/* ─────────────────────────────────────────────────────────────────────────────
   base.css — shell, navigation, cards, tables, overlays.
   Rhythm: every padding, margin and gap is a multiple of 4px.
   Chrome stays quiet; the chart is the one rich moment on the screen.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;

  --font-ui: "Paperlogy", "Pretendard", -apple-system, "Apple SD Gothic Neo",
             "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-w: 256px;
}

* , *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--font-ui);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; padding: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; border-spacing: 0; }
::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: var(--s4); top: -64px; z-index: 40;
  background: var(--surface-2); color: var(--text);
  padding: var(--s2) var(--s4); border-radius: var(--r-md);
  transition: top 160ms var(--ease);
}
.skip:focus { top: var(--s4); }

/* ── shell ─────────────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ── sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  padding: var(--s4) var(--s3) var(--s4);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s2) var(--s4);
}
.brand__mark { display: flex; width: 24px; height: 24px; align-items: center; justify-content: center; }
/* 공식 원본 로고(/static/icons/CONDERI_logo_white.svg) — 비율 유지를 위해 높이만 지정한다. */
.brand__logo { display: block; height: 30px; width: auto; }
.brand__mark svg { width: 24px; height: 24px; display: block; }
.brand__name {
  font-size: 15px; line-height: 20px; font-weight: 500; letter-spacing: 0.02em;
}
.brand__tag {
  font-family: var(--font-num); font-size: 11px; line-height: 16px;
  color: var(--text-3); letter-spacing: 0.08em;
  border: 1px solid var(--line); border-radius: var(--r-xs);
  padding: 0 var(--s1); margin-left: var(--s1);
}
.brand__collapse { margin-left: auto; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text-3); cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }

.searchbtn {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; height: 36px; padding: 0 var(--s2) 0 var(--s3);
  margin-bottom: var(--s6);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--text-3); font-size: 13px; cursor: pointer; text-align: left;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.searchbtn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.searchbtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.searchbtn span { flex: 1; }

kbd {
  font-family: var(--font-num); font-size: 11px; line-height: 16px;
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  padding: 0 var(--s1); min-width: 24px; text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav { display: flex; flex: 1; flex-direction: column; gap: var(--s1); overflow-y: auto; padding-bottom: var(--s4); }
.nav__label {
  margin: var(--s6) 0 var(--s2) ; padding: 0 var(--s2);
  font-size: 11px; line-height: 16px; color: var(--text-3); letter-spacing: 0.04em;
}
.nav__label:first-child { margin-top: 0; }

.nav__row {
  display: flex; align-items: center; gap: var(--s2);
  height: 32px; padding: 0 var(--s2);
  border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13px; line-height: 20px;
  cursor: pointer; border: 1px solid transparent;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.nav__row svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; opacity: 0.9; }
.nav__row span.nav__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__row:hover { background: var(--surface); color: var(--text); }
.nav__row.is-active {
  background: var(--surface-2); color: var(--text);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.nav__row.is-active svg { color: var(--accent); opacity: 1; }
.nav__count {
  font-family: var(--font-num); font-size: 11px; line-height: 16px;
  color: var(--text-3); font-variant-numeric: tabular-nums;
}
.nav__row.is-active .nav__count { color: var(--text-2); }

.dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--text-3);
}
.dot--enterprise { background: var(--series-2); }
.dot--business   { background: var(--series-1); }
.dot--pro        { background: var(--series-3); }
.dot--starter    { background: var(--series-4); }
.dot--live       { background: var(--pos); box-shadow: 0 0 0 3px rgba(76, 195, 138, 0.12); }
.dot--warn       { background: var(--warn); }
.dot--neg        { background: var(--neg); }

.sidebar__foot { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.statusrow {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2); font-size: 11px; line-height: 16px; color: var(--text-3);
}
.account { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); border-radius: var(--r-md); }
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--text); font-size: 12px;
  border: 1px solid var(--line); flex: none;
}
.account b { display: block; font-size: 12px; line-height: 16px; font-weight: 500; }
.account small { display: block; font-size: 11px; line-height: 16px; color: var(--text-3); }

/* ── main ──────────────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--s3);
  height: 56px; padding: 0 var(--s8);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
/* 모바일 바: 사이드바가 접히는 폭에서만 공식 로고를 노출한다. */
.topbar__logo { display: none; height: 27px; width: auto; flex: none; }
.topbar__crumbs {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 12px; color: var(--text-3);
}
.topbar__crumbs svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.topbar__crumbs b { color: var(--text-2); font-weight: 400; }
.topbar__crumbs { flex: 1; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: var(--s2); }

.view { padding: var(--s8) var(--s8) var(--s16); width: 100%; max-width: 1440px; }

.page__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s6); margin-bottom: var(--s8); flex-wrap: wrap;
}
.page__title {
  margin: 0; font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -0.01em;
}
.page__sub { margin: var(--s1) 0 0; font-size: 13px; color: var(--text-3); }
.page__actions { display: flex; align-items: center; gap: var(--s2); }

/* ── buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 36px; padding: 0 var(--s4);
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface); }
.btn--sm { height: 28px; padding: 0 var(--s3); font-size: 12px; }
.btn--danger { color: var(--neg); }
.btn--danger:hover { border-color: var(--neg); background: rgba(229, 72, 77, 0.08); }

.seg {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: var(--s1); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.seg button {
  height: 28px; padding: 0 var(--s3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3); font-size: 12px; cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--surface-3); color: var(--text); }

/* ── cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  min-width: 0;
}
.card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap;
}
.card__title { margin: 0; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-2); }
.card__sub { margin: var(--s1) 0 0; font-size: 12px; color: var(--text-3); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }

.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s5); min-width: 0;
}
.kpi__label { margin: 0 0 var(--s3); font-size: 12px; line-height: 16px; color: var(--text-3); }
.kpi__value {
  margin: 0; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: var(--s1);
  white-space: nowrap;
}
.kpi__unit { font-size: 13px; color: var(--text-3); font-family: var(--font-ui); }
.kpi__foot { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); flex-wrap: wrap; }
.kpi__delta { display: inline-flex; align-items: center; gap: var(--s1); font-size: 12px; line-height: 16px; }
.kpi__delta svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }
.kpi__delta.is-up { color: var(--pos); }
.kpi__delta.is-down { color: var(--neg); }
.kpi__delta.is-warn { color: var(--warn); }
.kpi__delta.is-flat { color: var(--text-3); }
.kpi__meta { font-size: 12px; line-height: 16px; color: var(--text-3); }
.kpi__spark { margin-top: var(--s3); height: 24px; }

.grid { display: grid; gap: var(--s4); }
.grid--main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); margin-bottom: var(--s4); }
.grid--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }

/* ── chart ─────────────────────────────────────────────────────────────────── */
.chartwrap { position: relative; margin-top: var(--s2); }
.chartwrap svg { display: block; width: 100%; }
.chart__total { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.chart__value {
  margin: 0; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.01em;
}
.legend { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.legend__item { display: inline-flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--text-2); }
.legend__swatch { width: 12px; height: 2px; border-radius: 2px; flex: none; }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 160px; padding: var(--s3);
  background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
  font-size: 12px; line-height: 16px;
  transition: opacity 120ms var(--ease);
}
.tooltip__title { color: var(--text-3); margin-bottom: var(--s2); }
.tooltip__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.tooltip__row + .tooltip__row { margin-top: var(--s1); }
.tooltip__row span { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-2); }
.tooltip__row b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; }

/* ── list rows ─────────────────────────────────────────────────────────────── */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row__main { min-width: 0; }
.row__title { margin: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__meta { margin: var(--s1) 0 0; font-size: 12px; line-height: 16px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__right { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 13px; }
.row__right small { display: block; font-family: var(--font-ui); font-size: 11px; color: var(--text-3); margin-top: var(--s1); }

/* ── table ─────────────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1) calc(var(--s5) * -1); padding: 0 var(--s5) var(--s5); }
.table { width: 100%; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 400; font-size: 11px; line-height: 16px;
  color: var(--text-3); letter-spacing: 0.02em; white-space: nowrap;
  padding: var(--s2) var(--s3); background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.table th.num, .table td.num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.table td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background 120ms var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td .sub { display: block; font-size: 11px; color: var(--text-3); margin-top: var(--s1); }
.table td.strong { color: var(--text); }
.table__empty { padding: var(--s10) var(--s4); text-align: center; color: var(--text-3); }

.pill {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 24px; padding: 0 var(--s2);
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-2);
  font-size: 11px; line-height: 16px; white-space: nowrap;
}
.pill .dot { width: 4px; height: 4px; }
.pill--paid { color: var(--pos); border-color: rgba(76, 195, 138, 0.24); background: rgba(76, 195, 138, 0.1); }
.pill--overdue { color: var(--neg); border-color: rgba(229, 72, 77, 0.24); background: rgba(229, 72, 77, 0.1); }
.pill--sent { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.pill--draft { color: var(--text-3); }
.pill--warn { color: var(--warn); border-color: rgba(224, 161, 92, 0.24); background: rgba(224, 161, 92, 0.1); }

.meter { display: block; width: 100%; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.meter__fill.is-warn { background: var(--warn); }
.meter__fill.is-neg { background: var(--neg); }
.meter__fill.is-pos { background: var(--pos); }

.toolbar { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; }
.toolbar__grow { flex: 1; min-width: 160px; }
.field {
  display: flex; align-items: center; gap: var(--s2);
  height: 36px; padding: 0 var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--text-2);
}
.field svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; flex: none; }
.field input {
  flex: 1; min-width: 0; height: 32px; border: 0; background: transparent; color: var(--text);
  font-size: 13px; outline: none;
}
.field input::placeholder { color: var(--text-3); }
.field:focus-within { border-color: var(--line-strong); }

select.select {
  height: 36px; padding: 0 var(--s3); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text-2); font-size: 13px;
}

/* ── misc ──────────────────────────────────────────────────────────────────── */
.insight { display: flex; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.insight:last-child { border-bottom: 0; }
.insight__idx { font-family: var(--font-num); font-size: 11px; color: var(--text-3); width: 16px; flex: none; }

.empty { padding: var(--s10) var(--s4); text-align: center; color: var(--text-3); font-size: 13px; }
.muted { color: var(--text-3); }
.strong { color: var(--text); }
.right { text-align: right; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card--flush { padding: 0; overflow: hidden; }
.card--flush .card__head { padding: var(--s5) var(--s5) 0; margin-bottom: var(--s3); }
.card--flush .tablewrap { margin: 0; padding: 0; }

.scrim {
  position: fixed; inset: 0; background: rgba(4, 6, 10, 0.6); z-index: 15;
  opacity: 0; pointer-events: none; transition: opacity 180ms var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ── split view (list + detail) ─────────────────────────────────────────────── */
.split { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.split__detail { position: sticky; top: 80px; min-height: 420px; }
@media (max-width: 1080px) { .split { grid-template-columns: minmax(0, 1fr); } }

.msgrow { transition: background 120ms var(--ease); }
.msgrow:hover { background: var(--surface-2); }
.msgrow.is-selected { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.msgrow .row__title, .msgrow .row__meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── command palette ───────────────────────────────────────────────────────── */
.palette[hidden] { display: none; }
.palette {
  position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center;
  align-items: flex-start; padding: 96px var(--s4) var(--s4);
  background: rgba(4, 6, 10, 0.64);
}
.palette__box {
  width: 100%; max-width: 560px; max-height: 480px;
  display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: rise 220ms var(--ease);
}
.palette__input {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
}
.palette__input svg { width: 16px; height: 16px; stroke: var(--text-3); fill: none; stroke-width: 1.5; }
.palette__input input {
  flex: 1; height: 24px; border: 0; background: transparent; color: var(--text);
  font-size: 14px; outline: none;
}
.palette__list { overflow-y: auto; padding: var(--s2); }
.palette__group { padding: var(--s1); }
.palette__label { padding: var(--s2) var(--s2) var(--s1); font-size: 11px; color: var(--text-3); }
.palette__item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; color: var(--text-2);
}
.palette__item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; flex: none; }
.palette__item .meta { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--font-num); }
.palette__item.is-active { background: var(--surface-3); color: var(--text); }
.palette__foot {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s2) var(--s4); border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-3);
}

/* ── drawer ────────────────────────────────────────────────────────────────── */
.drawer[hidden] { display: none; }
.drawer {
  position: fixed; inset: 0; z-index: 25; display: flex; justify-content: flex-end;
  background: rgba(4, 6, 10, 0.5);
}
.drawer__panel {
  width: 100%; max-width: 440px; height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line-strong);
  animation: slide 240ms var(--ease);
}
.drawer__head {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s5); border-bottom: 1px solid var(--line);
}
.drawer__head h2 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; }
.drawer__head p { margin: var(--s1) 0 0; font-size: 12px; color: var(--text-3); }
.drawer__body { padding: var(--s5); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--s5); }
.drawer__foot {
  display: flex; align-items: center; gap: var(--s2); justify-content: flex-end;
  padding: var(--s4) var(--s5); border-top: 1px solid var(--line);
}
.field-row { display: flex; flex-direction: column; gap: var(--s2); }
.field-row label { font-size: 12px; color: var(--text-3); }
.field-row input, .field-row select, .field-row textarea {
  height: 36px; padding: 0 var(--s3); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text); font-size: 13px;
}
.field-row textarea { height: 96px; padding: var(--s2) var(--s3); resize: vertical; line-height: 20px; }
.field-row input:focus, .field-row select:focus, .field-row textarea:focus { outline: none; border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: var(--s2) var(--s3); font-size: 13px; }
.kv dt { color: var(--text-3); font-size: 12px; }
.kv dd { margin: 0; color: var(--text); }

/* ── toasts ────────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; right: var(--s6); bottom: var(--s6); z-index: 40;
  display: flex; flex-direction: column; gap: var(--s2); align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); min-width: 200px; max-width: 360px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: rise 200ms var(--ease);
}
.toast svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; flex: none; }
.toast--ok svg { color: var(--pos); }
.toast--err svg { color: var(--neg); }

/* ── automation ────────────────────────────────────────────────────────────── */
.workflow { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); }
.workflow__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.workflow__title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; }
.workflow__desc { margin: var(--s1) 0 0; font-size: 12px; line-height: 16px; color: var(--text-3); }
.workflow__meta { display: flex; gap: var(--s2); flex-wrap: wrap; }
.workflow__form { display: flex; align-items: flex-end; gap: var(--s2); flex-wrap: wrap; }
.workflow__form .field-row { gap: var(--s1); }
.workflow__form input { width: 88px; }
.steps { display: flex; flex-direction: column; gap: var(--s2); }
.step { display: flex; align-items: flex-start; gap: var(--s2); font-size: 12px; line-height: 16px; }
.step__dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--pos); }
.step__dot--failed { background: var(--neg); }
.step__dot--skipped { background: var(--text-3); }
.step__name { color: var(--text); }
.step__detail { color: var(--text-3); }
.step__idx { font-family: var(--font-num); color: var(--text-3); width: 16px; flex: none; }

/* ── timetable ─────────────────────────────────────────────────────────────── */
.tt { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s3); }
.ttcol { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.ttcol__head {
  padding: var(--s2) 0; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--text-3); display: flex; justify-content: space-between;
}
.ttblock {
  display: flex; flex-direction: column; gap: var(--s1);
  padding: var(--s3); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.ttblock p { margin: 0; font-size: 12px; line-height: 16px; color: var(--text); }
.ttblock .mono { font-size: 11px; color: var(--text-3); }
.ttblock small { font-size: 11px; color: var(--text-3); }
.ttblock.is-full { border-color: rgba(217, 161, 91, 0.28); }

/* ── funnel ────────────────────────────────────────────────────────────────── */
.funnel { display: flex; gap: var(--s2); flex-wrap: wrap; }
.stage {
  display: flex; flex-direction: column; gap: var(--s1);
  padding: var(--s3); min-width: 96px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.stage b { font-family: var(--font-num); font-size: 20px; line-height: 28px; font-weight: 500; }
.stage span { font-size: 11px; line-height: 16px; color: var(--text-3); }

/* ── plan cards ────────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.plan { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); }
.plan__name { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--text-2); }
.plan__count { font-family: var(--font-num); font-size: 24px; line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; }
.plan__mrr { font-size: 12px; color: var(--text-3); }

/* QA: full-page screenshots keep the sidebar at full document height */
@media (min-width: 1081px) {
  .fullpage-shot .shell { position: relative; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .fullpage-shot .sidebar { position: absolute; top: 0; left: 0; width: var(--sidebar-w); height: 100%; }
  .fullpage-shot .main { grid-column: 2; }
}
.fullpage-shot .topbar { position: static; }

/* ── motion ────────────────────────────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.fade-in { animation: rise 260ms var(--ease); }

/* ── responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px;
    transform: translateX(-100%); transition: transform 220ms var(--ease);
  }
  .sidebar.is-open { transform: none; }
  .topbar { padding: 0 var(--s4); }
  .topbar__menu { display: inline-flex; }
  .topbar__logo { display: block; }
  .view { padding: var(--s6) var(--s4) var(--s12); }
  .page__title { font-size: 28px; line-height: 36px; }
}

@media (max-width: 720px) {
  .kpis, .plans, .grid--even, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page__title { font-size: 26px; line-height: 32px; }
  .kpi__value, .chart__value { font-size: 24px; line-height: 32px; }
  .card { padding: var(--s4); }
  .tablewrap { margin: 0 calc(var(--s4) * -1) calc(var(--s4) * -1); padding: 0 var(--s4) var(--s4); }
  .palette { padding: 40px var(--s2) var(--s2); }
  .drawer__panel { max-width: none; }
  .toasts { left: var(--s4); right: var(--s4); bottom: var(--s4); align-items: stretch; }
  .toast { max-width: none; }
  /* tables become stacked records */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .table td { padding: var(--s1) 0; border: 0; display: flex; justify-content: space-between; gap: var(--s4); }
  .table td::before {
    content: attr(data-label); color: var(--text-3); font-size: 11px;
    font-family: var(--font-ui); flex: none;
  }
  .table td.num { text-align: right; }
  .table td[data-label=""]::before { display: none; }
  .table td.strong { font-weight: 400; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
