:root{color-scheme:light;--ink:#423624;--gold:#caa44f;--border:#dfd2b3;--paper:#fffdf8;--bg:#faf7ed;font-family:system-ui,sans-serif;color:var(--ink);background:var(--bg)}*{box-sizing:border-box}[hidden]{display:none!important}body{margin:0}header{display:flex;gap:12px;align-items:center;background:var(--paper);border-bottom:1px solid var(--border);padding:12px 4%;}header img{width:110px;max-height:65px;object-fit:contain}header small,small{display:block;color:#77684c}header button{margin-left:auto}main{max-width:1100px;margin:auto;padding:20px 14px}h1{font:600 32px Georgia,serif;margin:6px 0 16px}h2{font-size:20px;margin:0 0 10px}.panel,.stat{background:var(--paper);border:1px solid var(--border);border-radius:12px;padding:18px;margin-bottom:14px}.login{max-width:420px;margin:30px auto}label{display:block;font-size:14px;font-weight:600}input,button{font:inherit;border:1px solid var(--border);border-radius:8px;padding:11px;background:white;color:var(--ink)}input{width:100%;min-width:0;margin:6px 0 13px}button{cursor:pointer;min-height:44px}button:disabled{opacity:.5;cursor:not-allowed}.gold{background:var(--gold);font-weight:650}.login button{width:100%}.date,.title,.actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:space-between}.date label{flex:1}.date input{margin:4px 0 0}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.stat{margin:0 0 14px;border-top:3px solid var(--border)}.stat strong{display:block;font-size:24px;margin:6px 0}.stat small{font-size:13px}.customer{display:grid;grid-template-columns:24px 1.5fr 1fr 1fr 1fr auto;gap:12px;align-items:center;border-top:1px solid var(--border);padding:13px 0}.customer input[type=checkbox]{width:20px;height:20px;margin:0}.customer input[type=number]{margin:4px 0}.customer strong{overflow-wrap:anywhere}.muted{color:#77684c;font-size:13px}#status,#login-status{white-space:pre-wrap;font-size:14px}#status:not(:empty){padding:10px;background:#f4ebd5;border-radius:6px;margin:8px 0}footer{text-align:center;font-size:12px;color:#77684c;padding:20px}dialog{border:1px solid var(--border);border-radius:12px;max-width:90vw;background:var(--paper);color:var(--ink)}dialog::backdrop{background:#0007}@media(max-width:700px){.stats{grid-template-columns:repeat(2,1fr)}.stat strong{font-size:20px}.customer{grid-template-columns:24px 1fr 1fr}.customer strong{grid-column:span 2}.customer button{grid-column:span 3}.customer label{grid-column:span 1}.title #identity{font-size:12px;overflow-wrap:anywhere}header img{width:85px}.panel{padding:13px}}
.customer-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(135px,1fr));gap:10px;margin:14px 0}.tile{min-height:68px;font-weight:650;overflow-wrap:anywhere}.paid{background:#b3cca7}.partial{background:#f0dfa9}.pending{background:#fffdf8}.none{background:#e9e8e3}.legend{display:flex;flex-wrap:wrap;gap:8px;font-size:12px}.legend span{border:1px solid var(--border);padding:5px 8px;border-radius:6px}#detail{border:1px solid var(--border);padding:16px;border-radius:12px;background:#fffdf8;scroll-margin-top:12px}.detail-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.detail-grid .stat{padding:10px;margin:0}.pair{display:flex;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid #eee5d2;font-size:14px}.pair strong{text-align:right}progress{width:100%;height:14px;accent-color:#37864e}details{margin:16px 0;border:1px solid var(--border);border-radius:8px;padding:12px}summary{cursor:pointer;font-weight:650}.history-row{display:grid;grid-template-columns:1fr auto;gap:5px;border-top:1px solid var(--border);padding:10px 0;margin-top:8px}.history-row small{grid-column:1/-1}.red{color:#b42328}.green{color:#267847}.full{width:100%}@media(max-width:420px){.customer-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.pair{font-size:13px}}

/* Mobile-first presentation. Desktop and transaction logic remain unchanged. */
@media (max-width:700px){
  header{padding:8px 12px;gap:8px;min-height:58px}
  header img{width:66px;max-height:44px;flex-shrink:0}
  header>div{min-width:0;flex:1;line-height:1.25}
  header strong{font-size:14px}header small{font-size:11px}
  header button{font-size:12px;padding:8px 10px;min-height:44px;flex-shrink:0}
  main{padding:10px 12px 16px}
  #dashboard>.title{margin:0 0 8px}#dashboard>.title small{display:none}
  #dashboard>.title h1{font:650 21px system-ui,sans-serif;margin:0}
  #identity{display:none}
  .panel{padding:12px;margin-bottom:10px;border-radius:10px}
  .date{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:end;gap:6px;padding:9px}
  .date label{min-width:0;font-size:11px}
  .date input{display:block;min-width:0;max-width:100%;width:100%;height:44px;padding:6px;font-size:16px;text-align:center;appearance:none;-webkit-appearance:none}
  .date input::-webkit-date-and-time-value{text-align:center;min-width:0}
  .date button{padding:6px 9px;font-size:12px;min-height:44px;white-space:nowrap}
  #stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:0;background:var(--paper);border:1px solid var(--border);border-radius:10px;margin:0 0 10px;padding:2px 10px}
  #stats .stat{border:0;border-radius:0;background:transparent;margin:0;padding:10px 6px;min-width:0}
  #stats .stat:nth-child(-n+2){border-bottom:1px solid #eee5d2}
  #stats .stat:nth-child(even){padding-left:12px;border-left:1px solid #eee5d2}
  #stats .stat small{font-size:11px;line-height:1.25}
  #stats .stat strong{font-size:17px;line-height:1.2;margin:5px 0 0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
  #stats .stat:nth-child(2) strong{color:#267847}#stats .stat:nth-child(3) strong{color:#b42328}
  #dashboard>section.panel>h2{font-size:17px;margin:0 0 8px}
  #dashboard>section.panel>p.muted{display:none}
  #dashboard>section.panel>label{font-size:12px}
  #search{font-size:16px;height:44px;margin:4px 0 9px;padding:8px 10px}
  .legend{gap:4px;font-size:10px;line-height:1.2}
  .legend span{padding:4px 5px;border-radius:5px}
  .customer-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin:9px 0 0}
  .tile{min-height:48px;padding:7px 5px;font-size:13px;line-height:1.25;border-radius:7px}
  footer{padding:10px;font-size:10px}
  /* The selected customer takes over the mobile workspace, without a second page or duplicate data. */
  #dashboard:has(#detail:not([hidden]))>.title,
  #dashboard:has(#detail:not([hidden]))>.date,
  #dashboard:has(#detail:not([hidden]))>#stats,
  #dashboard:has(#detail:not([hidden]))>section.panel>h2,
  #dashboard:has(#detail:not([hidden]))>section.panel>label,
  #dashboard:has(#detail:not([hidden])) .legend,
  #dashboard:has(#detail:not([hidden])) #rows{display:none}
  #dashboard:has(#detail:not([hidden]))>section.panel{padding:0;border:0;background:transparent;margin:0}
  #dashboard:has(#detail:not([hidden])) #status:not(:empty){position:sticky;top:0;z-index:3;margin:0 0 8px;font-size:12px;box-shadow:0 2px 8px #42362415}
  #detail{padding:12px;min-width:0;scroll-margin-top:8px}
  #detail .actions{flex-wrap:nowrap;gap:8px;align-items:center}
  #detail .actions h2{font-size:18px;overflow-wrap:anywhere;margin:0}
  #detail .actions button{font-size:12px;padding:7px 9px;flex-shrink:0}
  #detail>p.muted{font-size:12px;margin:8px 0 10px}
  .detail-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .detail-grid .stat{padding:9px;border-top-width:1px;min-width:0}
  .detail-grid .stat small{font-size:11px}.detail-grid .stat strong{font-size:18px;margin:4px 0 0;overflow-wrap:anywhere}
  #detail h3{font-size:15px;margin:14px 0 6px}
  #detail progress{height:12px}
  .pair{font-size:12px;gap:8px;padding:9px 0;align-items:baseline}
  .pair strong{flex-shrink:0;max-width:48%;overflow-wrap:anywhere}
  #detail details{margin:12px 0;padding:10px;font-size:13px}
  #detail .history-row{font-size:12px}
  #detail input{font-size:16px;margin-bottom:8px;min-height:44px}
  #detail>.gold.full{position:sticky;bottom:max(8px,env(safe-area-inset-bottom));z-index:2;min-height:48px;box-shadow:0 3px 12px #42362422}
  dialog{width:min(360px,calc(100% - 24px));max-width:none}
}

.date-actions{display:flex;gap:10px;align-items:center}
@media(max-width:700px){
#dashboard>.date{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;align-items:stretch;overflow:hidden}
#dashboard>.date label{display:block;width:100%;min-width:0;max-width:100%}
#dashboard>.date #day{display:block;box-sizing:border-box;width:100%;min-width:0;max-width:100%;inline-size:100%;min-inline-size:0;margin:4px 0 0}
#dashboard>.date .date-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%;min-width:0}
#dashboard>.date .date-actions button{width:100%;min-width:0;margin:0}
}

/* Contact cards: independent call link and detail buttons. */
.customer-grid{grid-template-columns:repeat(auto-fill,minmax(195px,1fr))}
.customer-card{min-width:0;border:1px solid var(--border);border-radius:9px;padding:8px;overflow:hidden;display:flex;flex-direction:column;gap:2px}
.customer-card .tile,.card-values{background:transparent;border:0;width:100%;min-height:44px;padding:5px 2px;border-radius:5px;color:var(--ink)}
.customer-card .tile{display:flex;align-items:center;justify-content:center;overflow-wrap:anywhere}
.card-name{font-size:14px;line-height:1.25;text-align:center}.card-phone{text-align:center;font-size:12px;overflow-wrap:anywhere;color:#77684c;min-height:24px;display:flex;align-items:center;justify-content:center}.card-phone a{color:#675226;text-decoration:underline;text-underline-offset:2px;display:inline-flex;align-items:center;min-height:28px}.card-values{border-top:1px solid #c8b99080;display:flex;flex-direction:column;gap:5px;text-align:left;font-size:12px}.card-line{display:flex;justify-content:space-between;align-items:baseline;gap:4px;flex-wrap:wrap}.card-line strong{font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.customer-card button:focus-visible,.card-phone a:focus-visible{outline:2px solid #92712d;outline-offset:1px}
@media(max-width:700px){.customer-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.customer-card{padding:7px}.card-name{font-size:13px}.card-line{font-size:11px}.card-phone{font-size:11px}.card-values{padding:5px 0}.customer-card .tile{min-height:42px}}
