/* ALLY AI · Kredit AI
   Warm paper, ink, one burnt-orange accent. The balance figure is the page. */
:root {
  --paper: #f5f2eb;
  --panel: #ffffff;
  --ink: #15171c;
  --muted: #565a63;
  --line: #d9d3c5;
  --line-strong: #8f8878;  /* control edges: 3.5:1 on panel (WCAG 1.4.11) */
  --accent: #b93c0b;
  --accent-ink: #ffffff;
  --ok: #1d6a47;
  --ok-bg: #e3efe7;
  --wait: #8a5a00;
  --wait-bg: #f6ecd6;
  --bad: #a32020;
  --bad-bg: #f7e2df;

  --f-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --gutter: 16px;
  --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--f-body);
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Chrome ── */
.top { border-bottom: 1px solid var(--line); }
.top-inner {
  max-width: 1120px; margin: 0 auto; padding: 14px var(--gutter);
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
}
.mark { font: 700 18px/1 var(--f-display); letter-spacing: 0.04em; }
.mark-ai { color: var(--accent); margin-left: 2px; }
.top-label {
  font-size: 14px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sandbox {
  background: var(--wait-bg); color: var(--wait);
  font-size: 14px; padding: 8px var(--gutter); text-align: center;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 32px var(--gutter) 64px; }
.narrow { max-width: 640px; }

/* ── Type ── */
.eyebrow {
  margin: 0 0 12px; font: 500 13px/1.3 var(--f-mono);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.display {
  font: 700 clamp(36px, 8vw, 64px)/1.02 var(--f-display);
  letter-spacing: -0.025em; margin: 0 0 20px;
}
.h1 { font: 700 32px/1.15 var(--f-display); letter-spacing: -0.015em; margin: 0 0 24px; }
.h2 { font: 600 20px/1.3 var(--f-display); letter-spacing: -0.01em; margin: 0 0 16px; }
.lede { font-size: 18px; color: var(--muted); max-width: 52ch; }
.aside, .small { color: var(--muted); font-size: 14px; }
.small { display: block; line-height: 1.45; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ── Balance figure (signature) ── */
.figure {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 18px;
  font-family: var(--f-mono); font-variant-numeric: tabular-nums;
}
.figure .cur { font-size: 18px; color: var(--muted); }
.figure .num {
  font-weight: 500; font-size: clamp(52px, 14vw, 104px);
  line-height: 0.95; letter-spacing: -0.04em;
}
.figure.is-short .num { color: var(--bad); }

.meter {
  position: relative; height: 10px; margin-bottom: 20px;
  background: repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 10%);
  border: 1px solid var(--ink); border-radius: 2px; overflow: hidden;
}
.meter-left { position: absolute; inset: 0 auto 0 0; background: var(--ink); }
.meter + .meter-note { margin: -12px 0 16px; font-size: 13px; color: var(--muted); }

.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 16px; border-top: 1px solid var(--line);
}
.facts > div { padding: 12px 12px 0 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font: 500 16px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }

/* ── Notices & tags ── */
.notice {
  margin: 0 0 20px; padding: 12px 14px; border-left: 3px solid currentColor;
  border-radius: 0 var(--radius) var(--radius) 0; font-size: 15px;
}
.notice.ok { color: var(--ok); background: var(--ok-bg); }
.notice.wait { color: var(--wait); background: var(--wait-bg); }
.notice.bad { color: var(--bad); background: var(--bad-bg); }
.notice a { color: inherit; }
.tag { white-space: nowrap;
  display: inline-block; padding: 1px 8px; border-radius: 2px;
  font: 500 12px/1.6 var(--f-mono); background: #ebe6da; color: var(--muted);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.wait { background: var(--wait-bg); color: var(--wait); }

/* ── Account layout: balance + history left, top-up right ── */
.account {
  display: grid; gap: 40px;
  grid-template-areas: "balance" "topup" "history";
}
.balance { grid-area: balance; }
.topup { grid-area: topup; }
.history { grid-area: history; }

@media (min-width: 900px) {
  .wrap { padding-top: 56px; }
  .account {
    grid-template-columns: minmax(0, 1fr) 380px; column-gap: 72px; row-gap: 48px;
    grid-template-areas: "balance topup" "history topup";
    align-items: start;
  }
  .topup { position: sticky; top: 24px; }
}

/* ── Top-up card ── */
.topup, .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
}
.chips { border: 0; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chips legend { font-size: 14px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 88px; padding: 12px 4px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 500 16px/1 var(--f-mono); transition: border-color .15s, background-color .15s;
}
.chip-name { font: 600 12px/1 var(--f-body); letter-spacing: .12em; }
.chip-usd { font-weight: 600; font-size: 18px; }
.chip-rm { font-size: 13px; opacity: .75; }
.chip input:hover + span { border-color: var(--ink); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

input:not([type="radio"]) {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: 400 16px/1.3 var(--f-body); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
input:not([type="radio"]):hover { border-color: var(--muted); }
input.copy { font: 400 13px/1.3 var(--f-mono); min-height: 40px; background: var(--paper); }

.total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
}
.total-label { font-size: 15px; }
.total-num { font: 500 26px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.rate { font-size: 13px; color: var(--muted); margin: 10px 0 20px; line-height: 1.5; }
.fine { font-size: 13px; color: var(--muted); margin: 12px 0 0; text-align: center; }

.btn {
  display: block; width: 100%; min-height: 52px; padding: 0 20px;
  font: 600 16px/1 var(--f-body); color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: var(--radius); cursor: pointer; transition: background-color .15s;
}
.btn:hover { background: #9c320a; }
.btn:disabled { cursor: progress; }
.btn[aria-busy="true"] { background: #9c320a; }
.btn-sm {
  min-height: 44px; padding: 0 14px; font: 500 14px/1 var(--f-body);
  background: transparent; color: var(--ink); border: 1px solid var(--ink);
  border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.btn-sm:hover { background: var(--ink); color: var(--paper); }

/* ── Ledger tables ── */
.scroll { overflow-x: auto; position: relative; }
.ledger { width: 100%; border-collapse: collapse; font-size: 15px; }
.ledger th {
  text-align: left; font: 500 12px/1.3 var(--f-mono); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 12px 10px 0; border-bottom: 1px solid var(--ink);
}
.ledger td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger td.mono { white-space: nowrap; }

/* Customer history collapses to stacked rows on phones */
@media (max-width: 560px) {
  .history .ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .history .ledger tr {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
    padding: 12px 0; border-bottom: 1px solid var(--line);
  }
  .history .ledger td { padding: 0; border: 0; }
  .history .ledger td:nth-child(1) { color: var(--muted); font-size: 14px; }
  .history .ledger td:nth-child(3) { color: var(--muted); font-size: 14px; }
  .facts { grid-template-columns: 1fr 1fr; }
}

/* ── Admin ── */
.admin { display: grid; gap: 48px; }
.admin > *, .account > * { min-width: 0; }
.customers input.copy { min-width: 240px; }
.customers .btn-sm { white-space: nowrap; }
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.stack dt { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.stack dd { margin: 0; }
.new-acct { max-width: 560px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Home: package price list */
.price-list { margin-top: 48px; }
.packages { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.packages li {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.packages .chip-usd { font-family: var(--f-mono); font-size: 20px; }
.pkg-rm { font: 500 15px/1 var(--f-mono); color: var(--muted); }
td.small { display: table-cell; }  /* .small is block; cells must stay cells to span columns */

/* Error page */
.error-page { padding-top: 64px; }
.error-page .btn-link { display: inline-block; margin-top: 8px; color: var(--accent); font-weight: 600; }

/* Account: which Hermes agent this page belongs to */
.agent { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.agent-name { font: 700 clamp(28px, 6vw, 40px)/1.1 var(--f-display); letter-spacing: -0.02em; margin: 0 0 14px; }
.agent-co { font: 500 14px/1 var(--f-mono); letter-spacing: .08em; color: var(--muted); vertical-align: middle; margin-left: 6px; }
.agent-ids { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.agent-ids dt { font-size: 13px; color: var(--muted); }
.agent-ids dd { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.field { display: block; margin: 4px 0 18px; }
.field-label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* Company page: per-employee split */
.staff-h { margin-top: 32px; }
.staff .small { display: block; }

/* Admin: one card per company */
.company { display: grid; gap: 16px; }
.company .h2 { margin: 0; }
.facts-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
@media (max-width: 560px) { .facts-4 { grid-template-columns: 1fr 1fr; } }
.company-tools { display: grid; gap: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
@media (min-width: 900px) { .company-tools { grid-template-columns: 1fr 1fr; column-gap: 32px; } }
.tool { display: grid; gap: 6px; min-width: 0; }
.tool-label { font-size: 13px; color: var(--muted); }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tool-row select { flex: 1 1 160px; min-width: 0; }
.tool-row .amount { flex: 0 1 100px; width: 100px; }
.tool-row .small { flex: 1 1 200px; }
select {
  min-height: 44px; padding: 0 10px; font: 400 15px/1.3 var(--f-body); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.btn-inline { width: auto; margin-top: 16px; }
.code {
  font: 400 13px/1.6 var(--f-mono); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; overflow-x: auto; white-space: pre;
}

/* Lead moves credit on their page */
.move { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 24px; }
.move-form { display: grid; gap: 0 16px; margin-top: 16px; }
@media (min-width: 560px) { .move-form { grid-template-columns: 1fr 1fr; } .move-form .btn { align-self: end; margin-bottom: 18px; } }
.move-form select { width: 100%; min-height: 48px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-ghost:hover, .btn-ghost[aria-busy="true"] { background: var(--ink); color: var(--paper); }
.h3 { font: 600 16px/1.3 var(--f-display); margin: 28px 0 8px; }
.changes { list-style: none; margin: 0; padding: 0; }
.changes li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.changes .mono { font-weight: 500; margin-right: 6px; }
input.copy.pin { font-size: 28px; letter-spacing: 0.3em; min-height: 56px; }

/* Balance getting low: amber under 25%, red under 10% */
.meter.is-wait .meter-left { background: var(--wait); }
.meter.is-bad .meter-left { background: var(--bad); }
.meter-note.runway { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }
.meter-note.runway strong { color: var(--ink); font-weight: 600; }
/* Employees out of / low on credit: one box per problem, names listed */
.alert {
  margin: 0 0 12px; padding: 12px 14px 6px; border-left: 3px solid currentColor;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.alert.bad { color: var(--bad); background: var(--bad-bg); }
.alert.wait { color: var(--wait); background: var(--wait-bg); }
.alert-h { font: 600 15px/1.3 var(--f-body); margin: 0; display: flex; justify-content: space-between; gap: 12px; }
.alert-count { font: 500 12px/1.6 var(--f-mono); }
.alert-note { margin: 2px 0 6px; font-size: 14px; }
.alert-list { list-style: none; margin: 0; padding: 0; color: var(--ink); }
.alert-list li {
  display: flex; align-items: center; gap: 12px; min-height: 44px;
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}
.alert-name { flex: 1; font-weight: 500; }
.alert-list .mono { font-size: 14px; }
.alert-act {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px;
  font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none;
  border: 1px solid var(--ink); border-radius: var(--radius);
}
.alert-act:hover { background: var(--ink); color: var(--paper); }
.alert-after { margin: -4px 0 16px; }
.alert + .facts, .alert-after + .facts { margin-top: 16px; }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

/* Admin summary */
.summary td { vertical-align: middle; }
.summary a { font-weight: 600; color: var(--ink); }
.mini-meter {
  display: inline-block; width: 64px; height: 8px; margin-right: 8px; vertical-align: middle;
  border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; position: relative;
}
.mini-meter > span { position: absolute; inset: 0 auto 0 0; background: var(--ink); }
.mini-meter.is-wait > span { background: var(--wait); }
.mini-meter.is-bad > span { background: var(--bad); }
.txt-bad { color: var(--bad); font-weight: 600; }
.txt-wait { color: var(--wait); font-weight: 600; }
.h2 .tag { vertical-align: middle; margin-left: 6px; }

/* Admin: searchable, collapsible company list */
[hidden] { display: none !important; }
.h2-count { font: 500 14px/1 var(--f-mono); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.co-toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 12px; }
.co-search { flex: 1 1 260px; }
.co-search input { min-height: 44px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg-btn {
  min-height: 44px; padding: 0 14px; font: 500 14px/1 var(--f-body); color: var(--ink);
  background: var(--panel); border: 0; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg-btn .mono { margin-left: 4px; opacity: .8; }
.co-bulk { display: flex; gap: 4px; }
.btn-link {
  min-height: 44px; padding: 0 8px; font: 500 14px/1 var(--f-body); color: var(--ink);
  background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.co-none { margin-top: 8px; }

.co-card { padding: 0; gap: 0; overflow: hidden; }
.co-sum {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 16px 52px 16px 24px;
  cursor: pointer; list-style: none; position: relative; min-height: 64px;
}
.co-sum::-webkit-details-marker { display: none; }
.co-sum:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.co-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 auto; }
.co-name { margin: 0; }
.co-meta { font-size: 13px; color: var(--muted); }
.chev {
  position: absolute; right: 22px; top: 50%; width: 9px; height: 9px; margin-top: -7px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
  transition: transform .15s;
}
.co-card[open] .chev { transform: rotate(-135deg); margin-top: -2px; }
.co-body { padding: 0 24px 24px; display: grid; gap: 16px; }
@media (max-width: 560px) {
  .co-sum { padding: 14px 44px 14px 16px; }
  .chev { right: 18px; }
  .co-body { padding: 0 16px 20px; }
}
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }

/* Sortable summary headers */
.th-sort {
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  background: none; border: 0; padding: 6px 0; min-height: 36px; cursor: pointer; text-align: left;
}
.th-sort:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--ink); }
.co-cards { display: grid; gap: 16px; }

/* Company admin page */
.crumb { margin: 0 0 16px; font-size: 14px; }
.crumb a { color: var(--ink); }
.co-head { margin-bottom: 24px; }
.co-head .h1 { margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.co-head .co-meta { margin: 0 0 6px; }
.co-links { margin: 0; font-size: 14px; }
.co-links a, .co-more a { color: var(--ink); font-weight: 500; }
.co-detail { display: grid; gap: 16px; margin-bottom: 32px; }
.co-more { margin: 0; font-size: 14px; }
.sort-status { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.btn-link-sm { min-height: 0; padding: 0 0 0 8px; font-size: 13px; }
.co-page { gap: 0; }
.co-page > section { margin-bottom: 48px; }
.co-head .h1 { margin-top: 0; }
.co-detail > .facts:first-child { border-top: 0; margin-top: -8px; }

/* ── Lead page: two tabs (top-up & payment / quota allocation) ── */
.co-intro { margin-bottom: 28px; padding-bottom: 0; border-bottom: 0; }
.co-intro .agent-ids { margin-bottom: 0; }
.tabs {
  display: flex; gap: 4px; margin: 0 0 32px;
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px;
  margin-bottom: -1px; border-bottom: 3px solid transparent; white-space: nowrap;
  font: 600 16px/1 var(--f-display); color: var(--muted); text-decoration: none;
  transition: color .15s;
}
.tab:first-child { padding-left: 0; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab-badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--bad); color: #fff; font: 600 12px/22px var(--f-mono); text-align: center;
}
.tab-jump { margin: 0 0 16px; font-size: 14px; }
.alloc { display: grid; gap: 40px; }
.alloc-main > .alert:first-child { margin-top: 0; }
.alloc .move { margin: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.alloc .move-form { grid-template-columns: 1fr; }
.alloc .move-form .btn { margin-bottom: 0; }
@media (min-width: 900px) {
  .alloc { grid-template-columns: minmax(0, 1fr) 380px; column-gap: 72px; align-items: start; }
  .alloc .move { position: sticky; top: 24px; }
  /* the top-up card is taller than the balance; let history follow the balance */
  .account { grid-template-rows: auto 1fr; }
}
@media (prefers-reduced-motion: reduce) { .tab { transition: none; } }

/* ── Internal team (monthly limits) ── */
.team-balance { margin-bottom: 28px; }
.team-balance .runway { margin-top: -8px; }
.team-card input.copy { width: 100%; margin-top: 6px; }
.team-card .co-body > .small:first-child { margin-top: 0; }
