:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dce4ef;
  --line-strong: #c6d2e2;
  --text: #172033;
  --muted: #64748b;
  --blue: #2367e8;
  --blue-dark: #174db3;
  --blue-soft: #eaf1ff;
  --green: #087c55;
  --green-soft: #e8f7f0;
  --amber: #9a6700;
  --amber-soft: #fff6da;
  --red: #b42318;
  --red-soft: #fff0ee;
  --purple: #6b41c7;
  --purple-soft: #f2edff;
  --shadow: 0 14px 38px rgba(28, 48, 82, .09);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.splash { position: fixed; inset: 0; z-index: 9999; display: grid; place-content: center; justify-items: center; gap: 18px; background: #fff; transition: opacity .25s ease, visibility .25s ease; }
.splash.done { opacity: 0; visibility: hidden; }
.splash img { width: 88px; height: 88px; border-radius: 24px; }
.splash div { display: grid; text-align: center; gap: 4px; }
.splash strong { font-size: 24px; letter-spacing: .06em; }
.splash span { color: var(--muted); font-size: 14px; }
.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 32px 18px; background: radial-gradient(circle at 10% 10%, #dfeaff, transparent 30%), radial-gradient(circle at 90% 90%, #e7f6ff, transparent 30%), #f7f9fd; }
.login-card { width: min(100%, 490px); background: #fff; border: 1px solid var(--line); border-radius: 28px; padding: 34px; box-shadow: 0 26px 70px rgba(24, 49, 88, .14); }
.brand-lockup { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.brand-lockup img { width: 82px; height: 82px; border-radius: 22px; box-shadow: var(--shadow); }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.brand-lockup h1 { margin: 4px 0 4px; font-size: 33px; line-height: 1; }
.brand-lockup p { margin: 0; color: var(--muted); }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #364152; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: 12px; padding: 11px 12px; outline: 0; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35,103,232,.13); }
textarea { resize: vertical; min-height: 96px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 12px; padding: 9px 15px; font-weight: 800; color: var(--text); background: #fff; transition: transform .08s, filter .15s, border-color .15s; }
.button:hover { filter: brightness(.98); }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.button.primary { background: var(--blue); color: #fff; }
.button.danger { background: var(--red); color: #fff; }
.button.success { background: var(--green); color: #fff; }
.button.secondary { border-color: var(--line-strong); background: #fff; }
.button.soft { background: var(--blue-soft); color: var(--blue-dark); }
.button.ghost { background: transparent; border-color: var(--line); }
.button.compact { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.button.large { min-height: 50px; font-size: 15px; }
.button.icon { width: 42px; padding: 0; }
.fine-print { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.inline-message, .global-notice { border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.45; }
.inline-message.error, .global-notice.error { background: var(--red-soft); color: var(--red); border: 1px solid #f2c4be; }
.inline-message.success, .global-notice.success { background: var(--green-soft); color: var(--green); border: 1px solid #b9e5d2; }
.inline-message.info, .global-notice.info { background: var(--blue-soft); color: var(--blue-dark); border: 1px solid #c8d9ff; }
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: calc(18px + var(--safe-top)) 14px 18px; background: #fff; border-right: 1px solid var(--line); z-index: 40; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; border: 0; background: transparent; text-align: left; padding: 4px 8px 19px; color: inherit; }
.sidebar-brand img { width: 44px; height: 44px; border-radius: 12px; }
.sidebar-brand span { display: grid; line-height: 1.1; }
.sidebar-brand b { font-size: 19px; letter-spacing: .08em; }
.sidebar-brand small { color: var(--muted); font-weight: 800; font-size: 11px; letter-spacing: .07em; margin-top: 4px; }
.nav-list { display: grid; gap: 5px; }
.nav-button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 12px; padding: 10px 12px; background: transparent; color: #475569; font-weight: 750; text-align: left; }
.nav-button .nav-icon { width: 22px; text-align: center; font-size: 17px; }
.nav-button.active { background: var(--blue-soft); color: var(--blue-dark); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 15px 5px 0; display: grid; gap: 10px; }
.user-card { display: grid; gap: 2px; min-width: 0; }
.user-card b, .user-card span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card span { color: var(--muted); font-size: 12px; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 88px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: calc(15px + var(--safe-top)) 26px 15px; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 25px; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.batch-switcher { min-width: 240px; gap: 4px; }
.batch-switcher span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.batch-switcher select { padding: 8px 34px 8px 10px; min-height: 42px; }
.global-notice { margin: 16px 24px 0; }
.page-root { padding: 22px 24px calc(34px + var(--safe-bottom)); }
.loading-panel { min-height: 360px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-section { display: grid; gap: 18px; }
.section-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.section-header h2, .card h2, .card h3 { margin: 0; }
.section-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; box-shadow: 0 8px 25px rgba(40,62,92,.04); }
.metric-card .metric-label { color: var(--muted); font-size: 12px; font-weight: 750; }
.metric-card .metric-value { font-size: 29px; font-weight: 850; margin-top: 8px; letter-spacing: -.02em; }
.metric-card .metric-foot { margin-top: 7px; color: var(--muted); font-size: 11px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 25px rgba(40,62,92,.04); }
.card.flush { padding: 0; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 14px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .span-4 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; align-items: center; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.toolbar .grow { flex: 1 1 230px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 750px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
td { font-size: 13px; }
tbody tr:hover { background: #fbfcff; }
.cell-title { display: grid; gap: 3px; max-width: 380px; }
.cell-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-title small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 850; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.green { color: var(--green); background: var(--green-soft); }
.status.blue { color: var(--blue-dark); background: var(--blue-soft); }
.status.amber { color: var(--amber); background: var(--amber-soft); }
.status.red { color: var(--red); background: var(--red-soft); }
.status.gray { color: #64748b; background: #edf1f6; }
.status.purple { color: var(--purple); background: var(--purple-soft); }
.progress { width: 100%; height: 9px; overflow: hidden; border-radius: 999px; background: #e9eef5; }
.progress > span { display: block; height: 100%; width: var(--progress, 0%); border-radius: inherit; background: var(--blue); transition: width .25s; }
.progress-row { display: grid; gap: 7px; }
.progress-row header { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.scan-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px; border: 2px solid #bad0ff; border-radius: 16px; background: linear-gradient(180deg,#f8fbff,#edf4ff); }
.scan-panel input { min-height: 56px; font-size: 19px; font-weight: 750; border-color: #9bbafd; }
.scan-panel .button { min-height: 56px; }
.scan-hint { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.queue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.queue-item { border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: grid; gap: 10px; background: #fff; }
.queue-item header { display: flex; justify-content: space-between; gap: 10px; }
.queue-item h3 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item p { margin: 0; color: var(--muted); font-size: 12px; }
.box-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 13px; }
.box-card { position: relative; display: grid; gap: 11px; border: 2px solid var(--line); border-radius: 16px; padding: 15px; background: #fff; }
.box-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35,103,232,.12); }
.box-card header { display: flex; justify-content: space-between; gap: 10px; }
.box-card h3 { font-size: 17px; }
.box-count { font-size: 31px; font-weight: 850; }
.box-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; font-size: 12px; color: var(--muted); }
.workflow { display: grid; gap: 11px; }
.workflow-step { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 15px; padding: 13px; background: #fff; }
.workflow-step .step-number { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-weight: 900; }
.workflow-step.done .step-number { background: var(--green-soft); color: var(--green); }
.workflow-step h3 { margin: 0; font-size: 14px; }
.workflow-step p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.option-list { display: grid; gap: 10px; margin-top: 12px; }
.option-card { border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: grid; gap: 9px; }
.option-card.selected { border-color: var(--blue); background: #f7faff; }
.option-card header { display: flex; justify-content: space-between; gap: 12px; }
.option-card pre { max-height: 220px; overflow: auto; margin: 0; padding: 10px; border-radius: 10px; background: #101827; color: #d8e3f5; font-size: 11px; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 26px minmax(0,1fr); gap: 10px; padding-bottom: 16px; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline-dot { width: 17px; height: 17px; border-radius: 50%; background: var(--blue-soft); border: 4px solid var(--blue); }
.timeline-item h4 { margin: 0; font-size: 13px; }
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.timeline-item time { display: block; margin-top: 4px; color: #94a3b8; font-size: 10px; }
.empty-state { min-height: 230px; display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; padding: 28px; color: var(--muted); }
.empty-state .empty-icon { font-size: 38px; }
.empty-state h3 { margin: 0; color: var(--text); }
.empty-state p { max-width: 440px; margin: 0; line-height: 1.5; }
.code-block { margin: 0; padding: 13px; max-height: 360px; overflow: auto; border-radius: 12px; background: #111827; color: #dbeafe; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: max(18px, var(--safe-top)) 18px max(18px, var(--safe-bottom)); background: rgba(16,24,39,.52); backdrop-filter: blur(4px); }
.modal { width: min(100%, 720px); max-height: calc(100dvh - 36px); overflow: auto; border-radius: 22px; background: #fff; box-shadow: 0 28px 90px rgba(9,20,42,.3); }
.modal.wide { width: min(100%, 980px); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 17px 18px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 18px; }
.modal-footer { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 9px; padding: 14px 18px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); }
.toast-root { position: fixed; z-index: 200; right: 18px; bottom: calc(18px + var(--safe-bottom)); display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 420px; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; background: #fff; box-shadow: var(--shadow); font-size: 13px; animation: toastIn .18s ease; }
.toast.success { border-color: #addfc9; color: var(--green); }
.toast.error { border-color: #efb8b2; color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.mobile-nav { display: none; }
.kv { display: grid; grid-template-columns: minmax(100px, .65fr) 1fr; gap: 8px 12px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.check-list { display: grid; gap: 8px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; }
.check-row .check { width: 20px; height: 20px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 900; }
.check-row.bad .check { background: var(--red-soft); color: var(--red); }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: #edf1f6; }
.segmented button { border: 0; border-radius: 9px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.segmented button.active { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(40,60,90,.1); }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-3 { grid-column: span 2; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { padding-bottom: calc(71px + var(--safe-bottom)); }
  .topbar { min-height: auto; align-items: flex-start; padding: calc(11px + var(--safe-top)) 14px 11px; }
  .topbar-title h1 { font-size: 21px; }
  .topbar-actions { align-items: stretch; }
  .batch-switcher { min-width: 145px; max-width: 210px; }
  .batch-switcher span { display: none; }
  #newBatchButton { width: 42px; padding: 0; font-size: 0; }
  #newBatchButton::before { content: "+"; font-size: 24px; }
  .page-root { padding: 15px 13px 24px; }
  .global-notice { margin: 12px 13px 0; }
  .mobile-nav { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr); padding: 7px 6px calc(7px + var(--safe-bottom)); background: rgba(255,255,255,.97); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .mobile-nav .nav-button { display: grid; justify-items: center; gap: 2px; padding: 5px 2px; border-radius: 9px; font-size: 9px; text-align: center; }
  .mobile-nav .nav-icon { font-size: 17px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .workflow-step { grid-template-columns: 36px minmax(0,1fr); }
  .workflow-step > .button, .workflow-step > .toolbar { grid-column: 1 / -1; }
  .scan-panel { grid-template-columns: 1fr; }
  .scan-panel .scan-hint { grid-column: auto; }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { width: 100%; max-height: calc(100dvh - var(--safe-top)); border-radius: 22px 22px 0 0; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { padding: 13px; }
  .metric-card .metric-value { font-size: 23px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3, .form-grid .span-4 { grid-column: auto; }
  .topbar-actions .button { flex: 0 0 auto; }
  .batch-switcher { max-width: 165px; }
  .card { padding: 14px; }
  .section-header { align-items: flex-start; }
  .section-header .toolbar { justify-content: flex-end; }
  .modal-body { padding: 14px; }
  .toast-root { left: 12px; right: 12px; bottom: calc(82px + var(--safe-bottom)); }
  .toast { min-width: 0; max-width: none; }
}
