/* Thirsty Layers — design system */
:root {
  --brand: #38bdf8;
  --brand-ink: #04121c;
  --bg: #0b0f17;
  --bg-2: #0f1420;
  --panel: #131a28;
  --panel-2: #182133;
  --line: #222c40;
  --line-2: #2c3850;
  --text: #e6ebf5;
  --muted: #8b97ad;
  --faint: #5d6a82;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --purple: #a78bfa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.center { text-align: center; }

/* boot */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #6366f1); display: grid; place-items: center; color: #fff; font-weight: 800; overflow: hidden; flex: none; }
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.brand-mode { font-size: 12px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--text); }
.nav-item.active svg { color: var(--brand); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; }
.main { min-width: 0; padding: 28px 32px 60px; animation: fadeUp .25s ease; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.pad-0 { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-label svg { width: 16px; height: 16px; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--faint); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .05s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.btn.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 20px; font-size: 16px; border-radius: 12px; }
.btn.xl { padding: 20px; font-size: 18px; border-radius: 16px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; padding: 0; }

/* forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); outline: none; font-weight: 500; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
textarea.input { min-height: 80px; resize: vertical; }
input[type=color].input { padding: 4px; height: 42px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.check-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); cursor: pointer; font-size: 13px; font-weight: 500; }
.chip-check input { accent-color: var(--brand); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

/* badges & bits */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.badge.purple { color: var(--purple); background: color-mix(in srgb, var(--purple) 12%, transparent); border-color: color-mix(in srgb, var(--purple) 30%, transparent); }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); display: inline-block; flex: none; }
.progress { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }
.progress.ok > div { background: var(--ok); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--faint); margin-bottom: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.alert-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.alert-icon svg { width: 17px; height: 17px; }
.kbd { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg-2); border: 1px solid var(--line-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* printers */
.printer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.printer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; gap: 10px; }
.printer:hover { border-color: var(--line-2); transform: translateY(-1px); }
.printer.st-printing { border-top: 3px solid var(--info); }
.printer.st-done { border-top: 3px solid var(--ok); }
.printer.st-failed { border-top: 3px solid var(--bad); }
.printer.st-paused { border-top: 3px solid var(--warn); }
.printer.st-offline, .printer.st-idle { border-top: 3px solid var(--line-2); }
.printer .pname { font-weight: 700; font-size: 16px; }
.drop-zone { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 14px; min-height: 70px; transition: border-color .15s, background .15s; }
.drop-zone.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.job { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; cursor: grab; display: flex; gap: 10px; align-items: center; }
.job.dragging { opacity: .4; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(3,6,12,.66); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fadeUp .15s ease; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; animation: fadeUp .2s ease; max-width: 340px; }
.toast.bad { border-color: var(--bad); }
.toast.ok { border-color: var(--ok); }

/* auth / wizard */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent), var(--bg); }
.auth-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); animation: fadeUp .3s ease; }
.auth-card.wide { width: min(640px, 100%); }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; font-size: 22px; }
.steps { display: flex; gap: 6px; margin-bottom: 24px; }
.steps div { flex: 1; height: 4px; border-radius: 99px; background: var(--line-2); }
.steps div.on { background: var(--brand); }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 22px; }
.mode-card { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px 16px; text-align: center; cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.mode-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.mode-card svg { width: 34px; height: 34px; color: var(--brand); }

/* phone mode */
.phone { min-height: 100vh; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; animation: fadeUp .2s ease; }
.phone-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(15,20,32,.94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 40; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 6px; cursor: pointer; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }
.tab .nav-badge { position: absolute; top: 0; right: 22%; }
.scan-big { width: 100%; aspect-ratio: 1; max-height: 52vh; border-radius: 24px; border: 2px dashed var(--line-2); background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer; color: var(--text); font-weight: 700; font-size: 18px; }
.scan-big svg { width: 64px; height: 64px; color: var(--brand); }
.video-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3/4; max-height: 60vh; margin: 0 auto; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.video-wrap .frame { position: absolute; inset: 18%; border: 3px solid var(--brand); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.big-choice { display: grid; gap: 10px; }
.big-choice .btn { padding: 16px; font-size: 16px; justify-content: flex-start; }
.walk-step { animation: fadeUp .2s ease; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* labels print page */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.qr-card { background: #fff; color: #111; border-radius: 12px; padding: 12px; text-align: center; }
.qr-card svg { width: 100%; height: auto; }
.qr-card .qname { font-weight: 800; font-size: 15px; margin-top: 4px; }
.qr-card .qtype { font-size: 11px; color: #555; text-transform: uppercase; letter-spacing: .06em; }

/* responsive */
@media (max-width: 1100px) { .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 45; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .main { padding: 18px 16px 60px; }
  .menu-btn { display: inline-flex !important; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .mode-grid { grid-template-columns: 1fr; }
}
.menu-btn { display: none !important; }
.phone .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.phone .stat-value { font-size: 24px; }
.phone .form-grid { grid-template-columns: 1fr; }

/* print (PDF reports, packing lists, QR labels) */
@media print {
  body { background: #fff; color: #111; }
  .sidebar, .no-print, #toast-root, .tabbar { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { background: #fff; border-color: #ddd; color: #111; break-inside: avoid; }
  .muted, .faint, .stat-label { color: #555 !important; }
  .table th { color: #555; }
  .table td, .table th { border-color: #ddd; }
  .chart text { fill: #444; }
  .modal-back { position: static; background: none; padding: 0; backdrop-filter: none; }
  .modal { box-shadow: none; border: 0; max-height: none; width: 100%; background: #fff; }
  .modal-head, .modal-foot { display: none; }
  body.printing-modal #app { display: none; }
}
