:root {
  color-scheme: dark;
  --root: #171a21;
  --panel: #202630;
  --elevated: #252c36;
  --border: #343c48;
  --hover: #667384;
  --text: #f3f6fb;
  --muted: #afbac8;
  --accent: #1686ff;
  --accent-dark: #1e477a;
  --success: #7fe39a;
  --warning: #f5c95c;
  --failure: #f06f6f;
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--root); color: var(--text); }
a { color: #8ec4ff; text-decoration: none; }
a:hover { color: white; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1080px)/2)); border-bottom: 1px solid var(--border); background: #171a21; }
.brand { color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.account-nav { display: flex; align-items: center; gap: 20px; }
.account-nav form { margin: 0; }
.page { width: min(1080px, calc(100% - 40px)); margin: 42px auto 80px; }
.page.narrow { width: min(460px, calc(100% - 32px)); margin-top: 9vh; }
h1 { margin: 0 0 20px; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; letter-spacing: -.025em; }
h2 { margin: 0; font-size: 21px; line-height: 1.3; }
p { margin: 0 0 14px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .13em; }
.muted, .hint { color: var(--muted); }
.small, .hint { font-size: 12px; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.24); }
.auth-panel, .form-panel { padding: 26px; }
.auth-panel h1 { margin-bottom: 8px; }
.stack { display: grid; gap: 16px; margin-top: 22px; }
.form-field { display: grid; gap: 7px; min-width: 0; }
label { color: var(--text); font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--elevated); color: var(--text); font: inherit; outline: none; }
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(22,134,255,.18); }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--elevated); color: var(--text); font: inherit; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover, .button:hover { border-color: var(--hover); background: #333e4d; color: white; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; border-color: #3e4857; background: #303945; color: #a4b0c0; }
.primary { border-color: var(--accent); background: var(--accent-dark); color: var(--text); }
.primary:hover { border-color: var(--accent); background: #245995; }
.link-button { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--muted); }
.link-button:hover { border: 0; background: transparent; color: white; }
.auth-submit { width: 100%; min-height: 44px; margin-top: 4px; }
.auth-alert { margin-top: 14px; }
.errorlist { margin: 0; padding: 0; color: var(--failure); list-style: none; font-size: 13px; }
.field-errors { color: #ff9a9a; font-size: 13px; }
.field-errors ul { margin: 0; padding: 0; list-style: none; }
.hint { margin: 0; }
.alert { padding: 11px 13px; border: 1px solid rgba(240,111,111,.35); border-radius: 8px; background: rgba(240,111,111,.1); color: #ff9a9a; }
.notice { padding: 12px 14px; border: 1px solid rgba(22,134,255,.28); border-radius: 8px; background: rgba(22,134,255,.09); color: #b8d9ff; }
.page.workspace-page { margin-top: 24px; }
.upload-panel { margin-bottom: 30px; }
.upload-form { display: grid; gap: 20px; padding: 23px; }
.source-workspace { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; min-width: 0; }
.source-tabs { display: grid; align-content: start; gap: 8px; padding-right: 16px; border-right: 1px solid var(--border); }
.source-tab { width: 100%; justify-content: flex-start; min-height: 46px; text-align: left; }
.source-tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-dark); color: var(--text); }
.source-panels, .source-panel { min-width: 0; }
.upload-section { display: grid; min-width: 0; align-content: start; gap: 10px; }
.source-title { display: block; font-size: 14px; }
.file-input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.drop-zone { display: grid; min-height: 168px; align-content: center; justify-items: center; gap: 5px; border: 1px dashed #536275; border-radius: 10px; background: rgba(255,255,255,.018); cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.drag-over, .file-input:focus-visible + .drop-zone { border-color: var(--accent); background: rgba(22,134,255,.07); outline: none; }
.drop-zone strong { font-size: 14px; }
.drop-zone > span:last-child { color: var(--muted); font-size: 12px; }
.drop-icon { display: grid; width: 36px; height: 36px; margin-bottom: 4px; place-items: center; border-radius: 9px; background: rgba(22,134,255,.13); color: #a8cfff; font-size: 23px; }
.selected-file { max-width: 90%; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
#source-text { min-height: 168px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.upload-footer { display: flex; align-items: end; justify-content: flex-end; gap: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.submit-group { display: grid; justify-items: end; gap: 6px; }
.submit-group .hint { text-align: right; }
.submit-upload { min-width: 150px; min-height: 44px; }
.empty-state { margin-top: 24px; padding: 34px 20px; text-align: center; }
.empty-icon { display: grid; width: 48px; height: 48px; margin: 0 auto 14px; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--elevated); color: var(--accent); font-size: 24px; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state p { margin: 0; }
.results-section { margin-top: 34px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.results-heading .eyebrow { margin-bottom: 2px; }
.results-actions { display: flex; gap: 8px; }
.small-button { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.result-summary { margin: 0 0 12px; padding: 13px 16px; color: var(--muted); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 10px; }
.table-toolbar p { margin: 0; }
.table-panel { overflow: hidden; }
.table-wrap { max-height: 70vh; overflow: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.accounts-table { width: 100%; min-width: 2960px; table-layout: fixed; border-collapse: collapse; }
.accounts-table th, .accounts-table td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.accounts-table th { position: sticky; z-index: 1; top: 0; background: var(--elevated); color: var(--muted); font-size: 12px; font-weight: 700; }
.accounts-table th:nth-child(1) { width: 62px; }
.accounts-table th:nth-child(2) { width: 92px; }
.accounts-table th:nth-child(3) { width: 220px; }
.accounts-table th:nth-child(n+4):nth-child(-n+13) { width: 230px; }
.accounts-table th:nth-child(14) { width: 300px; }
.accounts-table tbody tr:last-child td { border-bottom: 0; }
.accounts-table tbody tr:hover { background: rgba(255,255,255,.025); }
.row-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.selection-cell { text-align: center !important; }
.status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--elevated); font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
.status-ready { color: var(--success); }
.status-review { color: var(--warning); }
.status-unrecognized, .status-error { color: var(--failure); }
.status-details summary { cursor: pointer; }
.status-details > div { margin-top: 8px; }
.reason-list { margin: 0; padding-left: 18px; color: var(--warning); font-size: 12px; }
.unknown-list { display: grid; gap: 9px; margin-top: 8px; }
.unknown-item { padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--elevated); }
.unknown-item pre, .source-details pre { margin: 0; overflow: auto; color: var(--text); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.unknown-item pre { max-height: 160px; }
.unknown-map { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-top: 8px; }
.unknown-map select { min-height: 34px; padding: 5px 8px; font-size: 12px; }
.unknown-map button { min-height: 34px; padding: 5px 8px; font-size: 12px; }
.cell-editor summary { min-height: 58px; max-height: 68px; overflow: hidden; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--elevated); cursor: pointer; color: var(--text); font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.cell-editor summary::marker { color: var(--accent); }
.cell-editor[open] summary { margin-bottom: 7px; border-color: var(--accent); color: var(--muted); }
.cell-editor textarea { display: block; min-height: 150px; padding: 8px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.source-details summary { color: #8ec4ff; cursor: pointer; font-size: 12px; }
.source-details pre { max-height: 220px; margin: 8px 0; padding: 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--elevated); }
.source-details button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; }
.pagination span { min-width: 105px; text-align: center; }
.export-panel { display: grid; gap: 12px; margin-top: 20px; padding: 23px; }
.export-heading, .export-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.export-heading h2 { margin: 0; }
#export-count, #copy-message { margin: 0; }
#export-output { min-height: 170px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.export-footer .primary { min-width: 150px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; clip-path: inset(50%) !important; }

@media (max-width: 650px) {
  .topbar { padding: 0 16px; }
  .account-nav { gap: 11px; font-size: 13px; }
  .page { width: calc(100% - 24px); margin-top: 26px; }
  .page.workspace-page { margin-top: 16px; }
  .page.narrow { width: calc(100% - 32px); margin-top: 9vh; }
  .auth-panel, .form-panel { padding: 19px; }
  .upload-form { gap: 18px; padding: 19px; }
  .source-workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .source-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 0 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .source-tab { justify-content: center; padding-right: 8px; padding-left: 8px; text-align: center; }
  .upload-footer { align-items: stretch; flex-direction: column; gap: 10px; }
  .submit-group { justify-items: stretch; }
  .submit-group .hint { text-align: left; }
  .submit-upload { width: 100%; }
  .results-heading { align-items: flex-start; flex-direction: column; }
  .results-actions { width: 100%; }
  .results-actions button { flex: 1; }
  .table-toolbar { align-items: flex-start; flex-direction: column; }
  .pagination { justify-content: space-between; }
  .export-panel { padding: 19px; }
  .export-heading, .export-footer { align-items: stretch; flex-direction: column; }
  .export-footer .primary { width: 100%; }
}
