/* TGT Terpadu - lembar kerja teknik
   Palet diambil dari logo dan situs resmi TGT:
   biru #2E3092, biru terang #4287D2, sian #00AEED/#76D6FF,
   tembaga logo #965C36, kertas hangat #F3EEE4. */

@font-face {
  font-family: "Source Sans 3";
  src: url("/static/fonts/SourceSans3-Variable.ttf") format("truetype");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/static/fonts/BarlowCondensed-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/static/fonts/BarlowCondensed-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #17181c;
  --ink-soft: #3c3b38;
  --muted: #787166;
  --paper: #f3eee4;
  --paper-2: #fbf8f2;
  --paper-3: #ece5d8;
  --line: #d8cdbb;
  --line-strong: #b9aa93;
  --blue: #2e3092;
  --blue-bright: #4287d2;
  --blue-deep: #202154;
  --cyan: #00aeed;
  --cyan-soft: #dff5ff;
  --copper: #965c36;
  --copper-soft: #f0dfd0;
  --good: #24624a;
  --good-soft: #e0efe6;
  --bad: #9c2b23;
  --bad-soft: #f7e2df;
  --warn: #99620a;
  --warn-soft: #f6e8ce;
  --radius: 2px;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
body.print-mode { background: #fff; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

::selection { background: var(--cyan-soft); color: var(--ink); }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--blue-deep);
  color: #f6f2e9;
  border-right: 1px solid #171840;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 14px;
}
.rail::-webkit-scrollbar { width: 4px; }
.rail::-webkit-scrollbar-thumb { background: #5e5fa0; }

.brand { display: flex; gap: 11px; align-items: center; color: #fff; text-decoration: none; padding: 2px 2px 16px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--paper-2);
  border: 1px solid #d9d2c3;
  border-radius: 1px;
  flex: 0 0 auto;
}
.brand-mark img { width: 36px; height: 36px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: .92; }
.brand-text strong { font-family: var(--display); font-weight: 700; font-size: 27px; letter-spacing: .06em; }
.brand-text span { font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: .38em; color: var(--cyan); }
.brand-text em { margin-top: 6px; font-style: normal; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: #b9bad9; }

.rail-rule { height: 1px; background: var(--copper); opacity: .9; margin: 0 2px 14px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 9px;
  color: #d9d9ef;
  font-size: 13px;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(0,174,237,.13); border-left-color: var(--cyan); color: #fff; }
.nav-no { font-family: var(--mono); font-size: 9px; color: #8f90c5; width: 18px; }
.nav-item.active .nav-no { color: var(--cyan); }
.rail-foot { margin-top: auto; padding-top: 18px; font-size: 10px; line-height: 1.5; color: #a9aacb; }
.rail-foot strong { color: #e8e7f7; font-weight: 600; display: block; font-size: 10px; letter-spacing: .04em; }
.rail-foot .doc-no { font-family: var(--mono); margin-top: 6px; color: #7f80b1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 30px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.locator {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  color: var(--copper);
  text-transform: uppercase;
  margin-bottom: 5px;
}
.crumb h1 { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: .02em; line-height: 1; text-transform: uppercase; }
.crumb p { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--ink);
  color: var(--paper-2);
  border: 1px solid var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
}
.btn-scan::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--cyan);
  background:
    linear-gradient(90deg, transparent 45%, var(--cyan) 45%, var(--cyan) 55%, transparent 55%);
}
.btn-scan:hover { background: var(--blue); border-color: var(--blue); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.avatar {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--blue); color: #fff; font-family: var(--display); font-weight: 700; font-size: 14px;
  border-radius: 1px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta a { font-size: 12px; font-weight: 600; color: var(--ink); }
.user-meta span { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.logout-form { margin: 0; }
.logout-form button {
  background: transparent; border: 0; color: var(--muted); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; padding: 4px;
}
.logout-form button:hover { color: var(--bad); }

.content { padding: 22px 30px 40px; flex: 1; min-width: 0; }
.pagefoot {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 14px 30px 18px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 9px; color: var(--muted); letter-spacing: .04em;
}

.notice {
  margin: 0 30px 0;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--paper-2);
  font-size: 12.5px;
}
.notice + .notice { margin-top: 6px; }
.notice.ok { border-left-color: var(--good); background: var(--good-soft); }
.notice.err { border-left-color: var(--bad); background: var(--bad-soft); }
.content > .notice { margin: 0 0 16px; }

/* ---------- typography ---------- */
.display { font-family: var(--display); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.mono { font-family: var(--mono); font-size: .92em; }
.label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
  margin-bottom: 4px;
}
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.tiny { font-size: 10px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }
.copper { color: var(--copper); }
.cyan { color: #007cae; }
.blue { color: var(--blue); }
.danger { color: var(--bad); }
.good { color: var(--good); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1.2;
  text-decoration: none;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--ink); color: var(--paper-2); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
.btn-copper { background: var(--copper); border-color: var(--copper); color: #fff; }
.btn-copper:hover { background: #744425; border-color: #744425; }
.btn-cyan { background: var(--cyan); border-color: var(--cyan); color: #062434; }
.btn-cyan:hover { background: #0095ca; border-color: #0095ca; color: #fff; }
.btn-ghost { border-color: var(--line-strong); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-3); color: var(--ink); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { padding: 5px 8px; font-size: 9px; letter-spacing: .08em; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; font-size: inherit; }

/* ---------- panels & ledger ---------- */
.panel { border: 1px solid var(--line); background: var(--paper-2); border-radius: var(--radius); min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.panel-title { font-family: var(--display); font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; line-height: 1.1; }
.panel-title .no { font-family: var(--mono); font-size: 9px; color: var(--copper); margin-right: 7px; vertical-align: 2px; }
.panel-meta { font-family: var(--mono); font-size: 9px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.panel-body { padding: 14px; }
.panel-foot { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--paper); }
.panel-flat { background: transparent; }

.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: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.grid-4 > * { background: var(--paper-2); }
.grid-gap { gap: 16px; background: none; border: 0; }
.grid-gap > * { background: transparent; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.kpi { background: var(--paper-2); padding: 13px 14px; min-width: 0; }
.kpi-value { font-family: var(--display); font-size: 38px; font-weight: 700; line-height: .9; letter-spacing: .01em; }
.kpi-value small { font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 7px; }
.kpi-note { font-size: 10.5px; color: var(--muted); margin-top: 5px; }

.hero {
  position: relative;
  overflow: hidden;
  background: var(--blue-deep);
  color: #fff;
  border: 1px solid var(--blue-deep);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.065) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.065) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; }
.hero-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); }
.hero h2 { font-family: var(--display); font-size: clamp(30px, 4vw, 48px); line-height: .94; text-transform: uppercase; letter-spacing: .02em; margin-top: 8px; }
.hero p { color: #c8c9e5; font-size: 12.5px; max-width: 560px; margin-top: 8px; }
.hero-side { min-width: 190px; border-left: 1px solid rgba(255,255,255,.22); padding-left: 18px; font-size: 11px; color: #c8c9e5; }
.hero-side div + div { margin-top: 8px; }
.hero-side strong { display: block; color: #fff; font-family: var(--mono); font-size: 11px; font-weight: 500; }

.data-list { display: grid; gap: 0; }
.data-list .row { display: flex; justify-content: space-between; gap: 18px; padding: 7px 0; border-bottom: 1px dotted var(--line); }
.data-list .row:last-child { border-bottom: 0; }
.data-list dt, .data-list .key { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.data-list .val { text-align: right; font-size: 12.5px; }

.table-wrap { width: 100%; overflow-x: auto; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ledger thead th {
  text-align: left;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  padding: 8px 8px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--paper);
  font-weight: 700;
  white-space: nowrap;
}
.ledger tbody td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger tbody tr:hover { background: #f2fafd; }
.ledger .group-row td { background: var(--paper-3); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.ledger .sub td { background: #fdfbf7; font-size: 11.5px; color: var(--ink-soft); }
.ledger .total td { background: var(--paper); font-weight: 700; border-top: 1px solid var(--line-strong); }
.ledger .empty-row td { padding: 20px; text-align: center; color: var(--muted); }
.ledger td.tight, .ledger th.tight { width: 1%; white-space: nowrap; }
.ledger-compact tbody td, .ledger-compact thead th { padding: 6px 6px; }

.empty { padding: 32px 18px; text-align: center; color: var(--muted); font-size: 12.5px; border: 1px dashed var(--line); background: transparent; }
.empty strong { display: block; font-family: var(--display); font-size: 21px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 5px; }

/* ---------- stamps / badges ---------- */
.stamp {
  display: inline-block;
  padding: 3px 7px 2px;
  border: 1px solid var(--line-strong);
  border-radius: 1px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--ink-soft);
  background: transparent;
}
.stamp.muted { color: var(--muted); border-color: var(--line-strong); }
.stamp.blue { color: var(--blue); border-color: #a9b6e8; background: #eff2ff; }
.stamp.cyan { color: #006c99; border-color: #92ddf6; background: var(--cyan-soft); }
.stamp.copper { color: #774321; border-color: #d9b79d; background: var(--copper-soft); }
.stamp.done { color: var(--good); border-color: #a9cbb8; background: var(--good-soft); }
.stamp.warn { color: var(--warn); border-color: #e3c589; background: var(--warn-soft); }
.stamp.bad { color: var(--bad); border-color: #dfa7a1; background: var(--bad-soft); }
.badge-dot { display: inline-block; width: 6px; height: 6px; background: currentColor; margin-right: 5px; vertical-align: 1px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.field { min-width: 0; }
.field > label, .field-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
  margin-bottom: 5px;
}
.input, input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  width: 100%;
  background: #fffdf9;
  border: 1px solid var(--line-strong);
  border-radius: 1px;
  padding: 8px 9px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
input[type="number"], .num-input { font-variant-numeric: tabular-nums; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(46,48,146,.13);
}
textarea { min-height: 78px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 25px; }
.hint { font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.checkline { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.checkline input { width: auto; margin-top: 2px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline-form input, .inline-form select { width: auto; }
.money-wrap { position: relative; }
.money-wrap input { padding-left: 30px; }
.money-wrap::before { content: "Rp"; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 10px; color: var(--muted); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 14px; }
.filter-bar .input, .filter-bar select { width: auto; min-width: 150px; }
.filter-bar .grow { flex: 1; min-width: 190px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 13px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- progress ---------- */
.progress { height: 7px; background: var(--paper-3); border: 1px solid var(--line); position: relative; }
.progress-bar { height: 100%; background: var(--blue); }
.progress-bar.cyan { background: var(--cyan); }
.progress-bar.good { background: var(--good); }
.progress-note { display: flex; justify-content: space-between; gap: 10px; font-size: 9px; font-family: var(--mono); color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- timeline ---------- */
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 5px; bottom: 5px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 16px 26px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: 2px; top: 4px; width: 11px; height: 11px; background: var(--paper-2); border: 1.5px solid var(--line-strong); border-radius: 50%; }
.timeline-item.done .timeline-dot { background: var(--good); border-color: var(--good); }
.timeline-item.current .timeline-dot { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.timeline-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.timeline-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.timeline-time { font-family: var(--mono); font-size: 9px; color: var(--muted); white-space: nowrap; }
.timeline-body { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- photos ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.photo-card { border: 1px solid var(--line); background: #fff; padding: 5px; }
.photo-card img { display: block; width: 100%; height: 120px; object-fit: cover; background: var(--paper-3); }
.photo-card .cap { font-size: 10px; color: var(--muted); padding: 5px 2px 1px; display: flex; justify-content: space-between; gap: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid img { width: 100%; height: 150px; object-fit: cover; border: 1px solid var(--line); }

/* ---------- checklist ---------- */
.checklist { display: flex; flex-direction: column; }
.check-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dotted var(--line); align-items: flex-start; }
.check-item:last-child { border-bottom: 0; }
.check-item.done .check-name { color: var(--muted); text-decoration: line-through; }
.check-box { width: 15px; height: 15px; border: 1px solid var(--line-strong); background: #fff; flex: 0 0 auto; margin-top: 1px; display: grid; place-items: center; font-size: 10px; color: transparent; }
.check-item.done .check-box { background: var(--good); border-color: var(--good); color: #fff; }
.check-main { flex: 1; min-width: 0; }
.check-name { font-size: 12px; }
.check-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 9px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }
.check-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- scan ---------- */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr); gap: 16px; align-items: start; }
.scan-stage { position: relative; background: #0c1320; border: 1px solid #0c1320; aspect-ratio: 4 / 3; overflow: hidden; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 14%; border: 1px solid rgba(255,255,255,.3); }
.scan-frame::before, .scan-frame::after {
  content: ""; position: absolute; width: 28px; height: 28px; border-color: var(--cyan); border-style: solid;
}
.scan-frame::before { left: -2px; top: -2px; border-width: 3px 0 0 3px; }
.scan-frame::after { right: -2px; bottom: -2px; border-width: 0 3px 3px 0; }
.scan-line { position: absolute; left: 14%; right: 14%; height: 2px; background: var(--cyan); box-shadow: 0 0 12px rgba(0,174,237,.85); animation: scanmove 2.4s linear infinite; }
@keyframes scanmove { 0% { top: 16%; opacity: .2; } 50% { opacity: 1; } 100% { top: 82%; opacity: .2; } }
.scan-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #9eb8c8; font-size: 11px; padding: 30px; }
.scan-empty strong { display: block; font-family: var(--display); font-size: 22px; letter-spacing: .08em; text-transform: uppercase; color: #fff; margin-bottom: 4px; }
.scan-controls { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.scan-result { border: 1px solid var(--line); background: var(--paper-2); padding: 14px; }

/* ---------- labels ---------- */
.label-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.label-sheet { display: grid; grid-template-columns: repeat(3, 62mm); gap: 2mm; background: #fff; padding: 6mm; width: max-content; max-width: 100%; border: 1px solid var(--line); }
.label-card { width: 62mm; height: 36mm; border: 1px dashed #bbb; padding: 2.5mm; display: grid; grid-template-columns: 22mm 1fr; gap: 2.5mm; overflow: hidden; background: #fff; box-sizing: border-box; }
.label-qr { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1mm; }
.label-qr img.qr { width: 20mm; height: 20mm; display: block; image-rendering: pixelated; }
.label-qr img.bc { width: 20mm; height: 5mm; object-fit: contain; }
.label-info { display: flex; flex-direction: column; min-width: 0; }
.label-brand { font-family: var(--display); font-size: 7pt; font-weight: 700; letter-spacing: .12em; color: var(--copper); }
.label-item { font-size: 7pt; font-weight: 700; line-height: 1.15; margin-top: 1mm; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.label-type { font-size: 6pt; color: #555; line-height: 1.15; margin-top: .5mm; }
.label-project { font-family: var(--mono); font-size: 5.5pt; color: #666; margin-top: auto; }
.label-code { font-family: var(--mono); font-size: 7.5pt; font-weight: 500; letter-spacing: .02em; margin-top: .5mm; }
.label-sheet + .label-sheet { page-break-before: always; }

/* ---------- print docs ---------- */
.print-toolbar {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--blue-deep); color: #fff;
}
.print-toolbar .hint { color: #b9bad9; margin: 0; }
.print-toolbar .btn { border-color: #fff; color: #fff; }
.print-toolbar .btn:hover { background: #fff; color: var(--ink); }
.doc { width: 210mm; min-height: 297mm; margin: 16px auto; background: #fff; padding: 15mm 16mm 14mm; border: 1px solid var(--line); color: #111; font-size: 10pt; }
.doc + .doc { margin-top: 20px; }
.doc-letterhead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--copper); padding-bottom: 4mm; }
.doc-brand { display: flex; gap: 10px; align-items: center; }
.doc-brand img { width: 19mm; height: 19mm; object-fit: contain; }
.doc-brand-name { font-family: var(--display); font-size: 20pt; font-weight: 700; letter-spacing: .06em; line-height: 1; text-transform: uppercase; }
.doc-brand-sub { font-size: 7pt; letter-spacing: .08em; text-transform: uppercase; color: #666; margin-top: 1mm; }
.doc-company { font-size: 7.5pt; color: #555; line-height: 1.4; max-width: 75mm; text-align: right; }
.doc-company strong { color: #111; }
.doc-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 6mm 0 4mm; }
.doc-title h1 { font-family: var(--display); font-size: 23pt; text-transform: uppercase; letter-spacing: .07em; line-height: 1; }
.doc-title .doc-no { font-family: var(--mono); font-size: 8pt; text-align: right; color: #444; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm 12mm; font-size: 8.5pt; margin-bottom: 5mm; }
.doc-meta .row { display: flex; justify-content: space-between; gap: 10px; border-bottom: .4pt dotted #bbb; padding-bottom: .8mm; }
.doc-meta .k { color: #666; }
.doc-meta .v { text-align: right; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 8.2pt; }
.doc-table th { background: #f2eee6; border: .5pt solid #9c9588; padding: 1.6mm; text-align: left; font-size: 7pt; text-transform: uppercase; letter-spacing: .06em; }
.doc-table td { border: .5pt solid #bbb4a6; padding: 1.6mm; vertical-align: top; }
.doc-table .num { text-align: right; }
.doc-table tr.addon td { background: #faf8f3; font-size: 7.6pt; color: #444; }
.doc-total { display: flex; justify-content: flex-end; margin-top: 3mm; }
.doc-total table { border-collapse: collapse; font-size: 8.5pt; min-width: 70mm; }
.doc-total td { padding: 1mm 2mm; }
.doc-total tr.grand td { border-top: 1.2pt solid #333; font-weight: 700; font-size: 10pt; }
.doc-terms { margin-top: 5mm; font-size: 7.8pt; line-height: 1.5; color: #333; }
.doc-terms h4 { font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1mm; }
.doc-sign { display: flex; justify-content: space-between; gap: 20mm; margin-top: 12mm; page-break-inside: avoid; }
.doc-sign div { flex: 1; text-align: center; font-size: 8pt; }
.doc-sign .line { height: 18mm; border-bottom: .6pt solid #777; margin-bottom: 2mm; }
.doc-sign .name { font-weight: 700; }
.doc-foot { margin-top: 8mm; border-top: .5pt solid #bbb; padding-top: 2mm; font-size: 6.8pt; color: #777; display: flex; justify-content: space-between; gap: 10px; }
.doc h2.section { font-family: var(--display); font-size: 13pt; text-transform: uppercase; letter-spacing: .06em; margin: 7mm 0 2mm; border-bottom: .6pt solid #bbb; padding-bottom: 1mm; }
.doc p { font-size: 8.5pt; line-height: 1.5; }

/* ---------- auth ---------- */
.auth-page { background: var(--paper); min-height: 100vh; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.auth-brand {
  position: relative; overflow: hidden; background: var(--blue-deep); color: #fff;
  padding: 46px clamp(30px, 6vw, 76px); display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 34px 34px;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand { padding: 0; }
.auth-mid { margin: 8vh 0; }
.auth-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan); }
.auth-mid h1 { font-family: var(--display); font-size: clamp(46px, 7vw, 82px); line-height: .88; letter-spacing: .01em; text-transform: uppercase; margin-top: 12px; max-width: 620px; }
.auth-mid p { color: #c4c6e4; max-width: 470px; font-size: 13px; margin-top: 16px; }
.auth-foot { font-size: 10px; color: #9fa1c7; line-height: 1.6; border-top: 1px solid rgba(255,255,255,.18); padding-top: 14px; display: flex; justify-content: space-between; gap: 20px; }
.auth-foot strong { color: #fff; font-weight: 600; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 26px; background: var(--paper); }
.auth-card { width: min(380px, 100%); }
.auth-card .rule { width: 52px; height: 3px; background: var(--copper); margin-bottom: 18px; }
.auth-card h2 { font-family: var(--display); font-size: 34px; text-transform: uppercase; letter-spacing: .04em; line-height: 1; }
.auth-card .lead { color: var(--muted); font-size: 12px; margin: 7px 0 22px; }
.auth-card .field { margin-bottom: 13px; }
.auth-card .btn { margin-top: 6px; }
.auth-note { font-size: 10px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 22px; padding-top: 12px; line-height: 1.5; }
.auth-card .notice { margin: 0 0 14px; }

/* ---------- misc ---------- */
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.action-card { border: 1px solid var(--line); background: var(--paper-2); padding: 11px; display: block; text-decoration: none; color: var(--ink); }
.action-card:hover { border-color: var(--blue); background: #f1f8fc; text-decoration: none; }
.action-card strong { display: block; font-family: var(--display); font-size: 17px; text-transform: uppercase; letter-spacing: .05em; line-height: 1.1; }
.action-card span { font-size: 10.5px; color: var(--muted); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 22px 0 10px; }
.section-head h2 { font-family: var(--display); font-size: 23px; line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
.section-head .meta { font-family: var(--mono); font-size: 9px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, .75fr); gap: 16px; align-items: start; }
.sticky-side { position: sticky; top: 16px; }
.stat-strip { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); background: var(--paper-2); }
.stat-strip .item { padding: 9px 14px; border-right: 1px solid var(--line); min-width: 110px; }
.stat-strip .item:last-child { border-right: 0; }
.stat-strip .n { font-family: var(--display); font-size: 24px; line-height: 1; font-weight: 700; }
.stat-strip .l { font-size: 8.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 2px; }
.meta-inline { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 10px; color: var(--muted); }
.meta-inline .mono { font-size: 9.5px; }
.doc-links { display: flex; flex-wrap: wrap; gap: 6px; }
.file-input { padding: 7px; background: #fffdf9; border: 1px dashed var(--line-strong); width: 100%; font-size: 11px; }
.photo-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.photo-form .field:first-child { grid-column: 1 / -1; }
.photo-form .btn { justify-self: start; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-3 { grid-column: span 2; }
  .scan-layout { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { padding: 15px 16px 13px; gap: 10px; }
  .crumb h1 { font-size: 25px; }
  .crumb p { display: none; }
  .top-actions { gap: 7px; }
  .user-chip { border-left: 0; padding-left: 0; }
  .user-meta { display: none; }
  .btn-scan { padding: 7px 9px; }
  .logout-form { display: none; }
  .content { padding: 15px 14px 86px; }
  .notice { margin: 0; }
  .pagefoot { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi-value { font-size: 32px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-4 { gap: 1px; }
  .hero { padding: 17px; }
  .hero-top { flex-direction: column; gap: 14px; }
  .hero-side { border-left: 0; border-top: 1px solid rgba(255,255,255,.2); padding-left: 0; padding-top: 10px; width: 100%; }
  .form-grid, .form-grid.cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .photo-form { grid-template-columns: 1fr; }
  .table-wrap { border: 1px solid var(--line); background: #fffdf9; }
  .ledger { min-width: 760px; }
  .label-sheet { grid-template-columns: repeat(2, 62mm); padding: 4mm; }
  .bottomnav { display: grid; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 270px; padding: 24px; }
  .auth-mid { margin: 30px 0; }
  .auth-mid h1 { font-size: 44px; }
  .auth-mid p { display: none; }
  .auth-foot { display: none; }
  .auth-panel { padding: 30px 20px 50px; }
  .auth-card { width: 100%; }
  .print-toolbar { position: sticky; top: 0; z-index: 5; }
  .doc { width: 100%; min-height: 0; margin: 0; padding: 18px 14px; border: 0; }
  .doc-title { flex-direction: column; align-items: flex-start; gap: 6px; }
  .doc-meta { grid-template-columns: 1fr; }
  .doc-letterhead { flex-direction: column; }
  .doc-company { text-align: left; max-width: none; }
  .label-sheet { width: 100%; max-width: 100%; grid-template-columns: 1fr; justify-items: center; overflow-x: auto; }
}
@media (max-width: 520px) {
  .top-actions .btn-scan span { display: none; }
  .label-sheet { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar .input, .filter-bar select, .filter-bar .btn { width: 100%; }
}

/* ---------- bottom nav ---------- */
.bottomnav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  grid-template-columns: repeat(5, 1fr);
  background: var(--blue-deep);
  border-top: 1px solid #171840;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 7px; color: #b9bad9; text-decoration: none;
  font-size: 8px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  border-top: 2px solid transparent;
}
.bottomnav a.active { color: #fff; border-top-color: var(--cyan); background: rgba(0,174,237,.1); }
.bottomnav .ico { width: 18px; height: 18px; display: block; }
.ico { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff !important; font-size: 9.5pt; }
  .rail, .topbar, .bottomnav, .pagefoot, .notice, .no-print, .print-toolbar, .content > .panel:not(.print-keep) { display: none !important; }
  .shell { display: block; }
  .main { display: block; }
  .content { padding: 0; }
  .doc { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; }
  .doc + .doc { page-break-before: always; margin: 0; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  .label-sheet { border: 0; padding: 0; gap: 2mm; grid-template-columns: repeat(3, 62mm); width: auto; }
  .label-card { break-inside: avoid; page-break-inside: avoid; }
  .print-only { display: block !important; }
  .no-print { display: none !important; }
  a { color: inherit; text-decoration: none; }
}
.print-only { display: none; }

/* ---------- RAB item builder ---------- */
.rab-item { border: 1px solid var(--line); background: var(--paper-2); margin-bottom: 10px; }
.rab-item-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.rab-item-no { font-family: var(--mono); font-size: 9px; color: var(--copper); border: 1px solid var(--line-strong); padding: 2px 5px; }
.rab-item-title { font-family: var(--display); font-size: 15px; text-transform: uppercase; letter-spacing: .06em; flex: 1; }
.rab-item-body { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px 12px; padding: 12px; }
.rab-item-body .col-2 { grid-column: span 2; }
.rab-item-body .col-4 { grid-column: 1 / -1; }
.rab-addons { border-top: 1px dashed var(--line); padding: 10px 12px; background: #fdfbf7; }
.addon-row { display: grid; grid-template-columns: 1.7fr .6fr .7fr 1fr 1.4fr auto; gap: 7px; align-items: end; margin-bottom: 7px; }
.addon-row .field > label { font-size: 8px; }
.rab-summary { display: grid; grid-template-columns: 1fr auto; gap: 5px 22px; font-size: 12.5px; }
.rab-summary .k { color: var(--muted); text-align: right; }
.rab-summary .v { text-align: right; font-variant-numeric: tabular-nums; min-width: 110px; }
.rab-summary .grand { font-family: var(--display); font-size: 23px; font-weight: 700; border-top: 1px solid var(--line-strong); padding-top: 6px; margin-top: 4px; }
@media (max-width: 900px) {
  .rab-item-body { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .rab-item-body .col-2 { grid-column: span 2; }
  .addon-row { grid-template-columns: 1fr 1fr; }
  .addon-row .field:first-child { grid-column: 1 / -1; }
}

/* ---------- master records ---------- */
.record { border: 1px solid var(--line); background: var(--paper-2); padding: 10px 12px; margin-bottom: 8px; }
.record-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.record-title { font-family: var(--display); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.record-code { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.record-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 8px; align-items: end; }
.record-grid .w2 { grid-column: span 2; }
.record-grid .w3 { grid-column: span 3; }
.record-actions { display: flex; align-items: end; gap: 6px; }
.record-sub { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: end; }
.record-sub .field { flex: 1; min-width: 150px; }
@media (max-width: 900px) {
  .record-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .record-grid .w2, .record-grid .w3 { grid-column: span 2; }
}


/* ---------- final responsive overrides ---------- */
@media (max-width: 900px) {
  .bottomnav { display: grid; }
}
@media (max-width: 520px) {
  .rab-item-body { grid-template-columns: 1fr; }
  .rab-item-body .col-2, .rab-item-body .col-4 { grid-column: auto; }
  .addon-row { grid-template-columns: 1fr 1fr; }
  .addon-row .field:first-child { grid-column: 1 / -1; }
  .top-actions { gap: 6px; }
}
