/* Chat Recap admin. The public app's world (ink, lime, Bricolage + Inter) set as a working tool:
   restrained colour, dense tables, colour reserved for actions and money states. */

@font-face {
  font-family: 'Inter';
  src: url('/admin/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/admin/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #0b0a10;
  --rail: #0f0e15;
  --surface: #14131b;
  --surface-2: #1a1823;
  --surface-3: #24212f;
  --line: rgb(255 255 255 / 0.07);
  --line-2: rgb(255 255 255 / 0.12);
  --text: #f2f1f6;
  --text-2: #b2afc0;
  --text-3: #8a8798;
  --lime: #c6f432;
  --lime-dim: rgb(198 244 50 / 0.14);
  --on-lime: #0b0a10;
  --ok: #34e3a8;
  --warn: #ffb547;
  --bad: #ff6b9a;
  --info: #5cc8fa;
  --ok-bg: rgb(52 227 168 / 0.12);
  --warn-bg: rgb(255 181 71 / 0.12);
  --bad-bg: rgb(255 107 154 / 0.12);
  --info-bg: rgb(92 200 250 / 0.12);
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Inter', ui-sans-serif, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  caret-color: var(--lime);
  scrollbar-color: var(--surface-3) transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100dvh; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--text); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--lime); }
::selection { background: var(--lime); color: var(--on-lime); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num, td.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--text-3); }
.soft { color: var(--text-2); }
.boot { padding: 48px 16px; color: var(--text-3); text-align: center; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 17px; margin-bottom: 40px; }
.login-brand img { width: 28px; height: 28px; }
.login h1 { font-family: var(--display); font-size: 40px; line-height: 1; letter-spacing: -0.03em; font-weight: 800; margin: 0 0 12px; }
.login p.lead { margin: 0 0 28px; color: var(--text-2); }
.marker { display: inline-block; font-style: normal; color: var(--on-lime); background: var(--lime); padding: 0.02em 0.16em 0.06em; transform: rotate(-1.4deg); }
.login .form-err { min-height: 21px; margin: 12px 0 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 28px 16px; background: var(--rail); border-right: 1px solid var(--line); }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 36px; font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.rail-brand img { width: 26px; height: 26px; }
.rail-brand small { font-family: var(--sans); font-weight: 500; font-size: 12px; color: var(--text-3); margin-left: auto; padding: 1px 7px; border: 1px solid var(--line-2); border-radius: 999px; }
nav.nav { display: flex; flex-direction: column; gap: 4px; }
nav.nav button { display: flex; align-items: center; gap: 12px; width: 100%; height: 42px; padding: 0 12px; border: 0; border-radius: var(--r); background: none; color: var(--text-2); font-weight: 500; text-align: left; cursor: pointer; transition: background 150ms, color 150ms; }
nav.nav button:hover { background: var(--surface-2); color: var(--text); }
nav.nav button[aria-current='page'] { background: var(--surface-3); color: var(--text); }
nav.nav button[aria-current='page'] svg { color: var(--lime); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 16px; padding: 20px 12px 0; border-top: 1px solid var(--line); }
.sources { display: grid; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.source { display: flex; align-items: center; gap: 8px; }
.logout { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0; border: 0; background: none; color: var(--text-2); cursor: pointer; font-weight: 500; }
.logout:hover { color: var(--text); }

main.main { min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 48px 56px 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 36px; }
.page-head h1 { font-family: var(--display); font-weight: 750; font-size: 34px; line-height: 1.1; letter-spacing: -0.025em; margin: 0; }
.page-head .sub { margin: 8px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); color: var(--text); font-weight: 550; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background 150ms, border-color 150ms, transform 150ms; }
.btn:hover { background: var(--surface-3); border-color: rgb(255 255 255 / 0.18); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }
.btn.primary:hover { background: #d4ff52; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.wide { width: 100%; height: 46px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-3); cursor: pointer; transition: background 150ms, color 150ms; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); }
.icon-btn svg.i { width: 16px; height: 16px; }

.field { display: block; margin-bottom: 22px; }
.field > .label { display: block; font-size: 13.5px; font-weight: 550; color: var(--text-2); margin-bottom: 8px; }
.input, .field input:not([type='checkbox']), .field select, .field textarea, select.input {
  width: 100%; height: 42px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); outline: none; transition: border-color 150ms, box-shadow 150ms;
}
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: rgb(255 255 255 / 0.2); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-dim); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type='date']::-webkit-calendar-picker-indicator { filter: invert(0.8); }
.hint { font-size: 12.5px; color: var(--text-3); margin: 6px 0 0; }
.form-err { color: var(--bad); font-weight: 550; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.check { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--lime); }

.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { padding-left: 38px; }

.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); max-width: 100%; overflow-x: auto; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: none; color: var(--text-2); font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background 150ms, color 150ms; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.4); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chips button { height: 30px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 550; cursor: pointer; }
.chips button:hover { color: var(--text); border-color: rgb(255 255 255 / 0.25); }
.chips button[aria-pressed='true'] { background: var(--lime); border-color: var(--lime); color: var(--on-lime); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.toolbar .count { margin-left: auto; color: var(--text-3); font-size: 13px; }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text-2); }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.status.ok::before { background: var(--ok); }
.status.warn::before { background: var(--warn); }
.status.bad::before { background: var(--bad); }
.status.info::before { background: var(--info); }
.status.lime::before { background: var(--lime); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.lime { background: var(--lime-dim); color: var(--lime); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.info { background: var(--info-bg); color: var(--info); }
.void { text-decoration: line-through; text-decoration-color: rgb(255 107 154 / 0.7); color: var(--text-3); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.panel-head h2 { font-size: 15px; font-weight: 650; margin: 0; }
.panel-body { padding: 16px 24px 24px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; border-radius: var(--r); background: var(--warn-bg); color: #ffd9a0; margin-bottom: 24px; }
.notice svg { color: var(--warn); margin-top: 2px; }
.notice.bad { background: var(--bad-bg); color: #ffc2d5; }
.notice.bad svg { color: var(--bad); }
.notice p { margin: 0; }

/* ---------- Summary ---------- */
.overview { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.side { display: grid; gap: 24px; }
.headline { padding: 32px 32px 8px; }
.headline .big { font-family: var(--display); font-weight: 750; font-size: 52px; line-height: 1; letter-spacing: -0.03em; margin: 0; }
.headline .line { margin: 14px 0 0; color: var(--text-2); }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); margin: 28px 0 0; }
.figures > div { padding: 20px 32px; border-right: 1px solid var(--line); }
.figures > div:last-child { border-right: 0; }
.figures dt { font-size: 13px; color: var(--text-3); }
.figures dd { margin: 6px 0 0; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-wrap { padding: 28px 32px 44px 76px; border-top: 1px solid var(--line); }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--lime); transition: opacity 150ms; }
.chart .bar.zero { fill: var(--surface-3); }
.chart.hovering .bar:not(.on) { opacity: 0.4; }
.chart .hit { fill: transparent; cursor: crosshair; }
.ylab, .xlab { position: absolute; font-size: 11.5px; color: var(--text-3); white-space: nowrap; pointer-events: none; }
.ylab { right: calc(100% + 10px); transform: translateY(-50%); }
.xlab { top: calc(100% + 8px); transform: translateX(-50%); }
.xlab.start { transform: none; }
.xlab.end { transform: translateX(-100%); }
.tip { position: absolute; z-index: 2; pointer-events: none; padding: 8px 10px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: 0 8px 24px rgb(0 0 0 / 0.45); font-size: 12.5px; color: var(--text-2); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 120ms; }
.tip.show { opacity: 1; }
.tip b { display: block; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .right { margin-left: auto; text-align: right; }
.empty-line { color: var(--text-3); margin: 0; }
.todo { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; color: var(--text); }
.todo:first-child { border-top: 0; padding-top: 2px; }
.todo:hover .todo-text { color: var(--lime); }
.todo .n { min-width: 28px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 6px; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.todo svg { margin-left: auto; color: var(--text-3); width: 16px; height: 16px; }
.allclear { display: flex; gap: 10px; align-items: center; color: var(--text-2); margin: 0; }
.allclear svg { color: var(--ok); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0 18px; height: 58px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { height: 46px; font-size: 13px; font-weight: 550; color: var(--text-3); background: var(--surface); }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 120ms; }
tbody tr:hover td { background: rgb(255 255 255 / 0.025); }
tbody tr.clickable { cursor: pointer; }
td.right, th.right { text-align: right; }
td.wrap { white-space: normal; min-width: 140px; max-width: 260px; color: var(--text-2); }
td .sub { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.35; margin-top: 2px; }
td.stack { padding-top: 10px; padding-bottom: 10px; line-height: 1.4; }
tfoot td { height: 60px; font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
td.empty { height: auto; padding: 56px 24px; text-align: center; white-space: normal; color: var(--text-2); }
td.empty .empty-title { display: block; color: var(--text); font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.row-actions .link-btn { margin-right: 6px; }
.code-cell { display: inline-flex; align-items: center; gap: 4px; }
.code-cell .mono { font-size: 13.5px; color: var(--text); }
.usage { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.usage .track { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.usage .fill { height: 100%; background: var(--lime); }
.usage .fill.full { background: var(--bad); }
.docs { display: grid; gap: 3px; }
.doc { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.doc .mono { color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--lime); }
.link-btn svg.i { width: 14px; height: 14px; }

/* Skeleton */
.sk { display: block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* ---------- Sheet (side panel) ---------- */
dialog { padding: 0; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(5 4 8 / 0.62); }
dialog.sheet { margin: 0 0 0 auto; width: min(540px, 100vw); height: 100dvh; max-height: 100dvh; border-width: 0 0 0 1px; border-radius: 0; }
dialog.sheet[open] { animation: sheet-in 240ms var(--ease); }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
.sheet-inner { display: flex; flex-direction: column; height: 100%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 17px; font-weight: 650; margin: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 28px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 18px 28px; border-top: 1px solid var(--line); background: var(--surface); }
.amount { font-family: var(--display); font-weight: 750; font-size: 42px; letter-spacing: -0.03em; line-height: 1; margin: 0 0 14px; }
dl.props { display: grid; grid-template-columns: 140px minmax(0, 1fr); margin: 28px 0 0; border-top: 1px solid var(--line); }
dl.props dt, dl.props dd { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); }
dl.props dt { color: var(--text-3); }
dl.props dd { min-width: 0; overflow-wrap: anywhere; }
.sheet h3 { font-size: 14px; font-weight: 650; color: var(--text-2); margin: 36px 0 14px; }
.doc-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; }
.doc-card .sub { display: block; color: var(--text-3); font-size: 12.5px; }
.codes-out { width: 100%; min-height: 220px; padding: 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r); font-family: var(--mono); font-size: 13px; line-height: 1.7; resize: vertical; }

#toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgb(0 0 0 / 0.5); font-weight: 550; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity 180ms, transform 220ms var(--ease); max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast svg { color: var(--ok); }
#toast.error svg { color: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .overview { grid-template-columns: 1fr; }
  .page { padding: 36px 32px 80px; }
}
@media (max-width: 860px) {
  th, td { padding: 0 14px; height: 52px; }
  th:first-child, td:first-child { padding-left: 16px; }
  .headline { padding: 24px 20px 4px; }
  .figures > div { padding: 16px 20px; }
  .chart-wrap { padding: 22px 20px 40px 60px; }
  .panel-head { padding: 18px 20px 0; }
  .panel-body { padding: 14px 20px 20px; }
  .sheet-head, .sheet-foot { padding-left: 20px; padding-right: 20px; }
  .sheet-body { padding: 22px 20px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); background: rgb(15 14 21 / 0.96); }
  .rail-brand { padding: 0; }
  .rail-brand small { margin-left: 4px; }
  nav.nav { order: 3; flex-direction: row; flex-basis: 100%; overflow-x: auto; gap: 4px; }
  nav.nav button { width: auto; height: 34px; white-space: nowrap; }
  nav.nav button svg { display: none; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .sources { display: none; }
  .page { padding: 28px 16px 64px; }
  .page-head h1 { font-size: 26px; }
  .headline .big { font-size: 36px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures > div:nth-child(2) { border-right: 0; }
  .figures > div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar .count { margin-left: 0; }
  .row2 { grid-template-columns: 1fr; }
  dl.props { grid-template-columns: 1fr; }
  dl.props dt { padding-bottom: 0; border-bottom: 0; }
}
