/* Hallmark · scope: /admin shell + pages · pre-emit critique: P4 H5 E4 S4 R5 V4
 *
 * The admin is a working surface: hairline cards on the paper, mono eyebrows for every
 * label, tabular numerals, and colour reserved for data and state (accent for series, the
 * semantic green/amber/red for status). Everything reads Hallmark tokens from
 * theme_hallmark.css (body.hallmark is set by the layout) with plain fallbacks so the page
 * still renders if HALLMARK_UI is flipped off.
 *
 * Mobile: the rail becomes a horizontally scrolling strip under 900px; KPI grids are
 * auto-fill with minmax(0, ·) floors; every table lives in an overflow-x wrapper. Loads
 * before tailwind.css (alphabetical), so rules are two classes deep where a utility could
 * otherwise win. */

.adm-body { background: var(--hh-paper, #0f1218); color: var(--text-primary, #e8ecf4); margin: 0; }
.adm-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }

/* ── Rail ─────────────────────────────────────────────────────────────────── */
.adm-side {
  border-right: 1px solid var(--hh-rule, #2a3140); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.adm-brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; padding: 0 6px; }
.adm-brand-word { font-weight: 900; letter-spacing: -0.01em; font-size: 18px; }
.adm-brand-accent { color: var(--hh-accent, #4693f1); }
.adm-brand-tag { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--hh-accent-2, #fbbf24); font-weight: 700; }
.adm-nav { display: flex; flex-direction: column; gap: 2px; }
.adm-nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 6px; text-decoration: none; color: var(--text-secondary, #a8b0c2);
  font-size: 14px; font-weight: 600; border-left: 3px solid transparent;
}
.adm-nav-link:hover { color: var(--text-primary, #e8ecf4); background: var(--hh-paper-2, #161b24); }
.adm-nav-link.is-active { color: var(--text-primary, #e8ecf4); background: var(--hh-paper-2, #161b24); border-left-color: var(--hh-accent, #4693f1); }
.adm-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; background: var(--accent-danger, #ef4444); color: #fff; font-variant-numeric: tabular-nums;
}
.adm-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.adm-side-link { font-size: 13px; color: var(--text-muted, #7c8598); text-decoration: none; }
.adm-side-link:hover { color: var(--text-primary, #e8ecf4); }
.adm-side-btn { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font: inherit; font-size: 13px; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.adm-main { padding: 28px 32px 56px; min-width: 0; }
.adm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 4px double var(--hh-ink, #e8ecf4); padding-bottom: 10px; }
body.hallmark .adm-title { font-family: var(--hh-display); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: clamp(20px, 2vw + 10px, 28px); margin: 0; }
.adm-title { font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: clamp(20px, 2vw + 10px, 28px); margin: 0; }
.adm-kicker { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--hh-accent-2, #fbbf24); font-weight: 700; margin: 0; }
.adm-sub { color: var(--text-secondary, #a8b0c2); font-size: 13px; margin: 0; }
.adm-eyebrow { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted, #7c8598); font-weight: 700; margin: 0 0 10px; }
.adm-section { margin: 28px 0 0; }
.adm-section > .adm-eyebrow { border-bottom: 1px solid var(--hh-rule, #2a3140); padding-bottom: 6px; }

.adm-flash { border: 1px solid; border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.adm-flash-ok { border-color: var(--accent-secondary, #10b981); color: var(--accent-secondary, #10b981); background: color-mix(in oklab, var(--accent-secondary, #10b981) 10%, transparent); }
.adm-flash-warn { border-color: var(--accent-danger, #ef4444); color: var(--accent-danger, #ef4444); background: color-mix(in oklab, var(--accent-danger, #ef4444) 10%, transparent); }

/* ── Cards, tiles, grids ──────────────────────────────────────────────────── */
.adm-card { background: var(--hh-paper-2, #161b24); border: 1px solid var(--hh-rule, #2a3140); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.adm-card-top { border-top: 2px solid var(--hh-ink, #e8ecf4); }
.adm-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.adm-grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.adm-grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }

.adm-tile { display: flex; flex-direction: column; gap: 6px; }
.adm-tile-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted, #7c8598); font-weight: 700; }
.adm-tile-value { font-size: clamp(22px, 2vw + 12px, 30px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
/* flex-wrap + a shrinkable sparkline: in a 2-up phone grid the tile is ~130px wide, and a
   fixed 140px SVG beside the value pushed the document past the viewport (probe, 320/375). */
.adm-tile-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-width: 0; }
.adm-tile-delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.adm-tile-delta.is-up { color: var(--accent-secondary, #10b981); }
.adm-tile-delta.is-down { color: var(--accent-danger, #ef4444); }
.adm-tile-delta.is-flat, .adm-tile-note { color: var(--text-muted, #7c8598); font-weight: 600; }
.adm-tile-note { font-size: 11px; }
.adm-spark { display: block; width: auto; max-width: 140px; min-width: 0; height: 36px; flex: 1 1 60px; }

/* Ops strip: one row of status pills above the tiles. */
.adm-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.adm-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--hh-rule, #2a3140); font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text-primary, #e8ecf4); background: var(--hh-paper-2, #161b24); }
.adm-pill:hover { border-color: var(--hh-accent, #4693f1); }
.adm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted, #7c8598); flex: 0 0 auto; }
.adm-dot.is-ok { background: var(--accent-secondary, #10b981); }
.adm-dot.is-warn { background: var(--accent-warning, #f59e0b); }
.adm-dot.is-bad { background: var(--accent-danger, #ef4444); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.adm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { text-align: left; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted, #7c8598); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--hh-rule, #2a3140); white-space: nowrap; }
.adm-table td { padding: 9px 10px; border-bottom: 1px solid var(--hh-rule, #2a3140); vertical-align: top; font-variant-numeric: tabular-nums; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table .num { text-align: right; }
.adm-table a { color: var(--text-primary, #e8ecf4); }
.adm-muted { color: var(--text-muted, #7c8598); }
.adm-mono { font-variant-numeric: tabular-nums; }
.adm-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--hh-rule, #2a3140); color: var(--text-secondary, #a8b0c2); white-space: nowrap; }
.adm-tag.is-ok { color: var(--accent-secondary, #10b981); border-color: var(--accent-secondary, #10b981); }
.adm-tag.is-warn { color: var(--accent-warning, #f59e0b); border-color: var(--accent-warning, #f59e0b); }
.adm-tag.is-bad { color: var(--accent-danger, #ef4444); border-color: var(--accent-danger, #ef4444); }
.adm-tag.is-accent { color: var(--hh-accent, #4693f1); border-color: var(--hh-accent, #4693f1); }
.adm-tag.is-gold { color: var(--hh-accent-2, #fbbf24); border-color: var(--hh-accent-2, #fbbf24); }

/* ── Forms & buttons ─────────────────────────────────────────────────────── */
.adm-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.adm-input, .adm-select { background: var(--hh-paper, #0f1218); color: var(--text-primary, #e8ecf4); border: 1px solid var(--hh-rule, #2a3140); border-radius: 6px; padding: 7px 10px; font-size: 13px; min-width: 0; }
.adm-input { flex: 1 1 200px; }
.adm-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 4px; border: 1px solid var(--hh-rule, #2a3140); background: transparent; color: var(--text-primary, #e8ecf4); font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; cursor: pointer; text-decoration: none; white-space: nowrap; font-family: inherit; }
.adm-btn:hover { border-color: var(--hh-accent, #4693f1); color: var(--hh-accent, #4693f1); }
.adm-btn.is-primary { background: var(--hh-accent, #4693f1); border-color: var(--hh-accent, #4693f1); color: var(--hh-accent-ink, #0b1220); }
.adm-btn.is-primary:hover { color: var(--hh-accent-ink, #0b1220); filter: brightness(1.08); }
.adm-btn.is-danger { border-color: var(--accent-danger, #ef4444); color: var(--accent-danger, #ef4444); }
.adm-btn.is-danger:hover { background: color-mix(in oklab, var(--accent-danger, #ef4444) 12%, transparent); }
.adm-btn.is-small { padding: 4px 8px; font-size: 11px; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.adm-actions form { display: inline; }
.adm-inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.adm-pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--text-secondary, #a8b0c2); }

/* ── Bars (funnels, top lists) ────────────────────────────────────────────── */
.adm-bars { display: flex; flex-direction: column; gap: 8px; }
.adm-bar { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 10px; align-items: center; font-size: 13px; }
.adm-bar-label { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.adm-bar-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-bar-track { height: 6px; background: var(--hh-paper, #0f1218); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.adm-bar-fill { height: 100%; background: var(--hh-accent, #4693f1); border-radius: 3px; }
.adm-bar-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── Cohort grid ──────────────────────────────────────────────────────────── */
.adm-cohort td { text-align: center; }
.adm-cohort .c { display: inline-block; min-width: 42px; padding: 3px 4px; border-radius: 3px; font-size: 12px; font-weight: 700; }

/* ── Timeline / transcript ────────────────────────────────────────────────── */
.adm-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.adm-timeline li { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--hh-rule, #2a3140); font-size: 13px; }
.adm-timeline li:last-child { border-bottom: 0; }
.adm-msg { border: 1px solid var(--hh-rule, #2a3140); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; max-width: 760px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.adm-msg.is-user { border-left: 3px solid var(--hh-accent, #4693f1); }
.adm-msg.is-assistant { border-left: 3px solid var(--hh-accent-2, #fbbf24); }
.adm-msg-meta { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted, #7c8598); font-weight: 700; margin-bottom: 4px; }

/* ── Definition rows ──────────────────────────────────────────────────────── */
.adm-dl { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); gap: 6px 12px; font-size: 13px; margin: 0; }
.adm-dl dt { color: var(--text-muted, #7c8598); }
.adm-dl dd { margin: 0; overflow-wrap: anywhere; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .adm-shell { grid-template-columns: minmax(0, 1fr); }
  .adm-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--hh-rule, #2a3140); padding: 12px 14px; gap: 10px; }
  .adm-nav { flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px; padding-bottom: 4px; }
  .adm-nav-link { border-left: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; padding: 8px 10px; white-space: nowrap; }
  .adm-nav-link.is-active { border-bottom-color: var(--hh-accent, #4693f1); }
  .adm-side-foot { flex-direction: row; gap: 14px; margin-top: 0; }
  .adm-main { padding: 18px 14px 40px; }
  .adm-timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-width: 480px) {
  .adm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .adm-card { padding: 12px; }
  .adm-tile-value { font-size: 20px; }
}

/* ---- Phase 2 ---- */

/* MRR movement — diverging month columns: new MRR up, churned down, split by a hairline
   baseline. Bar heights are set inline by the view as % of the window's max. */
.adm-moves { display: flex; gap: 6px; }
.adm-move { flex: 1 1 0; min-width: 0; text-align: center; }
.adm-move-plot { height: 120px; display: flex; flex-direction: column; }
.adm-move-up { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; border-bottom: 1px solid var(--hh-rule, #2a3140); }
.adm-move-down { flex: 1 1 0; }
.adm-move-up i, .adm-move-down i { display: block; width: 62%; margin: 0 auto; }
.adm-move-up i { background: var(--accent-secondary, #10b981); border-radius: 2px 2px 0 0; }
.adm-move-down i { background: var(--accent-danger, #ef4444); border-radius: 0 0 2px 2px; }
.adm-move-label { margin-top: 4px; font-size: 10px; color: var(--text-muted, #7d8590); font-variant-numeric: tabular-nums; }

/* Raw Telegram text next to what the parser made of it. */
.adm-msg-compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
@media (max-width: 900px) { .adm-msg-compare { grid-template-columns: minmax(0, 1fr); } }
