:root {
  color-scheme: light;
  --ink: #0a1837;
  --muted: #52617c;
  --surface: #ffffff;
  --ground: #f4f7fb;
  --line: #cbd4e3;
  --line-dark: #8d9bb2;
  --cobalt: #075bd8;
  --cobalt-dark: #0648aa;
  --cobalt-soft: #e9f1ff;
  --mint: #07883d;
  --mint-soft: #e4f7eb;
  --amber: #aa6100;
  --amber-soft: #fff2d8;
  --danger: #b42318;
  --danger-soft: #ffebe9;
  --radius-panel: 8px;
  --radius-control: 6px;
  --font: "Segoe UI Variable Text", "Aptos", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--ground); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--ground); font-family: var(--font); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.12; letter-spacing: -0.035em; }
h2 { margin-bottom: 5px; font-size: 1.2rem; line-height: 1.2; letter-spacing: -0.02em; }
h3 { margin-bottom: 4px; }
p { color: var(--muted); }
code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .8rem; }
:focus-visible { outline: 3px solid #7fb2ff; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.25rem; font-weight: 760; letter-spacing: -0.025em; text-decoration: none; }
.brand svg { width: 30px; height: 30px; color: var(--cobalt); stroke-width: 1.7; }
.brand--light { color: #fff; }
.brand--light svg { color: #84b3ff; }

.topbar { min-height: 68px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.ready-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; color: #065b2b; background: var(--mint-soft); border: 1px solid #b9e3c9; border-radius: var(--radius-control); font-weight: 650; }
.signal { display: inline-block; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--line-dark); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%); }
.signal--ok { background: var(--mint); }
.signal--warn { background: #d98200; }
.signal--bad { background: var(--danger); }
.signal--muted { background: #728097; }

.button { min-height: 42px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: var(--radius-control); font-weight: 680; line-height: 1.1; text-decoration: none; cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button svg { width: 20px; height: 20px; }
.button--primary { color: #fff; background: var(--cobalt); border-color: var(--cobalt); }
.button--primary:hover { background: var(--cobalt-dark); border-color: var(--cobalt-dark); }
.button--secondary { color: var(--cobalt-dark); background: #fff; border-color: var(--cobalt); }
.button--secondary:hover { background: var(--cobalt-soft); }
.button--quiet { min-height: 38px; padding-inline: 11px; color: var(--ink); background: transparent; border-color: var(--line); }
.button--quiet:hover { background: #edf2f8; border-color: var(--line-dark); }
.button--small { min-height: 34px; padding: 7px 10px; font-size: .86rem; }
.button--wide { width: 100%; }

.console { width: min(1500px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 38px) clamp(14px, 3.5vw, 48px) 56px; }
.operations { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr); gap: 16px; align-items: stretch; }
.upload-workbench, .route-console, .manifest { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); }
.upload-workbench { padding: clamp(18px, 2.5vw, 30px); }
.section-heading { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading p { max-width: 66ch; margin-bottom: 0; }
.upload-form { display: grid; gap: 12px; }
.drop-zone { min-height: 255px; padding: 32px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--ink); text-align: center; background: #fbfdff; border: 2px dashed #4d89e2; border-radius: var(--radius-panel); cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease; }
.drop-zone:hover, .drop-zone.is-dragging { background: var(--cobalt-soft); border-color: var(--cobalt); }
.drop-zone svg { width: 48px; height: 48px; margin-bottom: 6px; color: var(--cobalt); stroke-width: 1.7; }
.drop-zone strong { font-size: 1.35rem; letter-spacing: -0.02em; }
.drop-zone span { color: var(--muted); }
.upload-options { border: 1px solid var(--line); border-radius: var(--radius-control); }
.upload-options summary, .network-settings summary { padding: 12px 14px; color: var(--ink); font-weight: 660; cursor: pointer; }
.option-grid { padding: 4px 14px 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.upload-queue { min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius-control); overflow: hidden; }
.queue-empty { min-height: 46px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .88rem; }
.queue-item { padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; border-top: 1px solid var(--line); }
.queue-item:first-child { border-top: 0; }
.queue-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item__status { color: var(--muted); font-size: .84rem; }
.queue-item progress { grid-column: 1 / -1; width: 100%; height: 6px; border: 0; border-radius: 4px; overflow: hidden; }
progress::-webkit-progress-bar { background: #dfe5ee; }
progress::-webkit-progress-value { background: var(--cobalt); }
progress::-moz-progress-bar { background: var(--cobalt); }

.route-console { padding: 22px; }
.route-console__header { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.route-console__header p { margin: 0; font-size: .9rem; }
.route { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-control); }
.route + .route { margin-top: 10px; }
.route__title { margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.route__title > span { display: inline-flex; align-items: center; gap: 9px; font-weight: 760; text-transform: uppercase; letter-spacing: .035em; }
.route__title strong { font-size: .8rem; color: var(--muted); }
.route dl { margin: 0; display: grid; gap: 12px; }
.route dl > div { display: grid; grid-template-columns: 1fr; gap: 2px; min-width: 0; }
.route dt { color: var(--muted); font-size: .78rem; }
.route dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.network-settings { margin-top: 10px; border-top: 1px solid var(--line); }
.form-stack { display: grid; gap: 16px; }
.form-stack--compact { padding: 2px 0 0; gap: 12px; }
label > span, .form-stack label > span { display: block; margin-bottom: 6px; color: var(--ink); font-size: .86rem; font-weight: 660; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line-dark); border-radius: var(--radius-control); }
input::placeholder { color: #66758c; }
input:focus, select:focus { border-color: var(--cobalt); outline: 3px solid #d9e8ff; }

.manifest { margin-top: 16px; overflow: hidden; }
.manifest__heading { min-height: 76px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.manifest__heading p { margin: 0; font-size: .88rem; }
.search-field { position: relative; width: min(300px, 100%); }
.search-field svg { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 39px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #3f4e69; background: #f9fbfd; font-size: .76rem; font-weight: 720; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbff; }
.file-name { min-width: 210px; display: flex; align-items: center; gap: 11px; }
.file-name svg { width: 28px; height: 32px; flex: 0 0 auto; color: var(--cobalt); }
.file-name span { min-width: 0; }
.file-name strong, .file-name small { display: block; max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.status-tag { display: inline-flex; align-items: center; gap: 7px; font-size: .83rem; font-weight: 650; }
.row-actions { min-width: 176px; text-align: right; white-space: nowrap; }
.icon-button { width: 38px; height: 38px; padding: 8px; display: inline-grid; place-items: center; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-control); cursor: pointer; vertical-align: middle; }
.icon-button + .icon-button { margin-left: 4px; }
.icon-button:hover { color: var(--cobalt); background: var(--cobalt-soft); border-color: #7da9e8; }
.icon-button--danger:hover { color: var(--danger); background: var(--danger-soft); border-color: #e2aaa5; }
.icon-button svg { width: 20px; height: 20px; }
.empty-state { padding: clamp(40px, 8vw, 90px) 20px; text-align: center; }
.empty-state svg { width: 50px; height: 50px; margin: 0 auto 16px; color: var(--cobalt); }
.empty-state p { margin: 0 auto; max-width: 50ch; }

.qr-dialog { width: min(820px, calc(100% - 24px)); max-height: calc(100vh - 24px); padding: clamp(20px, 4vw, 34px); color: var(--ink); background: var(--surface); border: 1px solid var(--line-dark); border-radius: 10px; }
.qr-dialog::backdrop { background: rgb(5 16 38 / 68%); }
.dialog-close-form { position: absolute; top: 16px; right: 16px; }
.qr-dialog__header { padding-right: 48px; }
.qr-dialog__header p { margin-bottom: 4px; }
.qr-grid { margin: 24px 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qr-plate { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-panel); }
.qr-plate > div:first-child { display: flex; align-items: center; gap: 8px; }
.qr-plate > div:first-child small { margin-left: auto; color: var(--muted); font-size: .76rem; font-weight: 680; }
.qr-plate img { width: min(100%, 280px); aspect-ratio: 1; margin: 12px auto; display: block; image-rendering: pixelated; }
.qr-plate p { min-height: 40px; margin-bottom: 12px; overflow-wrap: anywhere; font-size: .78rem; }
.button-row { display: flex; gap: 8px; }
.button-row > * { flex: 1; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 20; max-width: min(380px, calc(100vw - 36px)); padding: 13px 16px; color: #fff; background: var(--ink); border: 1px solid #314466; border-radius: var(--radius-control); box-shadow: 0 12px 32px rgb(10 24 55 / 24%); }

.notice { padding: 12px 14px; color: #24415d; background: #edf6ff; border: 1px solid #a9c9ea; border-radius: var(--radius-control); }
.notice--error { color: #74180f; background: var(--danger-soft); border-color: #e4aaa5; }

.auth-page { background: #071633; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1.05fr) minmax(420px, .95fr); }
.auth-context { padding: clamp(30px, 7vw, 90px); display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: #071633; }
.auth-context h1 { max-width: 8ch; font-size: clamp(3rem, 7vw, 6rem); letter-spacing: -0.045em; }
.auth-context p { max-width: 55ch; color: #cbd9ef; font-size: 1.06rem; }
.auth-context__status { display: flex; align-items: center; gap: 9px; margin-bottom: 0; }
.auth-panel { padding: clamp(30px, 8vw, 120px); display: flex; flex-direction: column; justify-content: center; gap: 26px; background: var(--surface); }
.auth-panel > * { width: min(430px, 100%); margin-inline: auto; }
.auth-panel__label { margin-bottom: 9px; color: var(--cobalt-dark); font-size: .8rem; font-weight: 740; letter-spacing: .05em; text-transform: uppercase; }
.auth-panel h2 { font-size: 2.1rem; }

.download-page { background: #edf2f8; }
.download-shell { width: min(620px, calc(100% - 28px)); min-height: 100vh; margin: 0 auto; padding: clamp(24px, 7vh, 68px) 0 30px; display: flex; flex-direction: column; justify-content: center; }
.download-shell > .brand { margin-bottom: 22px; }
.download-card { padding: clamp(24px, 6vw, 44px); background: var(--surface); border: 1px solid var(--line-dark); border-radius: var(--radius-panel); }
.download-file-mark { position: relative; width: max-content; margin-bottom: 22px; }
.download-file-mark svg { width: 58px; height: 68px; color: var(--cobalt); }
.download-file-mark .signal { position: absolute; right: -4px; bottom: 3px; width: 13px; height: 13px; border: 2px solid #fff; }
.download-card__heading h1 { overflow-wrap: anywhere; }
.download-card__heading p { margin-bottom: 24px; }
.file-facts { margin: 0 0 24px; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.file-facts > div { min-width: 0; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.file-facts dt { color: var(--muted); font-size: .76rem; }
.file-facts dd { margin: 3px 0 0; overflow-wrap: anywhere; font-weight: 660; }
.button--download { min-height: 54px; font-size: 1.05rem; }
.download-note, .download-footer { margin: 12px 0 0; text-align: center; font-size: .82rem; }
.error-shell { width: min(560px, calc(100% - 32px)); min-height: 100vh; margin: auto; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.error-code { margin-top: 60px; color: var(--cobalt); font-size: clamp(5rem, 18vw, 10rem); font-weight: 800; letter-spacing: -.07em; line-height: .8; }
.error-shell h1 { margin-top: 30px; }
.error-shell p { max-width: 52ch; }

@media (max-width: 980px) {
  .operations { grid-template-columns: 1fr; }
  .option-grid { grid-template-columns: 1fr 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-context { min-height: 42vh; gap: 60px; }
  .auth-context h1 { max-width: 12ch; }
  .auth-panel { min-height: 58vh; }
}

@media (max-width: 720px) {
  .topbar { min-height: 60px; padding-inline: 14px; }
  .ready-pill { display: none; }
  .console { padding: 14px 10px 36px; }
  .upload-workbench, .route-console { padding: 17px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .button { width: 100%; }
  .drop-zone { min-height: 205px; }
  .option-grid, .qr-grid { grid-template-columns: 1fr; }
  .manifest__heading { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { padding: 15px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { min-height: 34px; padding: 5px 0 5px 112px; position: relative; border: 0; }
  td::before { content: attr(data-label); position: absolute; left: 0; top: 7px; width: 98px; color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
  td:first-child { padding-left: 0; padding-bottom: 13px; }
  td:first-child::before, .row-actions::before { display: none; }
  .file-name { min-width: 0; }
  .row-actions { min-width: 0; padding: 12px 0 0; text-align: left; }
  .icon-button { width: 42px; height: 42px; }
  .file-facts { grid-template-columns: 1fr; }
  .auth-context { min-height: 46vh; padding: 28px; }
  .auth-context h1 { font-size: clamp(2.7rem, 15vw, 4.5rem); }
  .auth-panel { padding: 34px 24px 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
