/* Wajer Actuals — one visual system. Tokens first, then primitives, then page pieces. */

:root {
  --blue: #000037;
  --light-blue: #d1e9f7;
  --grey: #f0f0f0;
  --white: #ffffff;
  --ink: #0b1021;
  --muted: #5b6472;
  --border: #e3e6ec;
  --row-border: #eef0f4;
  --hover: #f7f9fc;
  --amber-ink: #b45309;
  --amber-bg: #fef3c7;
  --green-ink: #166534;
  --green-bg: #dcfce7;
  --slate-ink: #334155;
  --slate-bg: #e2e8f0;
  --red-ink: #991b1b;
  --shadow: 0 1px 2px rgba(0, 0, 55, 0.06);
  --radius: 10px;
  --control: 36px;
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--grey);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h1 small, h2 small { color: var(--muted); font-weight: 400; font-size: 0.72em; margin-left: 0.35em; }
p { margin: 0 0 0.6rem; }
strong { font-weight: 600; }
em { font-style: normal; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint, .meta { color: var(--muted); font-size: 13px; }
.meta { margin: 0 0 0.25rem; }
.crumb { font-size: 13px; margin: 0 0 0.5rem; }
.crumb a { color: var(--muted); }
.crumb a::before { content: "\2190\00a0"; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nums { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; text-align: center;
  font: 500 11px/18px var(--font); color: var(--slate-ink);
  background: var(--white); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
}

/* ---------- header ---------- */
header.top {
  height: 64px; background: var(--blue); color: var(--white);
  display: flex; align-items: center; gap: 28px; padding: 0 32px;
}
header.top .brand { display: inline-flex; align-items: baseline; gap: 10px; color: var(--white); text-decoration: none; white-space: nowrap; }
header.top .wordmark { font-weight: 600; font-size: 14px; letter-spacing: 0.18em; text-transform: uppercase; }
header.top .product { color: var(--light-blue); font-weight: 400; font-size: 15px; }
header.top nav { display: flex; align-items: center; gap: 4px; height: 100%; }
header.top nav a {
  position: relative; display: inline-flex; align-items: center; height: 64px; padding: 0 10px;
  color: rgba(255, 255, 255, 0.78); font-size: 14px; font-weight: 500; white-space: nowrap;
}
header.top nav a:hover { color: var(--white); text-decoration: none; }
header.top nav a.active { color: var(--white); }
header.top nav a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--light-blue); border-radius: 2px 2px 0 0;
}
header.top .me {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px 0 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: var(--white); font-size: 13px; white-space: nowrap;
}
header.top .me:hover, header.top .me.active { background: rgba(209, 233, 247, 0.22); text-decoration: none; }
header.top .me-role { color: var(--light-blue); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 32px 48px; }
footer.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 32px 40px; }

/* ---------- page header ---------- */
.bar { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin: 0 0 6px; }
.bar h1 { margin-right: auto; }
.bar + .hint, .bar + .meta { margin: 0 0 24px; font-size: 14px; }
.fy { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fy label { display: inline-flex; align-items: center; gap: 8px; }
section + section, .group + .group, .table-wrap + h2, .group + h2, .summary + h2, .actions + h2, details.split + h2 { margin-top: 24px; }
h2 + .table-wrap, h2 + .actions, h2 + .group, h2 + .cards { margin-top: 10px; }
#flash + h2, .flash + h2 { margin-top: 24px; }

/* ---------- cards & panels ---------- */
.card, .group, .qcard, .summary, .table-wrap, .narrow, .empty {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card, .qcard, .summary, .narrow { padding: 20px; }
.narrow { max-width: 560px; margin: 40px auto; }
.narrow #sign-in { display: flex; justify-content: center; }
.narrow .cl-rootBox { width: 100%; }
.auth-switch { margin-top: 14px; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--navy, #000037); font-weight: 500; }
.narrow h1 { margin-bottom: 8px; }
.narrow p:last-child { margin-bottom: 0; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; }
.empty a { font-weight: 500; }

.group { margin: 0 0 16px; }
.group-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 20px; }
.group-head .meta { margin: 4px 0 0; }
.group-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.pills { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.group-body { border-top: 1px solid var(--row-border); }
.group-body .loading { display: block; padding: 14px 20px; color: var(--muted); font-size: 13px; }
.group-body .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.group-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 12px 20px; background: var(--grey); border-top: 1px solid var(--border); border-radius: 0 0 9px 9px;
}
.group-foot.sticky { position: sticky; bottom: 0; }
.group.unknown { border-color: #f1d48a; }
.group .callout {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0; padding: 12px 20px; background: var(--light-blue); color: var(--ink); font-size: 14px; border-top: 1px solid var(--row-border);
}
.callout p { margin: 0; }

details.ch-lines > summary {
  list-style: none; cursor: pointer; padding: 12px 20px; font-size: 13px; font-weight: 500; color: var(--blue);
  border-top: 1px solid var(--row-border); display: flex; align-items: center; gap: 8px;
}
details.ch-lines > summary::-webkit-details-marker { display: none; }
details.ch-lines > summary::before { content: ""; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform 0.15s; margin-left: 2px; }
details.ch-lines[open] > summary::before { transform: rotate(45deg); }
details.ch-lines > summary:hover { background: var(--hover); }

/* stat tiles */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; }
.summary > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.summary .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.summary .big { font-size: 22px; }
table.mini { border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 1px 12px 1px 0; }

/* show cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; color: inherit; transition: border-color 0.12s, box-shadow 0.12s; }
.card:hover { text-decoration: none; border-color: #c8cfdb; box-shadow: 0 1px 3px rgba(0, 0, 55, 0.1); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card h2 { font-size: 16px; }
.card .meta { margin: 0; }
.card .money { margin-top: auto; padding-top: 10px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.card .money .big { color: var(--ink); font-size: 18px; }
.meter { height: 5px; background: var(--light-blue); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--blue); border-radius: 3px; }

/* ---------- tables ---------- */
.table-wrap { overflow: visible; }
table.lines { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.lines th, table.lines td { padding: 10px 14px; border-bottom: 1px solid var(--row-border); text-align: left; vertical-align: middle; height: 44px; }
table.lines th:first-child, table.lines td:first-child { padding-left: 20px; }
table.lines th:last-child, table.lines td:last-child { padding-right: 20px; }
table.lines thead th {
  background: var(--grey); color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
  height: 40px; border-bottom: 1px solid var(--border);
}
table.lines thead th:first-child { border-top-left-radius: 9px; }
table.lines thead th:last-child { border-top-right-radius: 9px; }
table.lines tbody tr:last-child td { border-bottom: 0; }
table.lines tbody tr:hover td { background: var(--hover); }
table.lines tbody tr.explain:hover td, table.lines tbody tr.band:hover td { background: inherit; }
table.lines td a { color: inherit; }
table.lines td a:hover { color: var(--blue); text-decoration: underline; }
table.lines tr.old td { color: var(--muted); }
table.lines tr.explain td { padding: 0; border: 0; height: auto; }
table.lines tr.explain td:empty { display: none; }
table.lines tbody tr[tabindex]:focus { outline: 2px solid var(--light-blue); outline-offset: -2px; }
table.lines tfoot th { font-weight: 600; background: var(--grey); border-top: 1px solid var(--border); text-align: right; }
table.lines tfoot th:first-child { text-align: left; border-bottom-left-radius: 9px; }
table.lines tfoot th:last-child { border-bottom-right-radius: 9px; }
table.lines td.wrap { overflow-wrap: anywhere; }
table.lines .gl-name { color: var(--muted); }
table.lines tr.band td { position: sticky; top: 0; z-index: 1; background: var(--grey); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; height: 32px; padding-top: 0; padding-bottom: 0; }
.mgmt .delta a { font-weight: 600; }
.mgmt .neg, .mgmt .neg a { color: var(--red-ink); }
.mgmt .pos, .mgmt .pos a { color: var(--green-ink); }
.explain-box { background: var(--light-blue); padding: 12px 20px; font-size: 13px; }
.explain-box ul { margin: 6px 0 0; padding-left: 18px; }
.explain-box li { margin: 2px 0; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 20px;
  padding: 0 8px; border-radius: 999px; background: var(--grey); color: var(--slate-ink); white-space: nowrap;
}
.chip.ok { background: var(--green-bg); color: var(--green-ink); }
.chip.open { background: var(--amber-bg); color: var(--amber-ink); }
.chip.warn { background: var(--slate-bg); color: var(--slate-ink); }
.chip.info { background: var(--light-blue); color: var(--blue); }
.chip.none { background: var(--grey); color: var(--muted); }
.chip a { color: inherit; text-decoration: underline; }
.status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }

/* ---------- controls ---------- */
button, .btn {
  font: 500 14px/1 var(--font); height: var(--control); padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--blue); background: var(--blue); color: var(--white); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
button:hover, .btn:hover { background: #10104a; text-decoration: none; }
button.secondary, .btn.secondary { background: var(--white); color: var(--blue); border-color: var(--border); }
button.secondary:hover, .btn.secondary:hover { background: var(--hover); border-color: #c8cfdb; }
button:focus-visible, .btn:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--light-blue); outline-offset: 1px;
}
button u { text-decoration: none; }
select, input[type=text], input[type=email] {
  font: 400 14px var(--font); color: var(--ink); height: var(--control); padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--white); max-width: 100%;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235b6472' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input::placeholder { color: #9aa3b2; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); vertical-align: middle; cursor: pointer; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
form.inline { display: inline-flex; gap: 6px; }
.pick { display: inline-flex; }

/* per-line action rows */
.actions { display: flex; flex-direction: column; gap: 10px; }
.act-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-left: 72px; min-height: var(--control); }
.act-label { position: absolute; left: 0; top: 11px; white-space: nowrap; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.act { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.act select { min-width: 160px; }
.act input[type=text], .act input[type=email] { min-width: 140px; }
.actions .act-note input { min-width: 260px; }
.group-foot .act { gap: 8px; }
.group-foot select { max-width: 220px; }
.decide { padding: 20px; }
.decide .actions { margin: 0; }

/* split */
details.split { margin-top: 14px; font-size: 13px; }
details.split summary { cursor: pointer; color: var(--blue); font-weight: 500; }
table.parts { border-collapse: collapse; margin: 10px 0; width: 100%; }
table.parts th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; text-align: left; padding: 4px 8px 4px 0; }
table.parts td { padding: 4px 8px 4px 0; }
table.parts input[type=text] { width: 100%; }
table.parts td select { max-width: 160px; }

/* ---------- queue card ---------- */
.qcard { max-width: 880px; display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr); gap: 24px; padding: 24px; }
.q-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.q-main .meta { margin: 0; }
.q-title { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; margin: 2px 0 4px; }
.q-amount { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.q-gl { font-size: 14px; margin: 0; }
.q-foot { margin-top: auto; padding-top: 12px; }
.q-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.suggestion { background: var(--light-blue); color: var(--ink); padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.suggestion .chip { vertical-align: middle; }
.qcard .act select { max-width: 180px; }
.suggestion p { margin: 0; }
.suggestion p + p { margin-top: 4px; }

/* ---------- team picker (cardholders) ---------- */
form.team { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin: 0; flex-wrap: wrap; }
form.team label { display: inline-flex; align-items: center; gap: 8px; }
.ch-head h2 { font-size: 17px; }
.ch-head .meta { margin: 2px 0 0; }
.ch-pills { margin-top: 6px; }

/* ---------- feedback ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.flash:empty { display: none; }
.flash.ok { background: var(--green-bg); color: var(--green-ink); }
.flash.error, .error { background: var(--grey); color: var(--red-ink); border-left: 3px solid var(--red-ink); padding: 10px 14px; border-radius: 0 8px 8px 0; }
.group-foot + div .flash, [id^="ch-result"] .flash, [id^="vendor-result"] .flash, #mentions-result .flash { margin: 12px 20px; }
dl { margin: 0 0 16px; }
dl dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; margin-top: 12px; }
dl dd { margin: 0; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .qcard { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  header.top { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 0 16px; }
  header.top .brand { height: 52px; }
  header.top .me { height: 28px; padding: 0 10px; }
  header.top .me-role { display: none; }
  header.top nav { order: 3; flex-basis: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -16px; padding: 0 12px; }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { height: 40px; padding: 0 8px; font-size: 13px; }
  header.top nav a.active::after { left: 8px; right: 8px; }
  main { padding: 20px 16px 40px; }
  h1 { font-size: 24px; }
  .bar { gap: 10px; }
  .group-head, .card, .qcard, .summary, .narrow, .decide { padding: 16px; }
  .group-head { flex-direction: column; }
  .group-stats { align-items: flex-start; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.lines { min-width: 720px; font-size: 13px; }
  table.lines td, table.lines th { white-space: nowrap; }
  table.lines td.wrap { white-space: normal; min-width: 240px; }
  table.lines tr.band td { position: static; }
  .group-foot, .callout { padding: 12px 16px; }
  .group-foot .act, .act-row .act, .act { width: 100%; }
  .group-foot select, .act select, .act input[type=text], .act input[type=email], .group-foot input[type=text] { flex: 1 1 140px; min-width: 0; }
  .group-foot button, .act-row button, .callout button { width: 100%; }
  .act-row { padding-left: 0; }
  .act-label { position: static; width: 100%; }
  .group-foot.sticky { position: static; }
  .act kbd { display: none; }
  .qcard .act select { max-width: none; }
  .nums { align-items: flex-start; }
  .summary { gap: 14px; }
}
