/* ============================================================
   TOKE FOLKS BACKOFFICE — "The Ledger"
   Editorial-industrial working software. Paper field, ink chrome,
   oxide accent, mono numerals. Sibling of the Downtown Press site.
   ============================================================ */

:root {
  --paper: #EFEBE1;
  --paper-deep: #E6E1D3;
  --card: #F8F5EE;
  --ink: #171512;
  --ink-soft: #3A372F;
  --ink-mute: #7A7466;
  --hairline: #D9D2C2;
  --hairline-dark: #C4BCA8;
  --oxide: #A8462F;
  --oxide-deep: #8A3722;
  --oxide-wash: #F0DDD5;
  --moss: #4F594B;
  --moss-wash: #DFE4DC;
  --amber: #B98A1E;
  --amber-wash: #F2E7CB;
  --steel: #62666A;
  --steel-wash: #E2E2DE;
  --display: "Archivo", -apple-system, sans-serif;
  --body: "Archivo", -apple-system, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --shadow-card: 0 1px 2px rgba(23, 21, 18, 0.05), 0 4px 16px rgba(23, 21, 18, 0.04);
  --shadow-pop: 0 2px 6px rgba(23, 21, 18, 0.12), 0 16px 40px rgba(23, 21, 18, 0.14);
  --rail: 232px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Paper grain atmosphere */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
::selection { background: var(--oxide); color: var(--paper); }

/* ============ APP SHELL ============ */
/* NOTE: no z-index here — it would trap the rail's mobile z-index inside a
   stacking context, putting the open nav drawer under its own scrim. */
.shell { display: flex; min-height: 100vh; position: relative; }

.rail {
  width: var(--rail); flex-shrink: 0;
  background: var(--ink);
  color: var(--paper);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.rail::-webkit-scrollbar { width: 0; }

.rail-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(239, 235, 225, 0.12);
}
.rail-brand .wordmark {
  font-family: var(--display);
  font-weight: 900; font-stretch: 125%;
  font-size: 1.18rem; letter-spacing: 0.01em;
  text-transform: uppercase; line-height: 1;
}
.rail-brand .wordmark em { font-style: normal; color: var(--oxide); }
.rail-brand .sub {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: rgba(239, 235, 225, 0.45); margin-top: 7px;
}

.rail-group { padding: 14px 0 4px; }
.rail-group + .rail-group { border-top: 1px solid rgba(239, 235, 225, 0.08); }
.rail-group .glabel {
  font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: rgba(239, 235, 225, 0.35);
  padding: 4px 20px 6px;
}
.rail a.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px 7px 17px;
  color: rgba(239, 235, 225, 0.72);
  text-decoration: none; font-size: 0.86rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.12s, background 0.12s;
}
.rail a.nav:hover { color: var(--paper); background: rgba(239, 235, 225, 0.05); }
.rail a.nav.on {
  color: var(--paper); border-left-color: var(--oxide);
  background: linear-gradient(90deg, rgba(168, 70, 47, 0.22), transparent 70%);
}
.rail a.nav .ic { width: 17px; height: 17px; opacity: 0.85; flex-shrink: 0; }
.rail a.nav .badge {
  margin-left: auto; font-family: var(--mono); font-size: 0.62rem;
  background: var(--oxide); color: var(--paper); border-radius: 99px;
  padding: 1px 7px; line-height: 1.5;
}

.rail-foot {
  margin-top: auto; padding: 14px 20px 18px;
  border-top: 1px solid rgba(239, 235, 225, 0.1);
  font-size: 0.78rem;
}
.rail-foot .who { font-weight: 600; }
.rail-foot .role {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--oxide);
  border: 1px solid rgba(168, 70, 47, 0.55); border-radius: 3px;
  display: inline-block; padding: 2px 6px; margin-top: 5px;
}
.rail-foot a { color: rgba(239, 235, 225, 0.5); text-decoration: none; font-size: 0.72rem; }
.rail-foot a:hover { color: var(--paper); }

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; padding: 0 clamp(20px, 4vw, 48px) 80px; }

.topline {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 0; font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-mute);
}
.topline .demo-flag {
  color: var(--oxide); border: 1px dashed var(--oxide); border-radius: 3px;
  padding: 3px 8px; letter-spacing: 0.16em;
}

.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 30px 0 20px; border-bottom: 2px solid var(--ink);
  margin-bottom: 26px; flex-wrap: wrap;
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.pagehead .kicker {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--oxide); margin-bottom: 8px;
}
.pagehead h1 {
  font-family: var(--display); font-weight: 800; font-stretch: 118%;
  font-size: clamp(1.7rem, 3.2vw, 2.4rem); line-height: 1.02;
  text-transform: uppercase; letter-spacing: 0.005em;
}
.pagehead .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* stagger children on load */
.stagger > * { animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.07s; }
.stagger > *:nth-child(3) { animation-delay: 0.11s; }
.stagger > *:nth-child(4) { animation-delay: 0.15s; }
.stagger > *:nth-child(5) { animation-delay: 0.19s; }
.stagger > *:nth-child(6) { animation-delay: 0.23s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ STAT CARDS ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--card); border: 1px solid var(--hairline);
  border-top: 3px solid var(--ink); border-radius: 6px;
  padding: 14px 16px 13px; box-shadow: var(--shadow-card);
}
.stat.oxide { border-top-color: var(--oxide); }
.stat.moss { border-top-color: var(--moss); }
.stat.amber { border-top-color: var(--amber); }
.stat .l {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-mute);
}
.stat .v {
  font-family: var(--mono); font-weight: 700; font-size: 1.55rem;
  letter-spacing: -0.02em; margin-top: 6px; line-height: 1;
}
.stat .d { font-size: 0.72rem; color: var(--ink-mute); margin-top: 6px; }
.stat .v .up { color: var(--moss); } .stat .v .down { color: var(--oxide); }

/* ============ CARDS / PANELS ============ */
.card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 6px;
  box-shadow: var(--shadow-card); margin-bottom: 22px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid var(--hairline);
}
.card-head h2 {
  font-family: var(--display); font-weight: 700; font-stretch: 112%;
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em;
}
.card-head .hint { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-mute); letter-spacing: 0.1em; }
/* overflow-x:auto at every width: a table wider than its (possibly narrow
   grid) column scrolls inside the card instead of being clipped by the
   card's overflow:hidden. Without this, wide tables only showed in full at
   very large window sizes. */
.card-body { padding: 18px; overflow-x: auto; }
.card-body.flush { padding: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid31 { display: grid; grid-template-columns: 2.2fr 1fr; gap: 22px; align-items: start; }
/* Grid items default to min-width:auto — a wide table would blow the column
   past the viewport instead of scrolling inside its card. */
.grid2 > *, .grid31 > * { min-width: 0; }
@media (max-width: 1080px) { .grid2, .grid31 { grid-template-columns: 1fr; } }

/* ============ TABLES ============ */
table.ledger { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ledger thead th {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-mute); font-weight: 400;
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--hairline-dark);
  background: linear-gradient(var(--card), var(--paper-deep) 400%);
  white-space: nowrap;
}
.ledger tbody td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.ledger tbody tr { transition: background 0.1s; }
.ledger tbody tr:hover { background: rgba(23, 21, 18, 0.025); }
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger .num { font-family: var(--mono); font-size: 0.8rem; text-align: right; white-space: nowrap; }
.ledger th.num { text-align: right; }
.ledger a.rowlink { font-weight: 600; text-decoration: none; }
.ledger a.rowlink:hover { color: var(--oxide-deep); text-decoration: underline; text-underline-offset: 3px; }
.ledger .sub { font-size: 0.72rem; color: var(--ink-mute); margin-top: 1px; }
tr.clickable { cursor: pointer; }
/* Multi-control action cells (e.g. role select + reset + deactivate) wrap onto
   as many rows as the column allows rather than forcing the table wide. */
.rowacts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rowacts form { display: inline-flex; margin: 0; }

.empty {
  padding: 34px 20px; text-align: center; color: var(--ink-mute); font-size: 0.85rem;
}
.empty .big { font-family: var(--display); font-weight: 800; font-stretch: 118%; text-transform: uppercase; font-size: 1.05rem; color: var(--ink-soft); margin-bottom: 6px; }

/* ============ CHIPS (letterpress status) ============ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em;
  text-transform: uppercase; border-radius: 3px; padding: 3px 8px;
  border: 1px solid; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.moss { color: var(--moss); background: var(--moss-wash); border-color: color-mix(in srgb, var(--moss) 40%, transparent); }
.chip.oxide { color: var(--oxide-deep); background: var(--oxide-wash); border-color: color-mix(in srgb, var(--oxide) 40%, transparent); }
.chip.amber { color: #8a6716; background: var(--amber-wash); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.chip.steel { color: var(--steel); background: var(--steel-wash); border-color: color-mix(in srgb, var(--steel) 40%, transparent); }
.chip.ink { color: var(--ink-soft); background: var(--paper-deep); border-color: var(--hairline-dark); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--display); font-weight: 700; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 9px 16px; border-radius: 4px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  transition: transform 0.08s, box-shadow 0.12s, background 0.12s;
}
.btn:hover { background: var(--ink-soft); box-shadow: 0 3px 10px rgba(23, 21, 18, 0.25); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.oxide { background: var(--oxide); border-color: var(--oxide); }
.btn.oxide:hover { background: var(--oxide-deep); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper-deep); box-shadow: none; }
.btn.sm { padding: 5px 11px; font-size: 0.68rem; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--oxide); outline-offset: 2px;
}

/* ============ FORMS ============ */
.field { margin-bottom: 15px; }
.field label {
  display: block; font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--body); font-size: 0.9rem;
  padding: 9px 12px; border: 1px solid var(--hairline-dark); border-radius: 4px;
  background: #FDFCF8; color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .note { font-size: 0.72rem; color: var(--ink-mute); margin-top: 5px; }
.formrow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.formrow3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .formrow, .formrow3 { grid-template-columns: 1fr; } }

/* ============ HELP DRAWER (field manual) ============ */
.help-toggle {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-soft);
  border: 1px solid var(--hairline-dark); background: var(--card);
  border-radius: 99px; padding: 7px 14px; cursor: pointer;
  display: inline-flex; gap: 7px; align-items: center;
  transition: border-color 0.12s, color 0.12s;
}
.help-toggle:hover { border-color: var(--oxide); color: var(--oxide-deep); }
.help-toggle .qm {
  width: 15px; height: 15px; border-radius: 50%; background: var(--oxide); color: var(--paper);
  font-weight: 700; display: grid; place-items: center; font-size: 0.62rem;
}
.help-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 92vw); z-index: 60;
  background: var(--card); border-left: 2px solid var(--ink);
  box-shadow: var(--shadow-pop);
  transform: translateX(103%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.25, 1);
  overflow-y: auto;
}
.help-drawer.open { transform: none; }
.help-drawer .hd-head {
  position: sticky; top: 0; background: var(--ink); color: var(--paper);
  padding: 16px 22px; display: flex; justify-content: space-between; align-items: center;
}
.help-drawer .hd-head .t { font-family: var(--display); font-weight: 800; font-stretch: 118%; text-transform: uppercase; font-size: 0.95rem; }
.help-drawer .hd-head .m { font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.22em; color: rgba(239,235,225,0.5); text-transform: uppercase; margin-top: 3px; }
.help-drawer .hd-close { background: none; border: 1px solid rgba(239,235,225,0.3); color: var(--paper); border-radius: 4px; width: 28px; height: 28px; cursor: pointer; font-size: 0.9rem; }
.help-drawer .hd-body { padding: 20px 22px 40px; font-size: 0.87rem; line-height: 1.55; }
.help-drawer .hd-body p { margin-bottom: 12px; }
.help-drawer ol.steps { list-style: none; counter-reset: st; margin: 14px 0; }
.help-drawer ol.steps li {
  counter-increment: st; position: relative; padding: 0 0 14px 38px;
  border-left: 1px solid var(--hairline-dark); margin-left: 12px;
}
.help-drawer ol.steps li:last-child { border-left-color: transparent; }
.help-drawer ol.steps li::before {
  content: counter(st, decimal-leading-zero);
  position: absolute; left: -13px; top: -2px;
  font-family: var(--mono); font-size: 0.6rem; font-weight: 700;
  background: var(--ink); color: var(--paper); border-radius: 3px; padding: 3px 4px;
}
.risk {
  border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent);
  background: repeating-linear-gradient(-45deg, var(--amber-wash), var(--amber-wash) 8px, color-mix(in srgb, var(--amber-wash) 60%, var(--card)) 8px, color-mix(in srgb, var(--amber-wash) 60%, var(--card)) 16px);
  border-radius: 5px; padding: 11px 13px; margin: 10px 0; font-size: 0.8rem;
}
.risk .rl { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.2em; text-transform: uppercase; color: #8a6716; display: block; margin-bottom: 4px; font-weight: 700; }
.help-scrim { position: fixed; inset: 0; background: rgba(23,21,18,0.35); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.help-scrim.open { opacity: 1; pointer-events: auto; }

/* ============ MISC ============ */
.mono { font-family: var(--mono); }
.mut { color: var(--ink-mute); }
.right { text-align: right; }
.mt { margin-top: 18px; } .mb0 { margin-bottom: 0; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.searchbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.searchbar input[type=search], .searchbar select {
  font-family: var(--body); font-size: 0.86rem; padding: 8px 13px;
  border: 1px solid var(--hairline-dark); border-radius: 99px; background: var(--card);
  min-width: 220px;
}
.searchbar .fpill {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 7px 13px; border-radius: 99px; border: 1px solid var(--hairline-dark);
  background: var(--card); color: var(--ink-soft); text-decoration: none;
}
.searchbar .fpill.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 16px 26px; border-left: 1px solid var(--hairline-dark); margin-left: 8px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 2px; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--paper); border: 2px solid var(--ink);
}
.timeline li.oxide::before { border-color: var(--oxide); background: var(--oxide-wash); }
.timeline li.moss::before { border-color: var(--moss); background: var(--moss-wash); }
.timeline .tl-t { font-size: 0.85rem; font-weight: 600; }
.timeline .tl-m { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-mute); letter-spacing: 0.08em; margin-top: 2px; }
.timeline .tl-b { font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }

.progressbar { height: 7px; border-radius: 99px; background: var(--paper-deep); border: 1px solid var(--hairline); overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--moss); border-radius: 99px; }
.progressbar.low > i { background: var(--oxide); }
.progressbar.mid > i { background: var(--amber); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 0.85rem; }
.kv dt { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); padding-top: 3px; }
.kv dd { font-weight: 500; }

/* ============ BOARD (build requests) ============ */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .board { grid-template-columns: 1fr; } }

.board-col { min-height: 160px; }
.board-col > .bc-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px 12px; border-bottom: 2px solid var(--hairline-dark); margin-bottom: 12px;
}
.board-col > .bc-head .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.board-col.col-requested > .bc-head .dot { background: var(--oxide); box-shadow: 0 0 0 3px var(--oxide-wash); }
.board-col.col-planned > .bc-head .dot { background: var(--steel); box-shadow: 0 0 0 3px var(--steel-wash); }
.board-col.col-in-progress > .bc-head .dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.board-col.col-done > .bc-head .dot { background: var(--moss); box-shadow: 0 0 0 3px var(--moss-wash); }
.board-col > .bc-head .t {
  font-family: var(--display); font-weight: 700; font-stretch: 112%;
  font-size: 0.78rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink);
}
.board-col > .bc-head .n {
  margin-left: auto; font-family: var(--mono); font-size: 0.62rem;
  color: var(--ink-mute); border: 1px solid var(--hairline-dark);
  background: var(--card); border-radius: 99px; padding: 1px 8px;
}
.board-col > .bc-empty {
  border: 1.5px dashed var(--hairline-dark); border-radius: 8px;
  padding: 22px 12px; text-align: center;
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-mute);
}

.bcard {
  position: relative;
  background: var(--card); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 12px 14px 10px; margin-bottom: 12px; box-shadow: var(--shadow-card);
  border-left: 3px solid var(--hairline-dark);
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}
.bcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--hairline-dark); }
.col-requested .bcard { border-left-color: var(--oxide); }
.col-planned .bcard { border-left-color: var(--steel); }
.col-in-progress .bcard { border-left-color: var(--amber); }
.col-done .bcard { border-left-color: var(--moss); }
.col-done .bcard .bt { color: var(--ink-mute); }

.bcard .bhead { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bcard .bnum {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--ink-mute);
}
.bcard .btag {
  margin-left: auto; font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.16em;
  text-transform: uppercase; border-radius: 99px; padding: 2.5px 9px; border: 1px solid;
  white-space: nowrap;
}
.bcard .btag.ankit { color: var(--oxide-deep); background: var(--oxide-wash); border-color: color-mix(in srgb, var(--oxide) 35%, transparent); }
.bcard .btag.client { color: var(--moss); background: var(--moss-wash); border-color: color-mix(in srgb, var(--moss) 35%, transparent); }

.bcard .bt { font-weight: 650; font-size: 0.89rem; line-height: 1.35; letter-spacing: -0.005em; }
.bcard .bd {
  font-size: 0.77rem; color: var(--ink-mute); line-height: 1.5; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bcard details.bmore summary {
  list-style: none; cursor: pointer; font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--oxide-deep); margin-top: 5px;
}
.bcard details.bmore summary::-webkit-details-marker { display: none; }
.bcard details.bmore[open] summary { display: none; }
.bcard .bshots { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bcard .bshots a {
  display: block; width: 56px; height: 56px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--card);
  transition: transform 0.1s, border-color 0.15s;
}
.bcard .bshots a:hover { transform: scale(1.04); border-color: var(--hairline-dark); }
.bcard .bshots img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bcard details.bmore .bfull { font-size: 0.77rem; color: var(--ink-soft); line-height: 1.5; margin-top: 5px; white-space: pre-wrap; }
.bcard details.bmore[open] ~ .bd, .bcard .bd:has(~ details.bmore[open]) { display: none; }

.bcard .bfoot {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--hairline); margin-top: 11px; padding-top: 9px;
}
.bcard .avatar {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 0.58rem; font-weight: 700;
  background: var(--ink); color: var(--paper);
}
.bcard .avatar.client { background: var(--moss); }
.bcard .bmeta { font-family: var(--mono); font-size: 0.6rem; color: var(--ink-mute); letter-spacing: 0.04em; }
.bcard .bctl { margin-left: auto; display: flex; gap: 5px; align-items: center; }
.bcard .bctl form { display: inline; margin: 0; }
.bcard .mvbtn {
  width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--hairline-dark); background: var(--paper); border-radius: 6px;
  color: var(--ink-soft); font-size: 0.78rem; line-height: 1; padding: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.bcard .mvbtn:hover { border-color: var(--ink); color: var(--ink); background: var(--card); }
.bcard .mvbtn.fwd { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bcard .mvbtn.fwd:hover { background: var(--oxide); border-color: var(--oxide); }
.bcard .mvbtn.del { border-color: transparent; background: none; color: var(--ink-mute); font-size: 0.7rem; }
.bcard .mvbtn.del:hover { color: var(--oxide-deep); background: var(--oxide-wash); border-color: transparent; }
.bcard .mvbtn[title] { position: relative; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); border-radius: 6px;
  padding: 11px 20px; font-size: 0.85rem; z-index: 90; box-shadow: var(--shadow-pop);
  animation: rise 0.3s both;
}

/* Print pages get their own stylesheets; hide chrome when printing */
@media print {
  .rail, .topline, .pagehead .actions, .help-toggle, .searchbar, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: white; }
  body::before { display: none; }
}

/* ============ MOBILE ============ */
.mobilebar { display: none; }
.nav-scrim {
  position: fixed; inset: 0; background: rgba(23, 21, 18, 0.45); z-index: 70;
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.nav-scrim.open { opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  /* Sticky ink topbar with hamburger */
  .mobilebar {
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 65;
    background: var(--ink); color: var(--paper);
    padding: 12px 16px;
    box-shadow: 0 1px 0 rgba(239, 235, 225, 0.12), 0 4px 14px rgba(23, 21, 18, 0.25);
  }
  .mobilebar .wordmark {
    font-family: var(--display); font-weight: 900; font-stretch: 125%;
    font-size: 1.05rem; letter-spacing: 0.01em; text-transform: uppercase; line-height: 1;
  }
  .mobilebar .wordmark em { font-style: normal; color: var(--oxide); }
  .nav-toggle {
    width: 40px; height: 40px; flex-shrink: 0; margin-left: -6px;
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  }
  .nav-toggle span {
    display: block; width: 20px; height: 2px; background: var(--paper);
    border-radius: 2px; transition: transform 0.2s, opacity 0.2s;
  }
  .nav-toggle.x span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.x span:nth-child(2) { opacity: 0; }
  .nav-toggle.x span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Rail becomes an off-canvas drawer */
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; z-index: 75;
    width: min(300px, 84vw);
    transform: translateX(-103%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.25, 1);
    box-shadow: var(--shadow-pop);
  }
  .rail.open { transform: none; }
  .rail a.nav { padding: 11px 20px 11px 17px; font-size: 0.92rem; }
  body.nav-locked { overflow: hidden; }

  /* Main content */
  .main { padding: 0 16px 60px; }
  .topline { flex-wrap: wrap; gap: 8px; letter-spacing: 0.12em; }
  .pagehead { padding: 20px 0 14px; margin-bottom: 18px; }
  .pagehead .actions { width: 100%; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

  /* Tables scroll sideways instead of crushing */
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-head { flex-wrap: wrap; }

  /* Help drawer above the sticky topbar */
  .help-drawer { z-index: 85; }
  .help-scrim { z-index: 80; }
  table.ledger { min-width: max-content; }
  .ledger thead th, .ledger tbody td { padding: 10px 12px; }

  /* Forms & search: full-width, no iOS focus-zoom */
  .field input, .field select, .field textarea,
  .searchbar input[type=search], .searchbar select { font-size: 16px; }
  .searchbar input[type=search], .searchbar select { min-width: 0; flex: 1 1 100%; }
  .searchbar .fpill { padding: 8px 13px; }

  /* Touch targets */
  .btn { padding: 11px 16px; }
  .btn.sm { padding: 8px 12px; }
  .bcard .mvbtn { width: 34px; height: 34px; }
  .help-toggle { padding: 9px 14px; }
}

@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { padding-top: 10px; }
  .kv dt:first-child { padding-top: 0; }
  .grid2, .grid31 { gap: 14px; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 26px 22px 24px; }
}

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; position: relative; z-index: 1;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(168, 70, 47, 0.13), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(79, 89, 75, 0.14), transparent 55%),
    var(--paper);
}
.login-card {
  width: min(400px, 92vw); background: var(--card);
  border: 1px solid var(--hairline-dark); border-top: 4px solid var(--oxide);
  border-radius: 8px; box-shadow: var(--shadow-pop); padding: 34px 34px 30px;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.login-card .wordmark {
  font-family: var(--display); font-weight: 900; font-stretch: 125%;
  font-size: 1.5rem; text-transform: uppercase; line-height: 1;
}
.login-card .wordmark em { font-style: normal; color: var(--oxide); }
.login-card .sub {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--ink-mute); margin: 8px 0 26px;
}
.login-err {
  background: var(--oxide-wash); border: 1px solid color-mix(in srgb, var(--oxide) 40%, transparent);
  color: var(--oxide-deep); border-radius: 5px; padding: 9px 13px; font-size: 0.8rem; margin-bottom: 16px;
}
