/* Bulkie console: partner portal and admin. Tokens from web-v2 (black, graphite, ash,
   smoke, paper; green, yellow, red for meaning only). Dark by default, light when the
   system asks for it. No inline styles anywhere: the CSP blocks them. */
:root {
  color-scheme: dark light;
  --bg: #000;
  --surface: #1c1c1e;
  --raised: #2c2c2e;
  --line: #2c2c2e;
  --line-soft: #1c1c1e;
  --text: #f3f1ec;
  --text-2: #d6d4cf;
  --muted: #8e8e93;
  --ink: #f3f1ec;
  --on-ink: #000;
  --green: #30d158;
  --yellow: #ffd60a;
  --red: #ff453a;
  --green-bg: rgba(48, 209, 88, .14);
  --yellow-bg: rgba(255, 214, 10, .14);
  --red-bg: rgba(255, 69, 58, .14);
  --chart: #f3f1ec;
  --chart-muted: #3a3a3c;
  --focus: #f3f1ec;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 16px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f1ec;
    --surface: #fff;
    --raised: #e9e6df;
    --line: #dcd8cf;
    --line-soft: #ebe8e1;
    --text: #0d070a;
    --text-2: #2c2c2e;
    --muted: #5c5c61;
    --ink: #0d070a;
    --on-ink: #f3f1ec;
    --green: #1f7a35;
    --yellow: #8a5a00;
    --red: #c4120a;
    --green-bg: #dff3e4;
    --yellow-bg: #fbefc9;
    --red-bg: #fbe0de;
    --chart: #0d070a;
    --chart-muted: #c9c5bc;
    --focus: #0d070a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--ink); color: var(--on-ink); padding: 8px 14px; border-radius: 999px; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .93em; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* Lockup */
.lockup { display: inline-flex; align-items: center; gap: 7px; color: var(--text); fill: currentColor; text-decoration: none; }
.lockup .mark { width: 12px; height: 17px; }
.lockup .word { width: 58px; height: 17px; }
.lockup .tag { margin-left: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* Shell */
.shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr); }
.shell > * { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line-soft); }
.top .spacer { flex: 1; }
.top form { margin: 0; }
.who { font-size: 13px; color: var(--muted); }
.main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }
.main.narrow { max-width: 560px; }

/* Tabs (partner) */
.tabs { border-bottom: 1px solid var(--line-soft); background: var(--bg); }
.tabs ul { display: flex; gap: 4px; max-width: 1120px; margin: 0 auto; padding: 0 10px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.tabs ul::-webkit-scrollbar { display: none; }
.tabs a { display: block; padding: 12px 10px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--ink); }

/* Sidebar (admin) */
@media (min-width: 900px) {
  .shell.side { grid-template-columns: 232px minmax(0, 1fr); }
  .side .nav { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line-soft); padding: 18px 12px; }
  .js .side .nav-toggle { display: none; }
  .side .menu { display: block !important; }
}
.side .nav .lockup { padding: 4px 10px 18px; }
.menu ul { list-style: none; padding: 0; }
.menu a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.menu a[aria-current="page"] { background: var(--surface); color: var(--text); }
.menu .group { margin: 14px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.menu .count { min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--raised); font-size: 12px; text-align: center; }
.side-foot { margin-top: 18px; padding: 12px 10px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.side-foot .role { display: inline-block; margin-top: 2px; }
@media (max-width: 899.98px) {
  .side .nav { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line-soft); padding: 0 16px; }
  .side .nav-bar { display: flex; align-items: center; justify-content: space-between; height: 56px; }
  .side .nav .lockup { padding: 0; }
  .side .menu { padding-bottom: 12px; }
  .js .side .menu { display: none; }
  .js .side .nav.open .menu { display: block; }
}
@media (min-width: 900px) { .side .nav-bar { display: block; } }
.nav-toggle { display: none; }
.js .nav-toggle { display: inline-flex; align-items: center; }
.nav-toggle { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: none; cursor: pointer; }

/* Page head */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.head h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.head p { margin-top: 6px; color: var(--muted); max-width: 46em; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: inherit; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 12px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }

/* Cards and stat tiles */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.stat dt { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat dd { margin-top: 4px; font-size: clamp(22px, 3vw, 28px); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.stat .sub { display: block; margin-top: 4px; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.stat.lead { background: var(--ink); color: var(--on-ink); }
.stat.lead dt, .stat.lead .sub { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.stat.lead .delta-up, .stat.lead .delta-down { color: inherit; font-weight: 600; }
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 20px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* Tables */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
@media (prefers-color-scheme: light) { th, td { border-bottom-color: var(--line-soft); } }
thead th { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
td a { font-weight: 500; }
tr.dim td { color: var(--muted); }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
caption { text-align: left; padding: 12px 14px 0; font-weight: 600; }

/* Badges: color only with a word */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--raised); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.good { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--yellow-bg); color: var(--yellow); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.info { background: var(--raised); color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 14.5px; text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform 150ms var(--ease-out), opacity 150ms; }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--raised); color: var(--text); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: none; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; min-height: 48px; font-size: 16px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) { .btn:hover { opacity: .86; } }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:active { transform: none; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted); cursor: pointer; }

/* Forms */
form.stack > :not([type=hidden]) ~ * { margin-top: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label, fieldset > legend { font-size: 13.5px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
.error-text { font-size: 13px; color: var(--red); font-weight: 500; }
input[type=text], input[type=email], input[type=search], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); }
@media (prefers-color-scheme: light) { input[type=text], input[type=email], input[type=search], input[type=number], input:not([type]), select, textarea { background: #fff; } }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); }
input[readonly] { color: var(--text-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--ink); }
.choices { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 6px; }
.choices label { display: inline-flex; gap: 8px; align-items: center; min-height: 32px; }
.choices input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .field { flex: 1 1 200px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 140px; flex: 1 1 140px; max-width: 260px; }
.filters .field.grow { max-width: none; flex: 3 1 220px; }
input[type=range] { width: 100%; accent-color: var(--ink); min-height: 32px; }
.range { display: flex; gap: 12px; align-items: center; }
.range output { min-width: 4ch; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* Notices */
.notice { padding: 12px 16px; border-radius: 12px; background: var(--surface); box-shadow: inset 3px 0 0 var(--muted); margin-bottom: 20px; }
.notice.good { box-shadow: inset 3px 0 0 var(--green); }
.notice.bad { box-shadow: inset 3px 0 0 var(--red); }
.notice.warn { box-shadow: inset 3px 0 0 var(--yellow); }
.notice strong { font-weight: 600; }
.mockbar { padding: 6px 20px; font-size: 12.5px; text-align: center; background: var(--yellow-bg); color: var(--yellow); font-weight: 600; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* Copy rows, QR */
.copy { display: flex; gap: 8px; align-items: stretch; }
.copy input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; }
.copy .btn { min-height: 44px; }
.code-big { font: 700 clamp(28px, 6vw, 40px)/1.1 var(--mono); letter-spacing: .06em; overflow-wrap: anywhere; }
.qr { width: 200px; max-width: 100%; padding: 12px; background: #fff; border-radius: 12px; }
.qr svg { width: 100%; height: auto; }
.split { display: grid; gap: 16px; }
@media (min-width: 860px) { .split { grid-template-columns: 1.4fr 1fr; align-items: start; } }

/* Charts: small multiples, one series each */
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.chart { background: var(--surface); border-radius: var(--radius); padding: 16px 16px 10px; min-width: 0; }
.chart header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chart h3 { font-size: 14px; font-weight: 600; }
.chart .total { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.chart .note { margin-top: 6px; font-size: 12.5px; color: var(--muted); min-height: 1.3em; }
.chart svg { width: 100%; height: auto; margin-top: 10px; overflow: visible; }
.chart .bar { fill: var(--chart); }
.chart .bar.neg { fill: var(--red); }
.chart .gap { fill: none; stroke: var(--chart-muted); stroke-width: 1.5; stroke-dasharray: 2 2; }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: .7; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart.wide { grid-column: 1 / -1; }
details.table-view { margin-top: 8px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details.table-view .table-wrap { margin-top: 8px; background: var(--bg); max-height: 320px; overflow-y: auto; }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; }
.hbar svg { width: 100%; height: 12px; }
.hbar rect { fill: var(--chart); }

/* Tickets */
.thread { display: grid; gap: 12px; }
.msg { padding: 14px 16px; border-radius: 14px; background: var(--surface); max-width: 760px; }
.msg.staff { background: var(--raised); margin-left: auto; }
.msg.note { background: var(--yellow-bg); }
.msg header { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-layout { display: grid; gap: 20px; }
@media (min-width: 980px) { .ticket-layout { grid-template-columns: 1fr 300px; align-items: start; } }
.unread { font-weight: 700; }

/* Prose (agreement, brief) */
.prose { color: var(--text-2); max-width: 46em; }
.prose > * + * { margin-top: 12px; }
.prose h1, .prose h2 { color: var(--text); margin-top: 24px; }
.prose h1 { font-size: 22px; }
.prose ol, .prose ul { padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose strong { color: var(--text); }
.prose table { font-size: 14px; margin-top: 12px; }
.prose th, .prose td { padding: 8px 10px 8px 0; background: none; }
.prose code { font-family: var(--mono); font-size: .9em; padding: 1px 6px; border-radius: 6px; background: var(--raised); }
.agreement { max-height: 360px; overflow-y: auto; padding: 16px 18px; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }

/* Assets */
.shots { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.shots figure { background: var(--surface); border-radius: var(--radius); padding: 10px; }
.shots img { width: 100%; border-radius: 12px; aspect-ratio: 1206 / 2622; object-fit: cover; background: #000; }
.shots figcaption { margin-top: 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 20px; }
.auth .box { width: 100%; max-width: 420px; }
.auth .lockup { margin-bottom: 28px; }
.auth h1 { font-size: 28px; letter-spacing: -0.02em; line-height: 1.15; }
.auth p.lead { margin-top: 8px; color: var(--muted); }
.auth form { margin-top: 24px; }
.auth .foot { margin-top: 28px; font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.demo { margin-top: 28px; padding: 14px 16px; border-radius: 12px; background: var(--yellow-bg); font-size: 13.5px; }
.demo strong { color: var(--yellow); }
.demo ul { margin-top: 6px; padding-left: 18px; }
.demo li + li { margin-top: 4px; }
.demo form { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--muted); }

/* Danger zone */
.danger-zone { box-shadow: inset 0 0 0 1px var(--red-bg); }
details.action { border-top: 1px solid var(--line-soft); }
details.action:first-of-type { border-top: 0; }
details.action > summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.action > summary::-webkit-details-marker { display: none; }
details.action > summary::after { content: "+"; color: var(--muted); font-weight: 400; }
details.action[open] > summary::after { content: "\2212"; }
details.action > form { padding-bottom: 16px; }
.hbar .contents-row { display: contents; }
@media (max-width: 560px) {
  .top { gap: 8px; padding: 0 14px; }
  .top .who, .top .lockup .tag { display: none; }
  .main { padding: 20px 16px 64px; }
}
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
@media (min-width: 700px) { .grid.stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.top-inner { display: contents; }
.card > * + * { margin-top: 14px; }
.card > .hint, .card > p.muted { margin-top: 8px; }
.card > .section-head + * { margin-top: 0; }
.card > .section-head { margin-bottom: 12px; }
.inline-bar { display: inline-block; vertical-align: middle; }
.inline-bar .track { fill: var(--raised); }
.inline-bar .fill { fill: var(--ink); }
ol.thread { list-style: none; padding: 0; }
ul.stack { list-style: none; padding: 0; margin-top: 12px; }
ul.stack > li + li { margin-top: 14px; }
.ticket-layout aside > * + * { margin-top: 16px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
@media (min-width: 700px) { .grid.stats { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
td .inline-form { flex-wrap: nowrap; align-items: center; }
td .inline-form input { width: 150px; min-height: 36px; padding: 6px 10px; }
td .inline-form .btn { min-height: 36px; }
.stat dd .lines { display: block; font-size: clamp(19px, 2.2vw, 23px); line-height: 1.25; }
.stat dd .lines > span { display: block; }
.card .table-wrap.flush { background: none; margin: 4px -14px 0; border-radius: 0; }
.plain-list { list-style: none; padding: 0; }
.plain-list > li + li { margin-top: 10px; }
.demo-sub { margin-top: 10px; }
.auth .box > .btn, .auth .box > a.btn { margin-top: 24px; }
section > h2 + .table-wrap, section > h2 + p { margin-top: 12px; }
