:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F7F7F8;
  --surface-3: #F1F1F3;
  --border: #E8E8EA;
  --border-2: #DCDCE0;
  --border-3: #C9C9CF;

  --ink: #09090B;
  --ink-2: #3F3F46;
  --ink-3: #52525B;
  --muted: #71717A;
  --muted-2: #A1A1AA;

  --red: #B42318;
  --red-hi: #C4342A;
  --red-lo: #912018;
  --red-deep: #7A271A;
  --red-wash: #FEF3F2;
  --red-edge: #FDCDC7;

  --green: #067647;
  --green-wash: #ECFDF3;
  --green-edge: #ABEFC6;
  --amber: #B54708;
  --amber-wash: #FFFAEB;

  --s1: #EAAA08; --s2: #E0930A; --s3: #D67C0C; --s4: #CC650E; --s5: #C24E10;
  --s6: #B83D14; --s7: #AE2E18; --s8: #99231A; --s9: #7F1D1A; --s10: #611712;

  --l1: var(--s1); --l2: var(--s2); --l3: var(--s3); --l4: var(--s4); --l5: var(--s5);
  --l6: var(--s6); --l7: var(--s7); --l8: var(--s8); --l9: var(--s9); --l10: var(--s10);

  --brand: var(--red);
  --brand-dk: var(--red-lo);
  --brand-lt: var(--red-hi);
  --brand-pale: var(--red-wash);
  --brand-edge: var(--red-edge);
  --accent: var(--red);
  --accent-deep: var(--red-deep);
  --accent-wash: var(--red-wash);
  --paper: var(--bg);
  --w0: var(--surface); --w1: var(--surface-2); --w2: var(--surface-2);
  --w3: var(--surface-3); --w4: var(--border); --w5: var(--border-2); --w6: var(--border-3);
  --ink2: var(--ink-2); --ink3: var(--ink-3); --muted2: var(--muted-2);
  --rule: var(--border); --rule-soft: var(--border);
  --ok: var(--green); --ok-pale: var(--green-wash); --warn: var(--amber);

  --f-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-serif: var(--f-sans);

  --sh-xs: 0 1px 2px rgba(16,24,40,.04);
  --sh-sm: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --sh-md: 0 4px 8px -2px rgba(16,24,40,.08), 0 2px 4px -2px rgba(16,24,40,.04);
  --sh-lg: 0 12px 16px -4px rgba(16,24,40,.08), 0 4px 6px -2px rgba(16,24,40,.03);
  --sh-xl: 0 24px 48px -12px rgba(16,24,40,.18);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
  --r-full: 999px;

  --shell: 1480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -.02em; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: var(--r-sm); }

/* ================= top bar ================= */

.masthead { background: var(--surface); border-bottom: 1px solid var(--border); }
.masthead-in {
  max-width: var(--shell); margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}

.mh-mark {
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-sm);
  background: linear-gradient(145deg, var(--red-hi), var(--red-lo));
  color: #fff; display: grid; place-content: center;
  font-family: var(--f-sans); font-weight: 800; font-size: 11px;
  line-height: 1.05; text-align: center; letter-spacing: -.02em;
  box-shadow: var(--sh-sm);
}

.mh-titles { min-width: 0; line-height: 1.2; }
.mh-org {
  display: block; font-weight: 800; font-size: 17px;
  letter-spacing: -.032em; color: var(--ink);
}
.mh-org:hover { text-decoration: none; }
.mh-sub {
  display: block; font-size: 11.5px; font-weight: 500;
  color: var(--muted); letter-spacing: -.005em; margin-top: 1px;
}

.mh-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); }
.mh-right b { color: var(--ink-2); font-weight: 600; }
.mh-right a { color: var(--muted); }
.mh-right a:hover { color: var(--ink); }
.mh-right .row2 { display: flex; gap: 10px; }

/* ================= nav ================= */

.tabstrip { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.tabstrip-in {
  max-width: var(--shell); margin: 0 auto; padding: 0 28px 10px;
  display: flex; align-items: center; gap: 4px;
}

.tab {
  display: block; padding: 7px 13px;
  font-size: 13.5px; font-weight: 600; letter-spacing: -.012em;
  color: var(--muted); border-radius: var(--r-sm); white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.tab:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tab.is-on { background: var(--red-wash); color: var(--red-deep); }

.statusbar { background: var(--bg); }
.statusbar-in {
  max-width: var(--shell); margin: 0 auto; padding: 12px 28px 0;
  display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted);
}
.sb-sep { color: var(--border-2); }

.syncpill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 4px 11px 4px 9px; background: var(--surface);
  cursor: pointer; box-shadow: var(--sh-xs); transition: box-shadow .12s ease;
}
.syncpill:hover { box-shadow: var(--sh-sm); }
.syncpill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; box-shadow: 0 0 0 3px var(--green-wash); }
.syncpill.is-stale .dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.syncpill.is-error .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-wash); }
.syncpill.is-busy .dot { background: var(--red); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.wrap { max-width: var(--shell); margin: 0 auto; padding: 20px 28px 56px; }

/* ================= surfaces ================= */

.panel, .card, .hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-xs);
}
.panel { overflow: hidden; }

.card { padding: 18px 20px; }
.card > h3 {
  margin: 0 0 14px; font-size: 12.5px; font-weight: 600;
  letter-spacing: -.01em; color: var(--muted);
}
.card .big {
  font-family: var(--f-sans); font-size: 30px; font-weight: 700;
  letter-spacing: -.035em; color: var(--ink); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.card .cap { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* ================= hero ================= */

.hero { padding: 0; margin-bottom: 18px; overflow: hidden; }
.hero-head { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); }

.hero-fig {
  display: flex; flex-direction: column; gap: 3px;
  padding: 18px 24px 20px; flex: 1; min-width: 190px;
  border-right: 1px solid var(--border);
}
.hero-fig:last-child { border-right: 0; }
.hero-fig .k { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: -.01em; }
.hero-fig .v {
  font-size: 30px; font-weight: 700; letter-spacing: -.038em;
  line-height: 1.12; color: var(--ink); font-variant-numeric: tabular-nums;
}
.hero-fig .v.sm { font-size: 24px; }
.hero-fig .v.accent { color: var(--red); }
.hero-fig .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.delta.up { color: var(--red); }
.delta.down { color: var(--green); }
.delta.flat { color: var(--muted); }

.chartwrap { padding: 18px 20px 8px; }
.chartwrap .ctitle {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px; gap: 12px; flex-wrap: wrap;
}
.chartwrap .ctitle h4 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); letter-spacing: -.015em; }
.chartwrap .ctitle .cnote { font-size: 12px; color: var(--muted); }

.spine { width: 100%; height: auto; display: block; }
.spine-legend {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--muted-2); padding: 2px 20px 14px;
  font-variant-numeric: tabular-nums;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ================= toolbar ================= */

.toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); font: 600 12.5px/1 var(--f-sans); letter-spacing: -.012em;
  padding: 8px 13px; border-radius: var(--r-pill); cursor: pointer;
  box-shadow: var(--sh-xs); transition: all .12s ease;
}
.chip:hover { border-color: var(--border-3); text-decoration: none; color: var(--ink); box-shadow: var(--sh-sm); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .55; margin-left: 6px; font-weight: 500; }

.search {
  margin-left: auto; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--r-sm); padding: 8px 13px;
  font: 400 13px/1.3 var(--f-sans); color: var(--ink); width: 270px;
  box-shadow: var(--sh-xs); transition: border-color .12s ease, box-shadow .12s ease;
}
.search::placeholder { color: var(--muted-2); }
.search:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash); }

/* ================= table ================= */

table.ar { width: 100%; border-collapse: collapse; }

table.ar thead th {
  text-align: left; font-size: 11.5px; font-weight: 600;
  letter-spacing: -.005em; color: var(--muted);
  padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.ar thead th.r { text-align: right; }

table.ar tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s ease;
}
table.ar tbody tr:hover { background: var(--surface-2); }
table.ar tbody tr.is-open { background: var(--red-wash); box-shadow: inset 3px 0 0 var(--red); }
table.ar tbody tr:last-child { border-bottom: 0; }

table.ar td { padding: 13px 16px; vertical-align: middle; }
table.ar td.r { text-align: right; }

.cust { font-weight: 600; color: var(--ink); font-size: 13.5px; letter-spacing: -.015em; }
.cust .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; letter-spacing: 0; }

.jobno {
  font-family: var(--f-mono); font-size: 13px; font-weight: 500;
  color: var(--ink); white-space: nowrap; letter-spacing: -.03em;
}
.jobno .nojob { color: var(--muted-2); font-weight: 400; font-size: 11.5px; font-family: var(--f-sans); }

.docno { font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); letter-spacing: -.03em; }
.datecell { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bal { font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.partpaid { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; font-weight: 400; }

.agecell { display: flex; align-items: center; gap: 11px; min-width: 155px; }
.agebar { width: 60px; height: 5px; background: var(--surface-3); border-radius: var(--r-pill); position: relative; flex: none; overflow: hidden; }
.agebar i { position: absolute; left: 0; top: 0; bottom: 0; display: block; border-radius: var(--r-pill); }
.agetxt { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.agetxt.pre { color: var(--muted-2); }

.lvl { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.lvl b { font-weight: 600; font-variant-numeric: tabular-nums; }
.lvl .tick { width: 8px; height: 8px; border-radius: 50%; flex: none; display: block; }
.lvl .lbl { font-size: 12.5px; color: var(--muted); }

.tag {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  letter-spacing: -.005em; padding: 2px 8px; border-radius: var(--r-pill);
  margin-left: 7px; white-space: nowrap; vertical-align: 1px;
}
.tag-hold { background: var(--surface-3); color: var(--ink-2); }
.tag-promise { background: var(--green-wash); color: var(--green); }
.tag-broke { background: var(--red-wash); color: var(--red-deep); }

.gatehint { font-size: 12px; color: var(--muted-2); white-space: nowrap; }

/* ================= buttons ================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--ink); font: 600 13px/1 var(--f-sans); letter-spacing: -.012em;
  padding: 9px 14px; border-radius: var(--r-sm); cursor: pointer;
  white-space: nowrap; text-decoration: none;
  box-shadow: var(--sh-xs); transition: all .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-3); text-decoration: none; color: var(--ink); box-shadow: var(--sh-sm); }
.btn:active { transform: translateY(.5px); box-shadow: none; }
.btn:disabled, .btn.is-off { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-lo); border-color: var(--red-lo); color: #fff; }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ================= drawer ================= */

.scrim {
  position: fixed; inset: 0; background: rgba(9,9,11,.42);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease; z-index: 60;
}
.scrim.is-on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(600px, 100vw); background: var(--bg);
  box-shadow: var(--sh-xl);
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.32,.72,0,1);
  z-index: 61; display: flex; flex-direction: column;
}
.drawer.is-on { transform: translateX(0); }

.drawer-head { padding: 20px 24px 18px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.drawer-body { padding: 18px 24px 48px; overflow-y: auto; flex: 1; }

.drawer-close {
  position: absolute; top: 16px; right: 18px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; transition: all .12s ease;
}
.drawer-close:hover { background: var(--surface-2); border-color: var(--border); color: var(--ink); }

.drawer h2 { font-size: 20px; font-weight: 700; margin: 0 0 3px; padding-right: 36px; color: var(--ink); letter-spacing: -.03em; }
.drawer .who { font-size: 13px; color: var(--muted); }

.stat-row {
  display: flex; margin-top: 16px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: var(--r-sm); overflow: hidden;
}
.stat { display: flex; flex-direction: column; gap: 2px; padding: 11px 15px; flex: 1; min-width: 96px; }
.stat + .stat { box-shadow: inset 1px 0 0 var(--border); }
.stat .k { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -.028em; font-variant-numeric: tabular-nums; }

.sect { margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh-xs); }
.sect > h3 {
  font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0;
  padding: 12px 16px 10px; letter-spacing: -.01em;
}
.sect > *:not(h3) { margin-left: 16px; margin-right: 16px; }
.sect > *:last-child { margin-bottom: 15px; }

.minirow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.minirow:last-child { border-bottom: 0; }
.minirow .grow { flex: 1; min-width: 0; }
.minirow .t { font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: -.015em; }
.minirow .s { font-size: 12px; color: var(--muted); font-weight: 400; }

.compose { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.compose .subj { padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.compose .subj span { color: var(--muted); font-weight: 500; margin-right: 8px; font-size: 12px; }
.compose textarea {
  width: 100%; border: 0; padding: 14px;
  font: 400 12.5px/1.65 var(--f-mono); letter-spacing: -.015em;
  color: var(--ink-2); resize: vertical; min-height: 230px; background: var(--surface); display: block;
}
.compose textarea:focus { outline: none; }
.compose-foot { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.compose-foot .len { font-size: 11.5px; color: var(--muted-2); margin-right: auto; font-variant-numeric: tabular-nums; }
.compose-foot .len.warn { color: var(--red); font-weight: 600; }

.notice {
  padding: 11px 14px; border-radius: var(--r-sm); font-size: 12.5px;
  background: var(--surface-2); color: var(--ink-2); margin-bottom: 12px;
  border: 1px solid var(--border);
}
.notice.warn { background: var(--red-wash); border-color: var(--red-edge); color: var(--red-deep); }

.script { counter-reset: s; margin: 0; padding: 0; }
.script li {
  counter-increment: s; list-style: none; position: relative;
  padding: 9px 0 9px 30px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.script li:last-child { border-bottom: 0; }
.script li::before {
  content: counter(s); position: absolute; left: 0; top: 9px;
  font-size: 10.5px; font-weight: 700; color: var(--red); background: var(--red-wash);
  width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%;
}

.tl { display: flex; flex-direction: column; }
.tl-row { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tl-row:last-child { border-bottom: 0; }
.tl-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--border-3); }
.tl-row.k-contact .dot { background: var(--red); }
.tl-row.k-note .dot { background: var(--muted-2); }
.tl-row.k-promise .dot { background: var(--green); }
.tl-row.k-flag .dot { background: var(--ink-2); }
.tl-row .grow { flex: 1; min-width: 0; }
.tl-row .t { font-size: 13px; font-weight: 600; letter-spacing: -.015em; }
.tl-row .s { font-size: 11.5px; color: var(--muted); }
.tl-row .b { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; white-space: pre-wrap; }

.rowform { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.rowform textarea, .rowform input, .rowform select,
.inline-fields input, .inline-fields select {
  border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 8px 11px;
  font: 400 13px/1.5 var(--f-sans); background: var(--surface); color: var(--ink); width: 100%;
}
.rowform textarea { resize: vertical; min-height: 62px; }
.rowform textarea:focus, .rowform input:focus, .inline-fields input:focus {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash);
}
.inline-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.inline-fields > * { flex: 1; min-width: 124px; }

/* ================= grids and charts ================= */

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }

.barlist { display: flex; flex-direction: column; gap: 12px; }
.barrow { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; align-items: baseline; }
.barrow .lab { font-size: 13px; color: var(--ink-2); letter-spacing: -.01em; }
.barrow .val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.barrow .track { grid-column: 1 / -1; height: 7px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.barrow .track i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--red); }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 0 0 9px; border-bottom: 1px solid var(--border);
}
table.mini th.r, table.mini td.r { text-align: right; }
table.mini td { padding: 10px 0; border-bottom: 1px solid var(--border); }
table.mini tr:last-child td { border-bottom: 0; }

.empty { padding: 64px 24px; text-align: center; color: var(--muted); }
.empty h3 { font-size: 17px; color: var(--ink); margin: 0 0 7px; font-weight: 700; letter-spacing: -.025em; }
.empty p { margin: 0 0 18px; font-size: 13px; }

/* ================= forms and pages ================= */

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; font-weight: 800; margin: 0 0 4px; color: var(--ink); letter-spacing: -.04em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; letter-spacing: -.01em; }
.field input[type=text], .field input[type=password], .field input[type=email],
.field input[type=number], .field input[type=date], .field input[type=search],
.field select, .field textarea, .field input:not([type]) {
  width: 100%; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 9px 12px; font: 400 13.5px/1.4 var(--f-sans);
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs);
}
.field textarea { font-family: var(--f-mono); font-size: 12.5px; line-height: 1.65; resize: vertical; letter-spacing: -.015em; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash);
}
.field input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.flash { padding: 12px 15px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 18px; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--green-wash); border-color: var(--green-edge); color: var(--green); }
.flash.err { background: var(--red-wash); border-color: var(--red-edge); color: var(--red-deep); }

.badge {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill);
  color: var(--muted); background: var(--surface-3);
}
.badge.admin { background: var(--red-wash); color: var(--red-deep); }
.badge.off { text-decoration: line-through; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card {
  width: 100%; max-width: 396px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 0; box-shadow: var(--sh-lg); overflow: hidden;
}
.login-card .lc-head { padding: 30px 32px 22px; text-align: center; }
.login-card .lc-body { padding: 0 32px 30px; }
.login-card .lc-org { font-weight: 800; font-size: 21px; letter-spacing: -.038em; color: var(--ink); display: block; }
.login-card .lede { font-size: 13px; color: var(--muted); margin: 5px 0 0; }

.tmpl-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 16px; }
.tmpl-tabs a {
  font-size: 12.5px; font-weight: 600; padding: 7px 13px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  color: var(--ink-2); background: var(--surface); box-shadow: var(--sh-xs);
}
.tmpl-tabs a:hover { border-color: var(--border-3); text-decoration: none; }
.tmpl-tabs a.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

.subnav { display: flex; gap: 4px; margin-bottom: 22px; flex-wrap: wrap; }
.subnav a {
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-radius: var(--r-sm); letter-spacing: -.012em;
}
.subnav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.subnav a.is-on { color: var(--red-deep); background: var(--red-wash); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-size: 13px; color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.appfoot {
  max-width: var(--shell); margin: 32px auto 0; padding: 18px 28px 36px;
  font-size: 12px; color: var(--muted-2); border-top: 1px solid var(--border);
  display: flex; gap: 18px; flex-wrap: wrap;
}
.appfoot a { color: var(--muted); }

/* ================= responsive ================= */

@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .wrap { padding: 14px 14px 40px; }
  .masthead-in { padding: 12px 14px; }
  .mh-org { font-size: 15px; }
  .mh-sub { font-size: 11px; }
  .mh-right { width: 100%; margin-left: 0; justify-content: space-between; }
  .tabstrip-in { padding: 0 14px 10px; overflow-x: auto; }
  .statusbar-in { padding: 12px 14px 0; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .hero-fig { min-width: 50%; border-bottom: 1px solid var(--border); }
  .search { width: 100%; margin-left: 0; }
  table.ar .hide-sm { display: none; }
  table.ar td, table.ar thead th { padding: 11px 10px; }
  .agebar { display: none; }
  .agecell { min-width: 0; }
  .drawer { width: 100vw; }
  .stat-row { flex-direction: column; }
  .stat + .stat { box-shadow: inset 0 1px 0 var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .masthead, .tabstrip, .statusbar, .toolbar, .drawer, .scrim, .btn, .appfoot { display: none !important; }
  .panel, .card, .hero { border-color: #999; box-shadow: none; }
}
