:root { font-family: system-ui, "Microsoft YaHei", sans-serif; color: #1d2a32; background: #f5f7f8; }
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 1380px; margin: 0 auto; padding: 24px 16px 56px; }
header { margin-bottom: 22px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 0 0 18px; }
p { line-height: 1.6; }
section { background: white; border: 1px solid #dde4e8; border-radius: 12px; padding: 22px; margin-bottom: 18px; box-shadow: 0 2px 12px #1d2a3209; }
label { display: block; font-weight: 600; margin: 0 0 16px; }
select, input[type=file], input[type=text], input:not([type]) { display: block; width: 100%; margin-top: 8px; padding: 11px; border: 1px solid #acbac3; border-radius: 8px; background: white; font: inherit; }
button { background: #1265aa; color: white; border: 0; border-radius: 8px; padding: 11px 17px; font: inherit; font-weight: 600; cursor: pointer; margin: 0 8px 8px 0; }
button.secondary { color: #14517f; background: #e8f1f8; }
button:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; }
.status { color: #315064; min-height: 1.5em; }
.note { color: #566b78; font-size: .88rem; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #10212e; color: #e4f5fa; border-radius: 8px; padding: 16px; min-height: 80px; max-height: 560px; overflow: auto; }
a { color: #0b64a7; }
[hidden] { display: none !important; }
nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
nav .tab { background: #e7edf1; color: #244b61; margin: 0; }
nav .tab.active { background: #1265aa; color: #fff; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.filters label { margin-bottom: 8px; }
input[type=search], input[type=date], input[type=number], select { display: block; width: 100%; margin-top: 8px; padding: 11px; border: 1px solid #acbac3; border-radius: 8px; background: white; font: inherit; }
.table-wrap { overflow-x: auto; border: 1px solid #dce5e9; border-radius: 10px; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; min-width: 1200px; font-size: .9rem; }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid #e3e9ec; vertical-align: top; }
th { white-space: nowrap; background: #e8f1f6; color: #244b61; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: #f9fbfc; }
.small { font-size: .83rem; padding: 6px 9px; margin: 0 5px 5px 0; white-space: nowrap; }
.warning { color: #9a5b04; font-weight: 600; }
.error { color: #aa2d28; font-weight: 600; }
.result-card, .supplier-card, .backup-box, .alias-box { border: 1px solid #dce5e9; border-radius: 10px; padding: 16px; margin: 16px 0; background: #fcfefe; }
.result-preview { width: 180px; height: 150px; object-fit: contain; border: 1px solid #dce5e9; cursor: zoom-in; background: white; }
.supplier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.supplier-card { margin: 0; }
.supplier-card h3 { margin-top: 0; }
.supplier-card strong { display: block; margin-bottom: 14px; color: #14517f; }
button.danger { background: #a53a35; }
dialog { width: min(940px, calc(100vw - 24px)); max-height: 90vh; border: 0; border-radius: 12px; padding: 24px; box-shadow: 0 12px 50px #10212e55; overflow: auto; }
dialog::backdrop { background: #10212e99; }
#image-dialog { width: min(95vw, 1200px); }
#full-image { width: 100%; height: auto; display: block; }
@media (max-width: 600px) {
  main { padding: 14px 10px 35px; }
  section { padding: 16px 12px; }
  nav { display: grid; grid-template-columns: 1fr 1fr; }
  nav .tab { padding: 10px 6px; font-size: .9rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  dialog { padding: 16px; }
}

.main-header{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.login-page{max-width:470px;min-height:100vh;display:grid;place-items:center;}
.login-panel{width:100%;padding:34px;}
.login-panel input{display:block;width:100%;margin-top:8px;padding:12px;border:1px solid #acbac3;border-radius:8px;font:inherit;}
.dropzone{border:2px dashed #8aaec9;border-radius:12px;background:#f5faff;padding:38px 18px;text-align:center;cursor:pointer;margin:10px 0 16px;}
.dropzone:focus-visible,.dropzone.dragover{background:#e4f3ff;border-color:#0b64a7;outline:2px solid #0b64a7;}
.dropzone strong{font-size:1.15rem;color:#175c87;}
.queued-file{display:inline-block;border-radius:6px;background:#e7f1f9;padding:6px;margin:3px;font-size:.86rem;}
.excel-panel{border:1px solid #dce5e9;background:#fbfcfe;padding:18px;border-radius:10px;margin:22px 0;}
.excel-panel select,.excel-panel input{max-width:100%;}
.excel-panel .preview-table{min-width:650px;width:max-content;}
.excel-panel .confirm-line{display:flex;gap:10px;align-items:flex-start;margin-top:18px;}
.excel-panel .confirm-line input{margin-top:4px;}
@media(max-width:600px){.main-header{align-items:flex-start;}.dropzone{padding:22px 12px;}}

.review-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 12px;background:#f0f7f9;border-bottom:1px solid #dce5e9;position:sticky;left:0;z-index:1;max-width:100%;width:max-content;min-width:min(100%,650px);}
.review-count{font-size:.9rem;color:#1d4b61;font-weight:600;margin-right:6px;}
.review-feedback{font-size:.88rem;color:#9a5b04;}
button.confirm-button{background:#16785b;color:#fff;}
button.confirm-button:hover{background:#10634b;}
.table-wrap td:first-child,.table-wrap th:first-child{text-align:center;}
.table-wrap td:first-child input[type=checkbox]{width:18px;height:18px;cursor:pointer;accent-color:#16785b;}
@media(max-width:600px){.review-toolbar{gap:4px;padding:8px;}.review-count{width:100%;}}

.cancelled-cell{text-decoration:line-through;text-decoration-thickness:1.5px;color:#8a8a8a;}
.summary-line{margin:12px 0 22px;padding:15px 18px;border-radius:10px;border:1px solid #c4ddd1;background:#f1faf5;color:#19583e;font-weight:650;line-height:1.7;}
.inline-check{display:inline-flex;align-items:center;gap:8px;margin:4px 12px;font-weight:550;font-size:.9rem;}
.inline-check input{width:17px;height:17px;accent-color:#16785b;}
button.danger.small{background:#ad3732;color:#fff;}
button.danger.small:hover{background:#8c2420;}

.cancelled-row td:nth-child(n+2):nth-child(-n+15){text-decoration:line-through;text-decoration-color:#a14e40;text-decoration-thickness:1.5px;color:#737e86;}
.cancelled-row td:nth-child(16){color:#a66e16;font-weight:700;}

/* Compact purchase ledger: one physical row per item; no content is truncated in storage. */
.records-toolbar-host{margin-top:12px;}
.review-table-shell{min-width:0;max-width:100%;margin:14px 0;}
.review-table-shell>.table-wrap{max-width:100%;margin:0;border-top:0;border-radius:0 0 10px 10px;}
.result-card{min-width:0;}
.review-toolbar.compact-toolbar{
  position:static;left:auto;z-index:auto;min-width:0;width:100%;max-width:100%;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:10px 12px;margin:0;border:1px solid #dce5e9;border-radius:10px 10px 0 0;
  background:#f0f7fa;box-sizing:border-box;
}
.toolbar-group{display:flex;flex-wrap:wrap;align-items:center;gap:6px;}
.compact-toolbar .toolbar-right{margin-left:auto;justify-content:flex-end;}
.compact-toolbar button{margin:0;padding:7px 11px;line-height:1.3;font-size:.82rem;white-space:nowrap;}
.compact-toolbar button:disabled{opacity:.38;cursor:not-allowed;filter:grayscale(.35);}
.compact-toolbar button.danger:not(:disabled){background:#b94442;}
.compact-toolbar .review-feedback{width:100%;font-size:.86rem;line-height:1.3;}
.records-toolbar-host + #records-table{margin-top:0;border-top:0;border-radius:0 0 10px 10px;}
.compact-records-table{
  table-layout:fixed;border-collapse:separate;border-spacing:0;min-width:0;
  font-size:.88rem;max-width:none;
}
.compact-records-table th,
.compact-records-table td{
  height:38px;max-height:38px;vertical-align:middle;
  padding:6px 9px;border-right:1px solid #e4ebee;border-bottom:1px solid #e4ebee;
  overflow:hidden;white-space:nowrap;text-overflow:ellipsis;line-height:1.4;
}
.compact-records-table .compact-th{
  position:sticky;top:0;height:41px;max-height:none;
  padding:7px 16px 7px 8px;overflow:visible;z-index:2;
  font-weight:650;background:#e8f1f6;user-select:none;
}
.compact-records-table .header-label{
  display:block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.compact-records-table .column-resize-handle{
  position:absolute;right:0;top:0;height:100%;width:9px;cursor:col-resize;
  touch-action:none;z-index:4;
}
.compact-records-table .column-resize-handle::after{
  content:'';position:absolute;top:9px;bottom:9px;left:4px;
  border-left:2px solid #9fb9c9;opacity:.55;
}
.compact-records-table .column-resize-handle:hover,
.compact-records-table .column-resize-handle:focus-visible{background:#c6e3f2;outline:1px solid #347fac;}
.compact-records-table .column-resize-handle:hover::after,
.compact-records-table .column-resize-handle:focus-visible::after{border-left-color:#176fa1;opacity:1;}
.compact-records-table .cell-ellipsis{
  display:block;width:100%;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.compact-records-table .checkbox-cell{text-align:center;padding:5px 6px;}
.compact-records-table .checkbox-cell input{width:17px;height:17px;vertical-align:middle;}
.compact-records-table tbody tr.selected-row td{background:#e9f5ff;}
.compact-records-table .cell-ellipsis.warning{color:#9a5b04;font-weight:650;}
.compact-records-table .cancelled-cell{text-decoration:line-through;}
body.resizing-records, body.resizing-records *{cursor:col-resize!important;user-select:none!important;}
@media (max-width:760px){
  .review-toolbar.compact-toolbar{align-items:flex-start;flex-direction:column;padding:9px;}
  .compact-toolbar .toolbar-right{margin-left:0;justify-content:flex-start;}
  .compact-records-table th,.compact-records-table td{font-size:.84rem;}
}

/* Multi-photo single-invoice intake, separate from normal batch intake. */
.upload-mode{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin:14px 0;}
.upload-mode label{display:inline-flex;gap:8px;align-items:center;padding:10px 13px;
  border:1px solid #c7dce8;border-radius:8px;background:#f5fafe;cursor:pointer;font-weight:600;margin:0;}
.upload-mode input{accent-color:#147f63;width:17px;height:17px;}
.multi-preview{border:1px solid #bbd7e2;border-radius:10px;margin-top:16px;background:#fbfdfe;}
.multi-preview h3{margin:0 0 12px;}
.multi-photos{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px;margin:12px 0;}
.multi-photo{padding:10px;border:1px solid #d6e5ed;border-radius:8px;background:#f1f8fc;}
.multi-photo strong,.multi-photo span{display:block;word-break:break-word;}
.multi-photo span{font-size:.85rem;color:#536a78;padding-top:4px;}
.multi-preview .table-wrap{max-height:450px;overflow:auto;}
.multi-preview table{min-width:950px;}
.multi-preview td{vertical-align:middle;font-size:.86rem;}
.multi-preview td.multi-name{max-width:240px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.multi-preview .multi-cancelled td:nth-child(n+3):nth-child(-n+7){text-decoration:line-through;color:#999;}
.multi-preview .inline-check{font-weight:650;margin-top:12px;}
.photo-navigation{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:12px;}
.photo-navigation button{margin-bottom:0;}
.photo-navigation span{font-size:.9rem;color:#244b61;flex:1;}

/* Pre-import editing and photo comparison for multiple-page slips. */
.multi-header-form{display:flex;flex-wrap:wrap;align-items:end;gap:10px;margin:14px 0;padding:12px;
  background:#f3f8fc;border:1px solid #d5e5ed;border-radius:8px;}
.multi-header-form label{display:flex;flex-direction:column;gap:4px;min-width:140px;flex:1;}
.multi-header-form input{width:100%;box-sizing:border-box;min-height:36px;}
.multi-header-form button{flex:0 0 auto;margin:0;}
.multi-review-table{border-collapse:collapse;table-layout:auto;min-width:1700px;width:max-content;max-width:none;}
.multi-review-table th,.multi-review-table td{font-size:.83rem;padding:8px 10px;vertical-align:middle;
  white-space:nowrap;max-width:230px;border:1px solid #e0e8ed;}
.multi-review-table .multi-cell-text{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px;}
.multi-review-table tbody tr.multi-modified{background:#eaf7f0;}
.multi-review-table tbody tr.multi-conflict{background:#fff1e9;}
.multi-review-table .multi-cancelled td:nth-child(n+3):nth-last-child(n+3) .multi-cell-text{text-decoration:line-through;}
.multi-review-table button{white-space:nowrap;}
.multi-editor-form{width:min(92vw,1300px);max-height:88vh;overflow-y:auto;padding:16px;}
#multi-editor{max-width:96vw;max-height:94vh;border-radius:12px;border:1px solid #cadde8;}
.multi-editor-columns{display:grid;grid-template-columns:minmax(420px,1fr) minmax(380px,1fr);gap:18px;}
.multi-edit-fields{display:grid;grid-template-columns:repeat(3,minmax(115px,1fr));gap:12px;}
.multi-edit-fields label{display:flex;flex-direction:column;gap:4px;font-size:.85rem;}
.multi-edit-fields input[type=text],.multi-edit-fields input[type=number]{width:100%;min-width:0;
  box-sizing:border-box;border:1px solid #bbcdd7;border-radius:6px;padding:8px;}
.multi-edit-fields label:has(input[type=checkbox]){flex-direction:row;align-items:center;grid-column:span 2;}
.multi-edit-fields input[type=checkbox]{width:18px;height:18px;accent-color:#177357;}
.multi-photo-review{position:relative;border:1px solid #dce8ed;background:#fafafa;border-radius:8px;overflow:auto;
  max-height:65vh;min-height:200px;}
.multi-photo-review p{padding:10px;margin:0;position:sticky;top:0;background:#f1f7fa;z-index:1;}
.multi-photo-review img{display:block;width:100%;height:auto;object-fit:contain;cursor:zoom-in;}
.multi-extra-row{display:flex;align-items:center;gap:8px;margin:8px 0;}
.multi-extra-row input{min-width:90px;padding:8px;border:1px solid #bed0da;border-radius:6px;}
.multi-extra-row .extra-name{flex:1;}.multi-extra-row .extra-value{flex:2;}
.multi-discarded{margin:8px 0;padding:10px;background:#f6f8fb;border:1px solid #dce3ee;border-radius:8px;}
.multi-discarded button{margin:4px;}
@media(max-width:850px){.multi-editor-columns{grid-template-columns:1fr;}.multi-edit-fields{grid-template-columns:repeat(2,minmax(115px,1fr));}.multi-photo-review{max-height:40vh;}}

/* Simplified inline-edit multipage ledger (single line, 10 core data columns). */
.multi-review-table{table-layout:fixed;min-width:1130px;width:100%;border-collapse:separate;border-spacing:0;}
.multi-review-table th,.multi-review-table td{max-width:none;min-width:0;height:40px;padding:7px 8px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;vertical-align:middle;}
.multi-review-table .multi-cell-text{display:block;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.multi-review-table th:nth-child(1),.multi-review-table td:nth-child(1){width:65px;}
.multi-review-table th:nth-child(2),.multi-review-table td:nth-child(2){width:165px;}
.multi-review-table th:nth-child(3),.multi-review-table td:nth-child(3){width:275px;}
.multi-review-table th:nth-child(4),.multi-review-table td:nth-child(4){width:120px;}
.multi-review-table th:nth-child(5),.multi-review-table td:nth-child(5){width:100px;}
.multi-review-table th:nth-child(6),.multi-review-table td:nth-child(6){width:75px;}
.multi-review-table th:nth-child(7),.multi-review-table td:nth-child(7){width:75px;}
.multi-review-table th:nth-child(8),.multi-review-table td:nth-child(8){width:100px;}
.multi-review-table th:nth-child(9),.multi-review-table td:nth-child(9){width:100px;}
.multi-review-table th:nth-child(10),.multi-review-table td:nth-child(10){width:100px;}
.multi-review-table th:nth-child(11),.multi-review-table td:nth-child(11){width:155px;}
.multi-review-table th:nth-child(12),.multi-review-table td:nth-child(12){width:105px;text-align:center;}
.multi-review-table .multi-edit-cell{cursor:text;}
.multi-review-table .multi-edit-cell:hover,.multi-review-table .multi-clickable-cell:hover{background:#e7f4fc;}
.multi-review-table .multi-clickable-cell{cursor:pointer;}
.multi-review-table .multi-inline-input{display:block;width:100%;min-width:0;margin:0;padding:3px;border:1px solid #2380b2;border-radius:3px;font:inherit;}
.multi-review-table tr.multi-modified{background:#e7f8ef;}
.multi-review-table tr.multi-conflict{background:#fff0e8;}
.multi-review-table tr.multi-cancelled .multi-cell-text{text-decoration:line-through;color:#8a8a8a;}
.multi-review-table td input[type=checkbox]{width:17px;height:17px;accent-color:#1265aa;}

.model-compare-panel{border:1px solid #dce5e9;border-radius:9px;margin:20px 0;padding:15px;}
.compare-results{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:12px;}
.compare-result{border:1px solid #dce5e9;border-radius:8px;background:#fbfcfd;padding:14px;min-width:0;}
.compare-result pre{max-height:340px;font-size:.8rem;}
.compare-result h4{margin:0 0 8px;}

.trash-documents-panel{margin:16px 0;padding:14px;border:1px solid #dce5e9;border-radius:9px;background:#fcfdfe;}
.trash-documents-panel h3{margin:0 0 10px;}
.trash-document-table{width:100%;border-collapse:collapse;min-width:870px;}
.trash-document-table td,.trash-document-table th{padding:9px 11px;border:1px solid #dae4eb;white-space:nowrap;}
.trash-document-table input[type=checkbox]{height:18px;width:18px;accent-color:#a33;}
.trash-document-ineligible{opacity:.62;}
.purge-confirm-form{max-width:660px;padding:12px;}
.purge-confirm-form label{display:flex;flex-direction:column;gap:8px;margin:14px 0;}
.purge-confirm-form input{width:100%;box-sizing:border-box;}
#purge-confirm-details ul{max-height:240px;overflow:auto;}

.cloud-panel{padding:16px;margin:14px 0;border:1px solid #dbe4eb;border-radius:10px;background:#fcfdff;}
.cloud-panel h3{margin-top:0;}
.cloud-auth-box{margin:14px 0;padding:12px;border:1px dashed #a1bfd0;border-radius:8px;}
#cloud-device-code{font-size:1.3rem;letter-spacing:.12rem;}
.cloud-jobs-table{width:100%;min-width:850px;border-collapse:collapse;}
.cloud-jobs-table th,.cloud-jobs-table td{border:1px solid #d8e1e9;padding:9px;white-space:nowrap;}
.cloud-long-cell{max-width:330px;overflow:hidden;text-overflow:ellipsis;}

.model-current{border:1px solid #d7e5ed;border-radius:10px;background:#edf6f9;padding:13px 16px;margin:15px 0;font-size:1.05rem;}
.model-switch-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:17px;margin:18px 0;}
.model-switch-panel{border:1px solid #d9e6ee;border-radius:12px;background:#fff;padding:19px;min-width:0;display:flex;flex-direction:column;gap:12px;}
.model-switch-panel h3{margin:0;}.model-switch-panel label{display:flex;flex-direction:column;gap:7px;}
.model-switch-panel label select,.model-switch-panel label input{max-width:100%;box-sizing:border-box;}
.model-switch-panel .note{margin:0;}.model-panel-selected{border-color:#198b79;box-shadow:inset 0 0 0 1px #198b79;}
.model-api-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;}
.model-api-tabs button{padding:9px 5px;min-width:0;}.model-api-tabs button.active{background:#106b99;color:#fff;}
.model-switch-panel button[id^="model-use"]{margin-top:auto;}
@media(max-width:850px){.model-switch-grid{grid-template-columns:1fr}.model-switch-panel{padding:14px;}}

/* Settlement review appears only when OCR detects a discount; ordinary slips stay collapsed. */
.settlement-details{margin:10px 0 15px;border:1px solid #d5e1e9;border-radius:9px;background:#fff}
.settlement-details[open]{border-color:#dda662;background:#fffcf7}
.settlement-details summary{padding:12px 15px;font-weight:650;cursor:pointer;color:#215674}
.settlement-details[open] summary{color:#924b16}
.settlement-form{padding:0 15px 14px;display:flex;flex-wrap:wrap;align-items:end;gap:12px}
.settlement-form label:not(.inline-check){min-width:190px;flex:1}
.settlement-form label:not(.inline-check) select,.settlement-form label:not(.inline-check) input{display:block;width:100%;margin-top:5px}
.settlement-original-note{width:100%;margin:3px 0;padding:8px;background:#fff2e7;border-radius:5px}
.settlement-form p.warning,.settlement-form p.note{width:100%;margin:1px 0}
.settlement-form .inline-check{width:100%}
.single-review{border:1px solid #e2ac72;border-radius:10px;padding:12px;margin-top:12px;background:#fffcf8}
.single-review-table{min-width:900px;border-collapse:collapse}
.single-review-table th,.single-review-table td{border:1px solid #dbe5ed;padding:6px}
.single-review-table input{width:100%;min-width:65px;padding:6px;font-size:14px}
.single-review-header{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0}
.single-review-header label{flex:1;min-width:160px}
.single-review-header input{width:100%}

/* Destructive action is visually distinct from ordinary edit/confirm controls. */
button.draft-delete{border-color:#c88080;color:#962e2e;background:#fff3f3}
button.draft-delete:hover:not(:disabled){background:#fbe1e1}

/* Supplier purchase date filters: dynamically populated years and responsive mobile layout. */
.supplier-period-tools{display:flex;align-items:end;gap:12px;flex-wrap:wrap;margin:4px 0 12px;padding:12px 14px;background:#f7fafc;border:1px solid #dce6ec;border-radius:10px;}
.supplier-period-tools label{flex:0 1 190px;min-width:145px;margin:0;}
.supplier-period-tools select{margin-top:7px;}
.supplier-period-tools button{margin:0 0 1px;}
@media(max-width:600px){.supplier-period-tools label{flex:1 1 calc(50% - 8px);min-width:110px;}.supplier-period-tools button{width:100%;}}

/* OpenAI compatible model configurator */
.model-switch-panel input[type=url],.model-switch-panel input[type=password]{display:block;width:100%;margin-top:8px;padding:11px;border:1px solid #acbac3;border-radius:8px;background:white;font:inherit;}
.model-test-box{padding:12px;border:1px solid #dbe5eb;border-radius:9px;background:#f7fafc;}
.model-test-box label:not(.inline-check){margin-bottom:12px;}
.model-test-box .inline-check{display:flex;flex-direction:row;align-items:center;gap:8px;margin:9px 0 13px;font-size:.85rem;}
.model-test-result{font-size:.82rem;max-height:300px;min-height:50px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;}
.model-switch-panel button.danger.small{background:#a53a35;color:white;}

/* Model settings v2: compact subscription, model browser + editor, mobile-friendly. */
#settings-section .model-settings-intro{margin:0 0 14px;}
#settings-section .model-current{
 display:flex;align-items:center;flex-wrap:wrap;gap:9px;
 margin:0 0 16px;padding:11px 15px;min-height:47px;
 background:#f1f7fa;border:1px solid #d8e7ec;border-radius:10px;font-size:.94rem;
}
#settings-section .model-current-indicator{height:9px;width:9px;flex:0 0 9px;border-radius:50%;background:#238b70;}
#settings-section .model-current-caption{color:#506577;font-size:.86rem;}
#settings-section .model-current strong{color:#153d58;overflow-wrap:anywhere;}
#settings-section .model-current-hint{font-size:.79rem;color:#687d8c;margin-left:auto;}
#settings-section .model-switch-grid{display:flex;flex-direction:column;gap:15px;margin:0 0 16px;}
#settings-section .model-switch-panel{min-width:0;margin:0;width:100%;box-shadow:none;}
#settings-section .model-oauth-details{
 display:block;background:#fff;padding:0;border:1px solid #dbe5eb;border-radius:12px;
}
#settings-section .model-oauth-details.model-panel-selected{border-color:#8abfb2;}
#settings-section .model-oauth-summary{
 display:flex;align-items:center;justify-content:space-between;gap:12px;cursor:pointer;
 padding:15px 19px;list-style:none;border-radius:12px;user-select:none;
}
#settings-section .model-oauth-summary::-webkit-details-marker{display:none;}
#settings-section .model-oauth-summary:focus-visible{outline:2px solid #1778b0;outline-offset:-3px;}
#settings-section .model-oauth-title{display:flex;flex-direction:column;gap:4px;min-width:0;}
#settings-section .model-oauth-title strong{font-size:1.02rem;}
#settings-section .model-oauth-title small{color:#667e8b;font-size:.81rem;font-weight:400;overflow-wrap:anywhere;}
#settings-section .model-oauth-toggle{font-size:.85rem;white-space:nowrap;color:#17628a;font-weight:650;}
#settings-section .model-oauth-toggle::after{content:'⌄';display:inline-block;margin-left:9px;font-size:1.15rem;transition:transform .2s;}
#settings-section .model-oauth-details[open] .model-oauth-toggle::after{transform:rotate(180deg);}
#settings-section .model-oauth-body{padding:17px 20px 20px;border-top:1px solid #edf1f4;}
#settings-section .model-oauth-body>.note{margin-bottom:13px;}
#settings-section .model-oauth-body>label{max-width:600px;}
#settings-section .model-oauth-body #model-use-oauth{width:auto;margin:5px 0 0;}
#settings-section .model-api-workspace{display:block;background:#fff;padding:0;border:1px solid #dbe5eb;border-radius:12px;}
#settings-section .model-api-workspace.model-panel-selected{border-color:#8abfb2;}
#settings-section .model-api-workspace-head{padding:19px 22px 16px;border-bottom:1px solid #e6edf1;}
#settings-section .model-api-workspace-head h3{margin:0 0 6px;font-size:1.1rem;}
#settings-section .model-api-workspace-head .note{margin:0;line-height:1.55;}
#settings-section .model-api-layout{display:grid;grid-template-columns:minmax(215px,28%) minmax(0,1fr);min-height:355px;}
#settings-section .model-api-sidebar{min-width:0;padding:18px 14px;border-right:1px solid #e6edf1;background:#f8fafc;border-radius:0 0 0 12px;}
#settings-section .model-api-sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:13px;}
#settings-section .model-api-sidebar-head h4{margin:0;font-size:.94rem;}
#settings-section .model-api-sidebar-head button{margin:0;flex-shrink:0;}
#settings-section .model-api-list{display:flex;flex-direction:column;gap:7px;}
#settings-section .model-api-list-item{
 display:flex;flex-direction:column;align-items:flex-start;gap:5px;width:100%;
 position:relative;margin:0;padding:12px 11px;text-align:left;white-space:normal;
 background:#fff;color:#233d50;border:1px solid #dce6ec;border-radius:8px;
 font-size:.89rem;font-weight:400;min-height:64px;
}
#settings-section .model-api-list-item:hover{border-color:#86b4ce;background:#f5fafe;}
#settings-section .model-api-list-item:focus-visible{outline:2px solid #137db1;outline-offset:2px;}
#settings-section .model-api-list-item.is-selected{border-color:#2c7baa;background:#eaf5fb;box-shadow:inset 3px 0 0 #2c7baa;}
#settings-section .model-api-list-item.is-active .model-api-list-item-title{padding-right:54px;}
#settings-section .model-api-list-item-title{font-weight:650;word-break:break-word;}
#settings-section .model-api-list-item-subtitle{font-size:.77rem;color:#617889;overflow-wrap:anywhere;}
#settings-section .model-api-list-item-badge{position:absolute;right:8px;top:9px;font-size:.7rem;border-radius:4px;padding:2px 5px;background:#e4f4ed;color:#186c4c;font-weight:650;}
#settings-section .model-api-empty{padding:18px 12px;background:#fff;border:1px dashed #c9d9e4;color:#637a89;border-radius:8px;font-size:.85rem;line-height:1.6;margin:0;}
#settings-section .model-api-sidebar>.note{margin:15px 0 0;font-size:.78rem;line-height:1.55;}
#settings-section .model-api-mobile-selector{display:none;}
#settings-section .model-api-editor{min-width:0;padding:19px 23px 18px;}
#settings-section .model-api-editor-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin:0 0 17px;}
#settings-section .model-api-editor-head h4{margin:0;font-size:1rem;}
#settings-section .model-editor-status{color:#62788a;background:#eef3f7;font-size:.75rem;font-weight:600;padding:4px 8px;border-radius:5px;}
#settings-section .model-editor-status.is-active{background:#e7f5ed;color:#176b4c;}
#settings-section .model-api-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 15px;}
#settings-section .model-api-form-grid label{margin:0;min-width:0;font-size:.88rem;}
#settings-section .model-api-field-full{grid-column:1/-1;}
#settings-section .model-api-form-grid input{margin:6px 0 0;min-height:42px;font-size:.91rem;}
#settings-section #model-key-status{margin:8px 0 15px;font-size:.79rem;}
#settings-section .model-api-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:0 0 14px;}
#settings-section .model-api-actions button{margin:0;}
#settings-section .model-api-actions #model-delete-api{margin-left:auto;background:#fff1f0;border:1px solid #ebc6c2;color:#9a3832;}
#settings-section .model-api-actions #model-delete-api:disabled{opacity:.4;}
#settings-section .model-test-details{display:block;background:#fafcfd;border:1px solid #e2eaf0;border-radius:9px;margin:0 0 12px;overflow:hidden;}
#settings-section .model-test-details summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:7px;padding:12px 14px;font-weight:600;font-size:.9rem;}
#settings-section .model-test-details summary::-webkit-details-marker{display:none;}
#settings-section .model-test-details summary::after{content:'⌄';color:#607e90;display:inline-block;transition:transform .2s;}
#settings-section .model-test-details[open] summary::after{transform:rotate(180deg);}
#settings-section .model-test-details summary small{font-weight:400;color:#62788a;font-size:.76rem;margin-left:auto;}
#settings-section .model-test-details summary:focus-visible{outline:2px solid #167ab0;outline-offset:-2px;}
#settings-section .model-test-box{background:#fff;border:0;border-top:1px solid #e2eaf0;border-radius:0;padding:14px;}
#settings-section .model-test-box button{margin:0;}
#settings-section .model-api-editor>.note{font-size:.8rem;line-height:1.6;}
#settings-section .model-api-editor>#model-api-feedback{margin:9px 0 0;font-size:.87rem;min-height:1.3em;}
@media(max-width:820px){
 #settings-section .model-api-layout{grid-template-columns:1fr;}
 #settings-section .model-api-sidebar{border-right:0;border-bottom:1px solid #e6edf1;border-radius:0;padding:12px 15px;}
 #settings-section .model-api-list{display:none;}
 #settings-section .model-api-mobile-selector{display:block;font-size:.85rem;font-weight:600;margin:0;}
 #settings-section .model-api-mobile-selector select{margin-top:7px;}
 #settings-section .model-api-sidebar>.note{margin-top:8px;}
 #settings-section .model-api-editor{padding:17px 16px 19px;}
}
@media(max-width:560px){
 #settings-section .model-current{padding:12px;gap:7px;}
 #settings-section .model-current-hint{margin-left:16px;flex-basis:100%;}
 #settings-section .model-oauth-summary{padding:13px 12px;}
 #settings-section .model-oauth-body{padding:14px 12px;}
 #settings-section .model-oauth-body .actions{gap:6px;}
 #settings-section .model-oauth-body .actions button{margin:0 0 5px;padding:9px 11px;}
 #settings-section .model-api-workspace-head{padding:15px 13px;}
 #settings-section .model-api-form-grid{grid-template-columns:minmax(0,1fr);gap:12px;}
 #settings-section .model-api-field-full{grid-column:auto;}
 #settings-section .model-api-actions{display:grid;grid-template-columns:1fr 1fr;}
 #settings-section .model-api-actions button{padding:10px 8px;}
 #settings-section .model-api-actions #model-delete-api{grid-column:1/-1;margin:0;justify-self:stretch;}
 #settings-section .model-test-details summary small{margin-left:0;}
 #settings-section .model-oauth-toggle{font-size:.8rem;}
}

/* Hierarchical model manager: collapsible provider panel and account/model tree. */
#settings-section .model-api-workspace{padding:0;}
#settings-section .model-api-accordion-summary{
 display:flex;align-items:center;justify-content:space-between;gap:14px;
 padding:15px 20px;cursor:pointer;list-style:none;border-radius:12px;
}
#settings-section .model-api-accordion-summary::-webkit-details-marker{display:none;}
#settings-section .model-api-accordion-summary:focus-visible{outline:2px solid #187cae;outline-offset:-3px;}
#settings-section .model-api-accordion-summary>span:first-child{display:flex;flex-direction:column;gap:4px;min-width:0;}
#settings-section .model-api-accordion-summary strong{font-size:1.03rem;}
#settings-section .model-api-accordion-summary small{color:#667b89;font-size:.8rem;font-weight:400;}
#settings-section .model-api-accordion-toggle{white-space:nowrap;color:#17628a;font-size:.85rem;font-weight:600;}
#settings-section .model-api-accordion-toggle::after{content:'⌄';display:inline-block;margin-left:8px;font-size:1.12rem;transition:transform .2s;}
#settings-section .model-api-workspace[open] .model-api-accordion-toggle::after{transform:rotate(180deg);}
#settings-section .model-api-workspace[open]>.model-api-layout{border-top:1px solid #e5edf2;}
#settings-section .model-api-account-group{border:1px solid #dce6eb;border-radius:9px;background:white;overflow:hidden;}
#settings-section .model-api-account-row{
 display:flex;align-items:center;gap:7px;width:100%;margin:0;padding:12px 11px;
 text-align:left;background:#fff;color:#263c4b;border:0;border-radius:0;min-height:45px;
 font-size:.87rem;
}
#settings-section .model-api-account-row:hover{background:#f1f8fc;}
#settings-section .model-api-account-row.is-selected{background:#eaf4fa;}
#settings-section .model-api-account-title{font-weight:650;overflow-wrap:anywhere;}
#settings-section .model-api-account-count{margin-left:auto;white-space:nowrap;color:#68808e;font-size:.72rem;}
#settings-section .model-api-account-arrow{font-size:1.1rem;color:#557083;width:13px;}
#settings-section .model-api-account-children{display:flex;flex-direction:column;gap:4px;padding:6px 7px 9px 16px;border-top:1px solid #e7eef2;}
#settings-section .model-api-account-children .model-api-list-item{
 min-height:51px;padding:9px 8px;background:#fff;border-color:transparent;box-shadow:none;
}
#settings-section .model-api-account-children .model-api-list-item.is-selected{
 border-color:#6faaca;background:#e8f4fb;box-shadow:inset 3px 0 0 #2c7baa;
}
#settings-section .model-api-account-children .model-api-list-item:hover{border-color:#a3c8dd;}
#settings-section .model-api-sidebar-bottom{margin-top:11px;}
#settings-section .model-api-sidebar-bottom button{width:100%;margin:0;}
#settings-section .model-api-list{gap:8px;}
#settings-section .model-account-editor{padding:0 0 16px;border-bottom:1px solid #e7edf2;margin-bottom:19px;}
#settings-section .model-entry-editor{margin-bottom:16px;}
#settings-section .model-account-editor .model-api-actions{margin:10px 0 0;}
#settings-section .model-account-editor #model-key-status{margin:7px 0;}
#settings-section .model-api-actions button.danger{margin-left:auto;background:#fff1f0;border:1px solid #ebc6c2;color:#9a3832;}
#settings-section .model-api-account-row:focus-visible,#settings-section .model-api-list-item:focus-visible{outline:2px solid #167ab0;outline-offset:-2px;}
@media(max-width:820px){
 #settings-section .model-api-sidebar-bottom{margin-top:9px;}
 #settings-section .model-api-mobile-selector{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
 #settings-section .model-api-mobile-selector label{font-size:.83rem;min-width:0;}
}
@media(max-width:560px){
 #settings-section .model-api-accordion-summary{padding:13px 12px;}
 #settings-section .model-api-mobile-selector{grid-template-columns:minmax(0,1fr);}
 #settings-section .model-api-account-row{font-size:.84rem;}
}

/* Records v3: sticky controls / sticky headings inside scrollable table and true pagination. */
#records-section #records-tools{position:sticky;top:0;z-index:10;background:#fff;}
#records-section .review-toolbar.compact-toolbar{border-radius:9px 9px 0 0;box-shadow:0 2px 5px #1b3a4513;}
#records-section #records-table{max-height:min(65vh,690px);min-height:175px;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;margin-top:0;border-radius:0;}
#records-section .compact-records-table .compact-th{top:0;position:sticky;z-index:3;background:#e8f1f6;box-shadow:0 1px 0 #cbdde7;}
#records-section .compact-records-table .compact-th.is-sorted{background:#d4eaf8;}
#records-section .sort-heading{display:flex;align-items:center;gap:4px;width:100%;max-width:100%;padding:2px 0;margin:0;
 border:0;border-radius:0;background:none;color:inherit;cursor:pointer;font:inherit;text-align:left;}
#records-section .sort-heading:hover{color:#075b99;}
#records-section .sort-heading:focus-visible{outline:2px solid #147aad;outline-offset:2px;}
#records-section .sort-indicator{font-size:.79rem;color:#4e7388;flex:0 0 auto;}
#records-section .compact-records-table tbody tr{cursor:pointer;}
#records-section .compact-records-table tbody tr:hover td{background:#ecf7ff;}
#records-section .compact-records-table tbody tr.selected-row td{background:#e1f2ff;}
#records-section .compact-records-table tbody tr.selected-row{box-shadow:inset 4px 0 #0d79ac;}
#records-section .compact-records-table tbody tr.cancelled-row.selected-row td{background:#f6f0e6;}
#records-section .compact-records-table tbody tr.cancelled-row.selected-row{outline:2px solid #197cac;outline-offset:-2px;}
#records-section .compact-records-table .checkbox-cell input{cursor:pointer;}
#records-section .compact-records-table td .cell-ellipsis{user-select:text;}
#records-section .records-pagination{display:flex;align-items:center;flex-wrap:wrap;gap:7px;margin:0 0 14px;padding:11px;
 border:1px solid #dce6ec;border-radius:0 0 10px 10px;background:#f8fbfd;}
#records-section .records-page-info{font-weight:600;color:#24526a;font-size:.87rem;white-space:nowrap;}
#records-section .records-page-buttons{display:flex;gap:3px;flex-wrap:wrap;}
#records-section .records-page-buttons button{margin:0;padding:7px 9px;min-width:32px;font-size:.84rem;}
#records-section .records-page-buttons button.current-page{background:#1167a5;color:#fff;}
#records-section .records-page-inputs{display:flex;align-items:center;gap:4px;margin:0;}
#records-section .records-page-inputs label{display:flex;align-items:center;gap:4px;margin:0;white-space:nowrap;font-size:.85rem;}
#records-section .records-page-inputs input{width:65px;max-width:72px;margin:0;padding:6px 4px;font-size:.87rem;min-height:32px;}
#records-section .records-page-inputs button{margin:0;}
#records-section #records-page-message{flex-basis:100%;min-height:0;}
/* Cloud backup forms: prevent 175px minimum grid columns from exceeding a phone viewport. */
#cloud-section,#cloud-section .cloud-panel{min-width:0;max-width:100%;}
#cloud-section .cloud-panel .filters{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));}
#cloud-section .cloud-panel .filters label{min-width:0;max-width:100%;}
#cloud-section .cloud-panel .filters input,#cloud-section .cloud-panel .filters select{
 display:block;box-sizing:border-box;min-width:0;max-width:100%;width:100%;}
#cloud-section .cloud-panel .actions{display:flex;flex-wrap:wrap;gap:8px;}
#cloud-section .cloud-panel .actions button{white-space:normal;min-width:0;overflow-wrap:anywhere;margin:0;}
@media(max-width:720px){
 #records-section .review-toolbar.compact-toolbar{gap:5px;padding:7px;}
 #records-section .compact-toolbar button{font-size:.78rem;padding:6px 7px;}
 #records-section .records-pagination{align-items:flex-start;}
 #records-section .records-page-info{width:100%;}
 #records-section .records-page-buttons{width:100%;}
 #records-section .records-page-buttons .page-number-far{display:none;}
}
@media(max-width:600px){
 #cloud-section .cloud-panel{padding:12px;margin:10px 0;}
 #cloud-section .cloud-panel .filters{grid-template-columns:minmax(0,1fr);}
 #cloud-section .cloud-panel .actions button{flex:1 1 145px;}
 #cloud-section .cloud-panel p,#cloud-section .cloud-panel code{overflow-wrap:anywhere;}
 #cloud-section .cloud-panel input[type=password]{width:100%;min-width:0;}
 #records-section .records-pagination{gap:8px;padding:9px;}
 #records-section #records-table{max-height:min(58vh,520px);}
 #records-section .records-page-inputs input{width:56px;}
}

/* Layout refresh: fluid desktop canvas; fixed side breathing room across viewport sizes. */
main{max-width:none;width:100%;min-width:0;margin:0;padding:24px clamp(20px,1.5vw,36px) 56px;}
main.login-page{max-width:470px;margin:0 auto;}
main>.page{min-width:0;}
#upload-section,#records-section,#suppliers-section,#settings-section,#cloud-section{min-width:0;}
#settings-section .model-api-layout{max-width:1500px;}
#settings-section .model-oauth-body{max-width:1050px;}
#cloud-section .cloud-panel>.filters{max-width:1020px;}
/* Table: JS updates max-height from current viewport and heights of toolbar, paging and totals.
   max-height instead of height lets short result sets use their natural row count. */
#records-section #records-table{max-height:var(--records-fit-height,calc(100dvh - 220px));height:auto;min-height:0;}
/* One upload surface with two explicit entry points; drag & paste remain available. */
#upload-section .dropzone{max-width:100%;margin:14px 0 12px;padding:24px 22px;text-align:center;cursor:default;}
#upload-section .upload-drop-title{display:flex;flex-direction:column;align-items:center;gap:5px;}
#upload-section .upload-drop-title .note{font-size:.86rem;}
#upload-section .upload-desktop-tip{margin:10px 0 16px;}
#upload-section .upload-entry-actions{display:flex;justify-content:center;align-items:stretch;gap:12px;flex-wrap:wrap;}
#upload-section .upload-entry-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-width:185px;max-width:260px;min-height:48px;flex:1 1 185px;padding:11px 18px;margin:0;
  border-radius:9px;font-size:1rem;line-height:1.4;}
#upload-section .upload-entry-button:focus-visible{outline:3px solid #2886ae;outline-offset:3px;}
#upload-section .upload-entry-hint{margin:14px 0 0;overflow-wrap:anywhere;}
#upload-section .dropzone.dragover{border-color:#0b64a7;background:#e4f3ff;}
/* On fine-pointer desktops the file picker is sufficient; camera is a mobile shortcut. */
@media (min-width:901px) and (hover:hover) and (pointer:fine){
 #upload-section #trigger-camera{display:none;}
 #upload-section .upload-entry-actions{max-width:340px;margin-inline:auto;}
}
@media (max-width:900px){
 main{padding:18px 16px 42px;}
}
@media (max-width:600px){
 main{padding:14px 12px 35px;}
 #upload-section .dropzone{padding:19px 13px;}
 #upload-section .upload-entry-actions{gap:9px;}
 #upload-section .upload-entry-button{min-width:0;max-width:none;flex:1 1 130px;padding:12px 7px;font-size:.92rem;}
 #upload-section .upload-desktop-tip{display:none;}
 #upload-section .upload-entry-hint{font-size:.81rem;}
}
@media(max-width:380px){
 #upload-section .upload-entry-actions{flex-direction:column;}
 #upload-section .upload-entry-button{width:100%;flex:0 0 auto;min-height:46px;}
}

/* Supplier day and filtered export controls */
#suppliers-section .supplier-period-tools label{flex:0 1 190px;min-width:142px;}
#suppliers-section .supplier-period-tools #supplier-export-filtered{margin:0 0 1px;}
/* Baidu credentials: visually match the tall, rounded backup strategy select. */
#cloud-section .cloud-credentials-grid{grid-template-columns:repeat(2,minmax(0,1fr));max-width:1020px;}
#cloud-section .cloud-credentials-grid label{min-width:0;}
#cloud-section .cloud-credentials-grid input[type=password]{
 display:block;width:100%;height:60px;min-height:0;max-width:100%;
 padding:12px 15px;margin-top:8px;border:1px solid #acbac3;border-radius:9px;
 background:#fff;font:inherit;line-height:1.4;box-sizing:border-box;
}
#cloud-section .cloud-credentials-grid input[type=password]:focus-visible{outline:2px solid #1265aa;outline-offset:1px;}
/* Keep the original action styles while aligning the controls horizontally. */
#cloud-section .cloud-panel .actions{align-items:center;}
#records-section .recently-updated-row td{background:#d7f1ff!important;transition:background 1.5s ease;}
#records-section #records-show-updated{margin-bottom:10px;}
@media(max-width:720px){
 #cloud-section .cloud-credentials-grid{grid-template-columns:minmax(0,1fr);}
 #suppliers-section .supplier-period-tools label{flex:1 1 calc(50% - 8px);}
 #suppliers-section #supplier-export-filtered{flex:1 1 100%;margin-top:4px;}
}
@media(max-width:440px){#suppliers-section .supplier-period-tools label{flex:1 1 100%;}}

#cloud-section #cloud-mode{height:60px;min-height:60px;padding:12px 15px;border-radius:9px;}

/* Model editor: form inputs and actions must not touch or overlap. */
#settings-section .model-entry-editor .model-api-actions{margin:16px 0 18px;gap:10px;}
#settings-section .model-entry-editor .model-api-actions button{margin-top:0;margin-bottom:0;}
/* High-volume Excel import preflight */
.excel-batch-review{margin:15px 0;padding:16px;border:1px solid #d5e2ea;border-radius:12px;background:#fafcfe;}
.excel-batch-review h4{margin:0 0 10px;}
.excel-batch-tools{display:flex;gap:9px;align-items:end;flex-wrap:wrap;margin:12px 0;}
.excel-batch-tools label{flex:1 1 190px;min-width:0;margin:0;}
.excel-batch-tools button{margin:0;}
.excel-page-tools{justify-content:flex-end;margin:8px 0;}
.excel-batch-wide-review{display:flex;align-items:flex-start;gap:9px;margin:10px 0;padding:11px 13px;border:1px solid #e8c98e;border-radius:9px;background:#fff8e9;color:#694414;font-weight:600;}
.excel-batch-wide-review input{flex:0 0 auto;margin-top:3px;}
.excel-attention-section{margin-top:12px;}
.excel-attention-section h5{margin:0;font-size:1rem;color:#714219;}
.review-count{display:inline-block;margin-left:5px;padding:2px 8px;border-radius:999px;background:#fff0d8;color:#7a441a;font-size:.85rem;}
.excel-batch-rows{max-height:540px;overflow:auto;border:1px solid #e0e8ed;border-radius:10px;background:white;}
.excel-batch-rows.is-empty{padding:18px;text-align:center;color:#587080;background:#f7fbf8;}
.excel-ready-details{margin-top:14px;border:1px solid #cfe2d6;border-radius:10px;background:#f7fbf8;overflow:hidden;}
.excel-ready-details>summary{cursor:pointer;padding:13px 15px;font-weight:700;color:#285f42;list-style-position:inside;}
.excel-ready-details[open]>summary{border-bottom:1px solid #dcebe1;}
.excel-ready-details>.note,.excel-ready-details>.excel-batch-tools{margin-left:14px;margin-right:14px;}
.excel-ready-rows{margin:0 14px 14px;width:auto;max-height:440px;}
.excel-review-card{padding:13px 14px;border-bottom:1px solid #e6edf2;}
.excel-review-card:last-child{border-bottom:0;}
.excel-review-card.needs-review{background:#fffaf1;}
.excel-review-card.has-error{background:#fff2f0;}
.excel-review-header{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.excel-review-header input[type=checkbox]{flex:0 0 auto;margin:0;}
.excel-review-header strong{overflow-wrap:anywhere;}
.excel-review-header .note{margin-left:auto;}
.excel-review-card p{margin:6px 0;line-height:1.55;overflow-wrap:anywhere;}
.excel-review-state{font-weight:600;color:#4b6877;}
.excel-review-card.has-error .excel-review-state{color:#9a3e32;}
.excel-review-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:11px;}
.excel-review-controls label{min-width:0;margin:0;}
.excel-review-controls select,.excel-review-controls input{width:100%;max-width:100%;box-sizing:border-box;margin-top:5px;}
.excel-review-card .inline-check{margin-top:9px;}
@media(max-width:600px){
 .excel-batch-review{padding:12px;}
 .excel-review-controls{grid-template-columns:minmax(0,1fr);}
 .excel-batch-tools label{flex:1 1 100%;}
 .excel-page-tools{justify-content:space-between;}
 .excel-ready-rows{margin:0 8px 10px;}
}

/* Returns are negative movements, visually distinct without changing original values. */
#records-table .return-ledger-value{color:#a73538;font-weight:600;}

/* Scoped to the Excel preflight; history and recognition tables retain their layout. */
.excel-sample-details{margin:14px 0;}
.excel-sample-details>summary,.excel-items-details>summary{cursor:pointer;color:#244b61;font-weight:600;padding:8px 0;}
.excel-panel .excel-detail-table{width:max-content;min-width:max(100%,960px);table-layout:auto;}
.excel-detail-table td{white-space:nowrap;max-width:260px;}
.excel-detail-table .excel-long-text{min-width:160px;max-width:300px;white-space:normal;overflow-wrap:anywhere;}
.excel-detail-table .excel-cell-edited{background:#fff0c5;}
.excel-detail-table tr.excel-row-error{background:#fff0ec;}
.excel-detail-table tr.excel-row-cancelled{color:#7a858d;text-decoration:line-through;}
.excel-detail-table td[data-editable]{cursor:pointer;}
.excel-detail-table td[data-editable]:hover{outline:1px solid #8aaec9;outline-offset:-1px;}
.excel-items-details .table-wrap{max-height:400px;overflow:auto;}
.excel-skipped-details{border-color:#dce3e8;background:#f7f9fb;}
.excel-skipped-details>summary{color:#566b78;}
.excel-review-card .excel-card-actions{margin:9px 0;gap:6px;}
.excel-review-card .excel-card-actions button{margin:0;}
#excel-row-fields .excel-original-value{display:block;font-size:.8rem;font-weight:400;color:#566b78;overflow-wrap:anywhere;margin-top:5px;}
#excel-row-form input[type=checkbox]{width:auto;}
@media(max-width:600px){.excel-detail-table .excel-long-text{max-width:210px;}#excel-row-fields{grid-template-columns:1fr;}}

/* Compact shell and records controls; other page forms retain their spacing. */
main{padding-top:10px;}
.main-header{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:18px;min-height:54px;margin-bottom:10px;}
.main-header h1{font-size:1.35rem;margin:0;white-space:nowrap;}
.main-header .site-nav{display:flex;justify-content:flex-start;gap:6px;flex-wrap:wrap;margin:0;min-width:0;}
.main-header .site-nav .tab{padding:9px 13px;font-size:.9rem;min-height:40px;}
.main-header #site-logout{margin:0;padding:9px 12px;font-size:.85rem;min-height:40px;white-space:nowrap;}
#records-section{padding:14px 16px;}
#records-section .records-filters{grid-template-columns:repeat(4,minmax(0,1fr));gap:9px 12px;}
.mobile-filter-toggle,.mobile-filter-summary{display:none;}
.supplier-period-fields,.supplier-period-actions{display:contents;}
#records-section .records-filters label,#records-section .records-more-filters label{margin:0;font-size:.86rem;min-width:0;}
#records-section .records-filters input,#records-section .records-filters select,
#records-section .records-more-filters select{height:38px;min-height:38px;margin-top:4px;padding:7px 9px;font-size:.9rem;min-width:0;}
#records-section .records-date-range{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;grid-column:span 2;}
#records-section .records-more-filters{grid-template-columns:repeat(3,minmax(0,1fr));max-width:980px;margin-top:10px;gap:12px;}
#records-section .records-search-actions{align-items:center;gap:7px;margin:10px 0 8px;}
#records-section .records-search-actions button{margin:0;padding:8px 12px;font-size:.88rem;min-height:36px;}
#records-section .records-search-actions .inline-check{margin:0 0 0 auto;font-size:.85rem;white-space:nowrap;}
#records-section .records-export-menu{position:relative;}
#records-section .records-export-menu>summary{list-style:none;cursor:pointer;border-radius:8px;background:#e8f1f8;color:#14517f;padding:8px 12px;font-weight:600;font-size:.88rem;min-height:36px;}
#records-section .records-export-menu>summary::-webkit-details-marker{display:none;}
#records-section .records-export-menu>summary:focus-visible{outline:2px solid #1265aa;outline-offset:2px;}
#records-section .records-export-options{position:absolute;top:calc(100% + 5px);left:0;z-index:30;min-width:255px;max-width:calc(100vw - 40px);padding:10px;border:1px solid #cfdee8;background:white;border-radius:9px;box-shadow:0 6px 22px #1d2a3225;display:grid;gap:8px;}
#records-section .records-export-options button{text-align:left;width:100%;}
#records-section .records-export-options small{font-size:.78rem;color:#566b78;line-height:1.5;}
#records-section .records-active-filters{display:flex;gap:5px;flex-wrap:wrap;margin:5px 0 8px;}
#records-section .filter-chip{font-size:.8rem;margin:0;}
#records-section #records-status{margin:6px 0;font-size:.88rem;min-height:0;}
#records-section #records-status:empty{display:none;}
#records-section #records-tools{margin:8px 0 0;}
#records-section .compact-toolbar{padding:9px 10px;gap:7px;}
#records-section .review-count{margin:0;font-size:.8rem;}
#records-section #records-table{margin:0 0 7px;border-top-left-radius:0;border-top-right-radius:0;}
#records-section .records-pagination{gap:6px 10px;margin:8px 0 6px;}
#records-section #record-summary{margin:6px 0;padding:9px 12px;font-size:.85rem;line-height:1.6;}
#suppliers-section #supplier-export-scope{align-self:center;}
@media(min-width:1600px){#records-section .records-filters{grid-template-columns:repeat(8,minmax(0,1fr));}}
@media(max-width:1050px){
 .main-header{grid-template-columns:minmax(0,1fr) auto;gap:8px;}
 .main-header .site-nav{grid-row:2;grid-column:1 / -1;}
 .main-header #site-logout{grid-column:2;grid-row:1;}
}
@media(max-width:700px){
 main{padding-top:8px;}
 .main-header{margin-bottom:8px;}
 .main-header h1{font-size:1.17rem;}
 .main-header .site-nav{flex-wrap:nowrap;overflow-x:auto;padding-bottom:3px;}
 .main-header .site-nav .tab{flex:0 0 auto;font-size:.85rem;padding:9px 10px;}
 #records-section{padding:11px 10px;}
 #records-section .mobile-filter-toggle,#suppliers-section .mobile-filter-toggle{display:block;width:100%;text-align:left;margin:0 0 5px;}
 #records-section .mobile-filter-summary{display:block;font-size:.85rem;color:#315064;line-height:1.4;overflow-wrap:anywhere;}
 #records-section .records-filter-panel:not(.open){display:none;}
 #records-section .records-filter-panel:not(.open)+.records-search-actions #records-more-toggle{display:none;}
 #records-section .records-filters{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
 #records-section .records-more-filters{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
 #records-section .records-more-filters label:last-child{grid-column:1 / -1;}
 #records-section .records-filters input,#records-section .records-filters select,#records-section .records-more-filters select{height:40px;min-height:40px;font-size:.9rem;}
 #records-section .records-search-actions .inline-check{margin-left:0;white-space:normal;flex-basis:100%;padding:4px 0;}
 #records-section .records-search-actions button,#records-section .records-export-menu>summary{min-height:40px;}
 #records-section .records-search-actions{gap:5px;position:relative;}
 #records-section .records-search-actions:has(.records-export-menu[open]){z-index:11;}
 #records-section .records-search-actions button,#records-section .records-export-menu>summary{padding:8px;font-size:.83rem;}
 #records-section .records-export-menu{position:static;}
 #records-section .records-export-options{left:0;right:0;top:calc(100% + 5px);width:100%;min-width:0;max-width:100%;}
 #records-section .compact-toolbar{padding:8px;}
 #records-section .compact-toolbar button{min-height:36px;}
 #records-section .toolbar-left{width:100%;min-width:0;}
 #records-section .toolbar-left [data-action="delete-restore"]{margin-left:auto;}
 #records-section .toolbar-right,.review-table-shell .toolbar-right{width:100%;flex-wrap:wrap;overflow:visible;padding-bottom:0;}
 #suppliers-section .supplier-period-fields{display:none;width:100%;flex-wrap:wrap;align-items:end;gap:12px;}
 #suppliers-section .supplier-period-fields.open{display:flex;}
 #suppliers-section .supplier-period-actions{display:flex;width:100%;flex-direction:column;gap:6px;}
 #suppliers-section .supplier-period-actions #supplier-export-filtered{width:100%;margin:0;}
}

/* Storage provider tabs, aligned with model platform selector. */
.cloud-provider-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:16px 0 18px;padding:5px;border:1px solid #dae6ed;border-radius:12px;background:#f0f5f8}
button.cloud-provider-tab{background:transparent;color:#35556a;margin:0;flex:1;min-width:160px;border-radius:8px}
button.cloud-provider-tab.active{background:#1265aa;color:#fff}
#cloud-s3-panel .cloud-panel{border:1px solid #dce5e9;border-radius:10px;padding:18px;margin:14px 0;background:#fff}
#cloud-s3-panel input[type=password],#cloud-s3-panel input[type=url],#cloud-s3-panel input[type=text]{display:block;width:100%;min-width:0;margin-top:8px;padding:11px;border:1px solid #acbac3;border-radius:8px;font:inherit}
#cloud-s3-panel .filters label{min-width:0}
@media(max-width:600px){button.cloud-provider-tab{min-width:0;font-size:.88rem;padding:10px 8px}}

#image-dialog #photo-source-choice{display:inline-block;width:auto;min-width:134px;max-width:205px;margin:0;padding:8px 10px;font-size:.88rem}
#photo-source{white-space:nowrap;color:#31586a;font-weight:600;font-size:.88rem}
@media(max-width:600px){#image-dialog #photo-source-choice{width:100%;max-width:100%;margin:2px 0 8px}}


/* Storage management: compact collapsible cards, consistent with AI model settings. */
#cloud-section .cloud-provider-accordions{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;margin:16px 0;}
#cloud-section details.cloud-provider-card{width:100%;min-width:0;margin:0;border:1px solid #dbe6ec;border-radius:12px;background:#fff;overflow:visible;}
#cloud-section details.cloud-provider-card:has(>summary:focus-visible){outline:2px solid #1265aa;outline-offset:2px;}
#cloud-section details.cloud-provider-card[open]{border-color:#a8d4c5;}
#cloud-section .cloud-provider-card>summary{list-style:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:88px;padding:16px 24px;}
#cloud-section .cloud-provider-card>summary::-webkit-details-marker{display:none;}
#cloud-section .cloud-provider-card>summary::marker{content:'';}
#cloud-section .cloud-provider-card>summary:hover{background:#f8fbfd;}
#cloud-section .cloud-provider-card[open]>summary{border-bottom:1px solid #e2edf0;border-radius:12px 12px 0 0;}
#cloud-section .cloud-provider-heading{display:grid;gap:7px;min-width:0;}
#cloud-section .cloud-provider-heading strong{font-size:1.12rem;color:#17364a;line-height:1.3;}
#cloud-section .cloud-provider-heading small{font-size:.84rem;font-weight:400;color:#597489;line-height:1.4;overflow-wrap:anywhere;}
#cloud-section .cloud-provider-toggle{display:flex;align-items:center;gap:9px;white-space:nowrap;color:#145c88;font-weight:650;font-size:.9rem;}
#cloud-section .cloud-provider-toggle::after{content:'⌄';font-size:1.2rem;line-height:1;display:inline-block;transition:transform .2s;}
#cloud-section .cloud-provider-card[open] .cloud-provider-toggle::after{transform:rotate(180deg);}
#cloud-section .cloud-provider-body{padding:17px 20px 20px;min-width:0;}
#cloud-section .cloud-provider-body>.cloud-panel:first-child{margin-top:0;}
#cloud-section .cloud-provider-body>.cloud-panel:last-child{margin-bottom:0;}
@media(max-width:600px){
 #cloud-section .cloud-provider-accordions{gap:10px;}
 #cloud-section .cloud-provider-card>summary{padding:13px 14px;min-height:78px;gap:8px;}
 #cloud-section .cloud-provider-heading strong{font-size:1rem;}
 #cloud-section .cloud-provider-heading small{font-size:.77rem;}
 #cloud-section .cloud-provider-toggle{font-size:.8rem;gap:4px;}
 #cloud-section .cloud-provider-body{padding:12px;}
}

#cloud-section details.cloud-provider-card.is-connected{border-color:#a7d5c1;}
#cloud-section .cloud-provider-card.is-connected .cloud-provider-heading small{color:#477e69;}

/* Dedicated backup and recovery page */
#recovery-section>.cloud-panel{border:1px solid #dbe7ec;border-radius:12px;padding:20px;margin:16px 0;background:#fff}
#recovery-section .recovery-preview{font-size:.87rem;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;max-height:340px;overflow-y:auto;background:#f0f6f9;color:#1a3e50;padding:15px;border-radius:9px;border:1px solid #c8dce8}
#recovery-section #recovery-state{white-space:pre-wrap;line-height:1.85}
#recovery-section #recovery-message{white-space:pre-wrap;line-height:1.65}
#recovery-section #recovery-r2-credentials{border:1px solid #d9e5eb;border-radius:9px;padding:12px 16px;margin:14px 0}
#recovery-section #recovery-r2-credentials summary{cursor:pointer;color:#2a546a;font-weight:600}
#recovery-section #recovery-apply-box{padding:15px;border:1px solid #d2b49d;background:#fffaf6;border-radius:10px;margin-top:14px}
/* Restore form: match the aligned label-above-control layout of the other panels. */
#recovery-section [hidden]{display:none!important}
#recovery-section .recovery-primary-fields,
#recovery-section .recovery-r2-fields{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px 16px;align-items:start}
#recovery-section .recovery-r2-fields{margin-top:20px}
#recovery-section .recovery-r2-endpoint,
#recovery-section .recovery-r2-credential{grid-column:span 2}
#recovery-section .recovery-confirm-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
#recovery-section .recovery-primary-fields>label,
#recovery-section .recovery-r2-fields>label,
#recovery-section .recovery-confirm-fields>label{display:flex;flex-direction:column;gap:8px;min-width:0;margin:0;font-weight:600;color:#253c4b}
#recovery-section .recovery-date-lookup{display:flex;flex-direction:column;gap:8px;min-width:0;align-self:start}
#recovery-section .recovery-date-lookup>label{font-weight:600;color:#253c4b}
#recovery-section .recovery-date-controls{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;min-width:0}
#recovery-section .recovery-primary-fields input,
#recovery-section .recovery-primary-fields select,
#recovery-section .recovery-r2-fields input,
#recovery-section .recovery-confirm-fields input{display:block;width:100%;max-width:100%;min-width:0;box-sizing:border-box;height:46px;min-height:46px;margin:0;padding:9px 12px;border:1px solid #bbcbd6;border-radius:8px;background:#fff;font:inherit;font-weight:400}
#recovery-section .recovery-primary-fields input[type=file]{padding:8px 10px;font-size:.88rem}
#recovery-section .recovery-date-controls button{height:46px;min-height:46px;margin:0;padding:0 14px;white-space:nowrap;font-size:.87rem}
#recovery-section #recovery-r2-credentials{min-width:0;padding:16px 20px}
#recovery-section #recovery-r2-credentials>summary{display:list-item;width:100%;min-height:26px;line-height:1.5;font-weight:600}
#recovery-section .recovery-primary-fields input:focus-visible,
#recovery-section .recovery-primary-fields select:focus-visible,
#recovery-section .recovery-r2-fields input:focus-visible,
#recovery-section .recovery-confirm-fields input:focus-visible{outline:2px solid #1265aa;outline-offset:2px}
@media(max-width:1100px){
 #recovery-section .recovery-primary-fields,
 #recovery-section .recovery-r2-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
 #recovery-section .recovery-r2-endpoint,
 #recovery-section .recovery-r2-credential{grid-column:span 2}
}
@media(max-width:620px){
 #recovery-section>.cloud-panel{padding:13px;margin:12px 0}
 #recovery-section #recovery-apply-box{padding:10px}
 #recovery-section .recovery-primary-fields,
 #recovery-section .recovery-r2-fields,
 #recovery-section .recovery-confirm-fields{grid-template-columns:minmax(0,1fr);gap:14px}
 #recovery-section .recovery-r2-endpoint,
 #recovery-section .recovery-r2-credential{grid-column:auto}
 #recovery-section #recovery-r2-credentials{padding:12px 14px}
}
