button, a, input, select, textarea{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.month-metrics button.metric{text-align:left;border:0;border-right:1px solid var(--line);border-radius:0;background:#fff;cursor:pointer;min-width:0}
.month-metrics button.metric:hover{background:#f0f7f3}
.month-metrics button.metric:focus-visible{outline:2px solid #247655;outline-offset:-3px}
.project-debt-lines table{min-width:0}
@media(max-width:700px){
  .project-debt-lines table tr{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:6px;min-height:38px}
  .project-debt-lines table td,.project-debt-lines table td:first-child,.project-debt-lines table td:has(button){grid-column:auto;display:block;padding:3px 6px;border:0;background:transparent;white-space:nowrap!important}
  .project-debt-lines table td:first-child{overflow:auto;font-size:12px}
  .project-debt-lines table td::before{display:none}
  .project-debt-lines table td button{min-height:30px;padding:3px;font-size:11px}
  .project-debt-lines table td.num{font-size:12px}
  .project-debt-lines table td[colspan]{grid-column:1/-1}
}
[hidden]{display:none!important}
.install-body{padding:24px;line-height:1.8}
.install-brand{display:flex;align-items:center;gap:16px}
.install-brand img{border-radius:8px;flex-shrink:0}
.install-brand strong{font-size:20px}
.install-brand p{margin:2px 0;color:var(--muted)}
.install-body ol{padding-left:24px}
.install-url{display:grid;gap:6px;font-size:12px}
.install-actions{display:flex;gap:10px;margin-top:16px}
.install-actions button{flex:1}
@media(max-width:700px){
  body{padding-bottom:calc(76px + env(safe-area-inset-bottom));overflow-x:hidden}
  .sidebar{padding:calc(10px + env(safe-area-inset-top)) 14px 10px}
  .brand{margin-bottom:10px;font-size:17px}
  .brand-mark{width:32px;height:32px}
  .brand small{font-size:11px}
  .sidebar nav{position:fixed;bottom:0;left:0;right:0;z-index:10;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;padding:6px 2px calc(6px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--line)}
  .sidebar nav button{display:flex;align-items:center;justify-content:center;min-height:48px;padding:6px 2px;border-left:0;border-radius:4px;font-size:12px;text-align:center;white-space:normal}
  .sidebar nav button.active{background:#e5f2eb;border-top:2px solid #247655}
  .sidebar-bottom{margin-top:0;gap:6px}
  .sidebar-bottom span{flex-basis:100%;margin:0;font-size:11px}
  .sidebar-bottom button{flex:1;min-height:40px;font-size:12px}
  header{padding:16px 0;min-height:0}
  h1{font-size:21px}
  .header-actions button{min-height:44px;font-size:14px}
  #content{padding-top:18px}
  .metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric{padding:14px 10px}
  .metric strong{font-size:22px}
  .metric small{display:block;line-height:1.7;font-size:10px}
  .section-head{align-items:center;flex-wrap:wrap}
  .toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:end;gap:10px}
  .toolbar label,.toolbar .search{max-width:none;min-width:0}
  .toolbar .search{grid-column:1/-1}
  input,select,textarea,.toolbar input,.toolbar select{font-size:16px}
  .toolbar input,.toolbar select,.toolbar button{min-height:44px;height:auto}
  .table-wrap{overflow:visible;border:0;background:transparent;margin-bottom:20px}
  table,table:has(th:nth-child(8)),table:has(th:nth-child(12)){min-width:0;width:100%;display:block}
  table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  table tbody{display:grid;gap:12px}
  table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0;background:#fff;border:1px solid var(--line);border-radius:6px;overflow:hidden}
  table td{display:block;border-bottom:1px solid #edf0f2;min-width:0;padding:10px 12px;text-align:left;overflow-wrap:anywhere;white-space:normal!important;font-size:13px}
  table td::before{content:attr(data-label);display:block;font-size:10px;color:var(--muted);font-weight:400;margin-bottom:4px}
  table td:first-child,table td[data-wide],table td[colspan],table td:has(button){grid-column:1/-1}
  table td:first-child{background:#f2f5f8;font-weight:600}
  table td:has(button){display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:8px}
  table td:has(button)::before{margin-right:auto}
  table td button{min-height:42px;padding:8px 12px;font-size:13px}
  table td[colspan]::before{display:none}
  table td[colspan]{padding:24px}
  table td.num{font-size:14px}
  .summary-total{gap:12px;align-items:flex-start}
  .summary-total strong{font-size:15px}
  .summary-total span{flex-basis:100%}
  dialog,#detail{width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0}
  .dialog-head{padding:calc(14px + env(safe-area-inset-top)) 16px 14px;gap:12px}
  .dialog-head h2{font-size:16px;overflow-wrap:anywhere;min-width:0}
  .dialog-head button{flex-shrink:0;width:44px;height:44px}
  #entryForm,.detail-body,.install-body{padding:18px 16px calc(24px + env(safe-area-inset-bottom))}
  .form-actions button{min-height:46px;flex:1}
  .allocation-list{max-height:40dvh}
  .allocation-row{grid-template-columns:32px minmax(0,1fr);padding:12px 8px;gap:10px}
  .allocation-row input[type=checkbox]{width:24px;height:24px}
  .allocation-row input[type=number]{grid-column:2;font-size:16px;min-height:44px}
  .allocation-row small{line-height:1.7}
  #toast{bottom:calc(82px + env(safe-area-inset-bottom))}
  footer{padding:16px 0;font-size:11px}
}

@media(max-width:360px){.metric strong{font-size:19px}.sidebar nav button{font-size:11px}.summary-total strong{flex-basis:100%}}

/* Dense overview: each summary record occupies exactly two grid rows. */
header{min-height:72px}
#content{padding-top:14px}
.section-head{margin-bottom:8px}
.metrics{margin-bottom:16px}
.metric{padding:12px}
.metric strong{margin:6px 0;font-size:23px}
td,th{padding:8px 10px}
.table-wrap{margin-bottom:16px}
.master-tabs{margin-bottom:14px}
@media(max-width:700px){
  .sidebar{padding:calc(6px + env(safe-area-inset-top)) 10px 6px}
  .brand{margin:0;font-size:15px}
  .brand-mark{width:27px;height:27px}
  main{padding:0 10px}
  header{padding:8px 0;gap:6px;min-height:0}
  h1{font-size:18px}
  .eyebrow{display:none}
  .header-actions:has(button[hidden]):not(:has(button:not([hidden]))){display:none}
  #content{padding-top:10px}
  .metric{padding:9px}
  .metric strong{font-size:20px;margin:4px 0}
  .metric small{line-height:1.3}
  .section-head h2{font-size:14px}
  .toolbar{gap:6px;margin-bottom:10px}
  .toolbar input,.toolbar select,.toolbar button{min-height:38px;font-size:14px}
  table tbody{gap:6px}
  table td{padding:6px 8px;font-size:12px}
  table td::before{margin-bottom:2px}
  table td button{min-height:36px;padding:6px 8px;font-size:12px}
  .detail-body{padding:10px}
  .summary-total{gap:7px;padding:10px 0}
  footer{padding:10px 0}
  .compact-summary tr,.compact-buyers tr{
    grid-template-columns:repeat(6,minmax(0,1fr));
    grid-template-rows:36px 44px;
  }
  .compact-summary td,.compact-buyers td{
    grid-column:auto;grid-row:auto;padding:4px 6px;min-width:0;
    white-space:nowrap!important;overflow:hidden;text-overflow:ellipsis;
    background:#fff!important;font-size:12px;
  }
  .compact-summary td:nth-child(1){grid-column:1/4;grid-row:1}
  .compact-summary td:nth-child(2){grid-column:4/5;grid-row:1;font-size:11px;text-align:right}
  .compact-summary td:nth-child(2)::after{content:" 笔"}
  .compact-buyers td:nth-child(1){grid-column:1/3;grid-row:1}
  .compact-buyers td:nth-child(2){grid-column:3/5;grid-row:1;font-weight:600}
  .compact-summary td:nth-child(-n+2),.compact-buyers td:nth-child(-n+2){line-height:27px}
  .compact-summary td:nth-child(-n+2)::before,.compact-buyers td:nth-child(-n+2)::before,
  .compact-summary td:last-child::before,.compact-buyers td:last-child::before{display:none}
  .compact-summary td:nth-child(3),.compact-buyers td:nth-child(3){grid-column:1/3;grid-row:2}
  .compact-summary td:nth-child(4),.compact-buyers td:nth-child(4){grid-column:3/5;grid-row:2}
  .compact-summary td:nth-child(5),.compact-buyers td:nth-child(5){grid-column:5/7;grid-row:2}
  .compact-summary td:last-child,.compact-buyers td:last-child{grid-column:5/7;grid-row:1;padding:0 4px;justify-content:flex-end}
  .compact-summary td button,.compact-buyers td button{min-height:34px;padding:4px;font-size:11px;white-space:nowrap}
  .compact-summary td.num,.compact-buyers td.num{font-size:12px}
  .compact-summary td[colspan],.compact-buyers td[colspan]{grid-column:1/-1;grid-row:1/-1;line-height:64px;text-align:center}
}

/* Compact list filters and records; full text remains scrollable in each cell. */
.toolbar{gap:6px;margin-bottom:8px}
.toolbar label{min-width:105px;max-width:160px;gap:3px}
.toolbar .search{max-width:200px}
.toolbar input,.toolbar select,.toolbar button{height:30px;min-height:30px;padding:4px 6px;font-size:12px}
.total-line{margin:8px 0;gap:12px;font-size:11px}
.compact-orders td,.compact-orders th,.compact-payments td,.compact-payments th{padding:5px 7px}
@media(max-width:700px){
  .toolbar{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
  .toolbar label,.toolbar .search{min-width:0;max-width:none;font-size:10px}
  .toolbar .search{grid-column:auto}
  .toolbar input,.toolbar select,.toolbar button{width:100%;height:30px;min-height:30px;font-size:12px;padding:3px 5px}
  .compact-orders tbody,.compact-payments tbody{gap:5px}
  .compact-orders tr,.compact-payments tr{grid-template-columns:repeat(3,minmax(0,1fr));border-radius:4px}
  .compact-orders td,.compact-payments td{
    grid-column:auto!important;padding:3px 5px;font-size:11px;line-height:16px;
    white-space:nowrap!important;overflow:auto;max-height:37px;
    touch-action:pan-x pan-y;
  }
  .compact-orders td:first-child,.compact-payments td:first-child{background:#fff;font-weight:400}
  .compact-orders td::before,.compact-payments td::before{font-size:9px;line-height:12px;margin:0}
  .compact-orders td.num,.compact-payments td.num{font-size:11px}
  .compact-orders td .pill{font-size:10px;padding:0 4px}
  .compact-orders td.actions,.compact-payments td.actions{
    grid-column:1/-1!important;max-height:none;min-height:30px;padding:0 4px;gap:12px;
  }
  .compact-orders td.actions::before,.compact-payments td.actions::before{display:none}
  .compact-orders td.actions button,.compact-payments td.actions button{
    min-height:30px;min-width:48px;padding:3px 8px;font-size:11px;
  }
  .compact-orders td[colspan],.compact-payments td[colspan]{grid-column:1/-1!important;max-height:none;padding:14px;text-align:center}
}
