/* Võrdle grupi koondvaade — v2 (REDESIGN.md, 23.10.2026).
   Light, calm, monochrome; one font (Inter); portal colours only as small dots and thin bars. */

/* ---------- Tokens (addendum C.2) ----------
   Every colour in this file comes from these. Light is the default; dark is set by
   <html data-theme="dark"> and only applies on screen, so printing always uses the light set.
   Contrast is checked by scripts/check-contrast.mjs (WCAG AA 4.5:1 for every text pair). */
:root {
  /* @tokens light */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --head: #f9fafb;
  --hover: #f3f4f6;
  --row-hover: #fafafb;
  --border: #e8eaee;
  --border-soft: #eff1f4;
  --text: #111827;
  --text-2: #636a77; /* #6b7280 was 4.39:1 on --hover */
  --text-3: #69707c; /* #9ca3af was 2.4–2.5:1 */
  --ink: #111827;
  --ink-hover: #1f2937;
  --on-ink: #ffffff;
  --accent: #2563eb;
  --focus-ring: rgba(37, 99, 235, 0.15);
  --pos: #15803d; /* #16a34a was 3.2–3.3:1 */
  --neg: #dc2626;
  --warn: #d97706;
  --bar: #9ca3af;
  --funnel-mail: #e5e7eb;
  --funnel-biz: #111827;
  --pill-neutral-bg: #f3f4f6;
  --pill-neutral-fg: #4b5563;
  --pill-green-bg: #dcfce7;
  --pill-green-fg: #15803d;
  --pill-amber-bg: #fef3c7;
  --pill-amber-fg: #9a5b04; /* #a16207 was 4.42:1 */
  --pill-orange-bg: #ffedd5;
  --pill-orange-fg: #c2410c;
  --pill-red-bg: #fee2e2;
  --pill-red-fg: #b91c1c;
  --pill-blue-bg: #dbeafe;
  --pill-blue-fg: #1d4ed8;
  --border-bad: #fecaca;
  --border-warn: #fde68a;
  --backdrop: rgba(17, 24, 39, 0.28);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.14);
  --shadow-layer: 0 16px 48px rgba(16, 24, 40, 0.18);
  /* Portal identity — dots and thin bars only, always next to the name. */
  --furo: #192744;
  --vordle: #025ca6;
  --elektrihind: #00b386;
  /* @end */

  --radius: 14px;
  --radius-sm: 8px;
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 300ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --gap: 24px;
  --pad: 20px;
  --sidebar: 232px;
  --rail: 64px;
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

@media screen {
  :root[data-theme='dark'] {
    /* @tokens dark */
    --bg: #0f1115;
    --surface: #16191f;
    --head: #1b1f26;
    --hover: #1e222a;
    --row-hover: #1e222a;
    --border: #262a33;
    --border-soft: #20242c;
    --text: #f3f4f6;
    --text-2: #9ca3af;
    --text-3: #818896; /* #6b7280 was 3.4–3.9:1 */
    --ink: #f3f4f6;
    --ink-hover: #e5e7eb;
    --on-ink: #111827;
    --accent: #60a5fa;
    --focus-ring: rgba(96, 165, 250, 0.25);
    --pos: #22c55e;
    --neg: #f87171;
    --warn: #f59e0b;
    --bar: #4b5563;
    --funnel-mail: #2a2f38;
    --funnel-biz: #e5e7eb;
    --pill-neutral-bg: rgba(255, 255, 255, 0.08);
    --pill-neutral-fg: #d1d5db;
    --pill-green-bg: rgba(34, 197, 94, 0.16);
    --pill-green-fg: #4ade80;
    --pill-amber-bg: rgba(245, 158, 11, 0.16);
    --pill-amber-fg: #fbbf24;
    --pill-orange-bg: rgba(249, 115, 22, 0.16);
    --pill-orange-fg: #fb923c;
    --pill-red-bg: rgba(248, 113, 113, 0.16);
    --pill-red-fg: #fca5a5;
    --pill-blue-bg: rgba(96, 165, 250, 0.16);
    --pill-blue-fg: #93c5fd;
    --border-bad: rgba(248, 113, 113, 0.45);
    --border-warn: rgba(245, 158, 11, 0.45);
    --backdrop: rgba(0, 0, 0, 0.55);
    --shadow: none;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-layer: 0 16px 48px rgba(0, 0, 0, 0.55);
    /* The light-mode brand primaries are too dark on a dark card: each brand's secondary colour. */
    --furo: #47abff;
    --vordle: #22b8f0;
    --elektrihind: #00cc99;
    /* @end */
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num, td, .kpi__value, .funnel__value { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { display: inline-flex; flex: none; color: inherit; }
.icon svg { display: block; }
.note { color: var(--text-2); font-size: 12.5px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.app.is-collapsed { grid-template-columns: var(--rail) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; min-height: 44px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; letter-spacing: -0.02em; }
.sidebar__name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.sidebar__name small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav__item {
  position: relative; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13.5px; transition: background 120ms, color 120ms;
}
.nav__item:hover { background: var(--hover); color: var(--text); }
button.nav__item { border: 0; background: transparent; width: 100%; cursor: pointer; text-align: left; }
.nav-scrim { display: none; }
.nav__item[aria-current='page'] { background: var(--hover); color: var(--text); }
.nav__item[aria-current='page']::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ink); }
.nav__icon { width: 18px; display: grid; place-items: center; flex: none; }
.nav__icon .dot { width: 9px; height: 9px; }
.sidebar__spacer { flex: 1; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; margin-top: 12px; min-width: 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--hover); color: var(--text); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; flex: none; }
.sidebar__email { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sidebar__role { font-size: 11.5px; color: var(--text-2); }
.sidebar__collapse { margin-top: 8px; }
.app.is-collapsed .nav__text, .app.is-collapsed .nav__label, .app.is-collapsed .sidebar__name, .app.is-collapsed .sidebar__who { display: none; }
.app.is-collapsed .nav__item { justify-content: center; padding: 0; }
.app.is-collapsed .sidebar__brand { justify-content: center; padding-inline: 0; }
.app.is-collapsed .sidebar__user { justify-content: center; padding: 8px; border: 0; }
.app.is-collapsed .nav__divider { margin: 10px 8px; }
.nav__divider { height: 1px; background: var(--border); margin: 10px 4px 0; }

.topbar { display: none; }
.main { min-width: 0; padding: 28px 40px 64px; }
.page { max-width: 1280px; margin: 0 auto; }

/* ---------- Header ---------- */
.header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.header__title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.header__sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.header__controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { position: relative; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.segmented button { position: relative; z-index: 1; border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: color var(--dur) var(--ease); white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'] { color: var(--on-ink); }
/* Before the indicator is placed (first frame), the active button carries the fill itself. */
.segmented:not(.is-ready) button[aria-pressed='true'] { background: var(--ink); }
.segmented__ind { position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 999px; background: var(--ink); transition: transform var(--dur) var(--ease), width var(--dur) var(--ease); }
.segmented:not(.is-ready) .segmented__ind { opacity: 0; }

/* Range control (addendum A.1) */
.range { display: flex; align-items: center; gap: 8px; }
.range__menu { position: relative; }
.range__caret { color: var(--text-3); font-size: 11px; }
.range__pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: grid; grid-template-columns: 190px 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); overflow: hidden; }
.range__pop[hidden] { display: none; }
.range__presets { display: grid; align-content: start; padding: 8px; border-right: 1px solid var(--border-soft); }
.range__preset { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.range__preset:hover { background: var(--hover); }
.range__preset[aria-pressed='true'] { background: var(--ink); color: var(--on-ink); }
.range__custom { display: grid; gap: 10px; align-content: start; padding: 14px; }
.range__custom .form-error { min-height: 0; margin: 0; }
.granular { margin-top: -8px; }
.select { appearance: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; border: 1px solid var(--border); border-radius: 999px; padding: 7px 30px 7px 14px; cursor: pointer; }
.button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text); text-decoration: none; transition: background 120ms; white-space: nowrap; }
.button:hover { background: var(--hover); }
.button--dark { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.button--dark:hover { background: var(--ink-hover); }
.button--small { padding: 5px 11px; font-size: 12.5px; }
.button[disabled] { opacity: 0.55; cursor: progress; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); transition: background 120ms; flex: none; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.updated { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }

/* ---------- Layout helpers ---------- */
.stack { display: grid; gap: var(--gap); }
.row { display: grid; gap: var(--gap); }
.row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row--2-60 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--pad); min-width: 0; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__title { font-size: 14px; font-weight: 600; }
.card__sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.card__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.card__foot { color: var(--text-3); font-size: 12.5px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.empty { color: var(--text-2); font-size: 13px; padding: 4px 0; }

/* ---------- KPI card ---------- */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-3); }
.kpi__label { font-size: 12.5px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.kpi__value { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; }
.kpi__value small { font-size: 15px; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-left: 4px; }
.kpi__delta { font-size: 12.5px; font-weight: 500; min-height: 18px; }
.kpi__vs { color: var(--text-3); font-weight: 400; }
.kpi__sub { font-size: 12.5px; color: var(--text-2); }
.delta--pos { color: var(--pos); }
.delta--neg { color: var(--neg); }
.delta--neutral { color: var(--text-2); }
.tip { display: inline-flex; color: var(--text-3); cursor: help; }
.tip:hover, .tip:focus-visible { color: var(--text-2); }

/* ---------- Portal cards (Ülevaade) ---------- */
.portal { display: flex; flex-direction: column; gap: 14px; }
.portal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.portal__name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.portal__open { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); text-decoration: none; }
.portal__open:hover { color: var(--text); }
.portal__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.portal__main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.portal__main strong { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.portal__main span { color: var(--text-2); font-size: 13px; }
.portal__secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.mini__label { font-size: 12px; color: var(--text-2); }
.mini__value { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.mini__sub { font-size: 11.5px; color: var(--text-3); }
.portal__foot { font-size: 12.5px; color: var(--text-3); }
.meter { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--ink); border-radius: 3px; }

/* ---------- Dots and pills ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--furo { background: var(--furo); }
.dot--vordle { background: var(--vordle); }
.dot--elektrihind { background: var(--elektrihind); }
.dot--kindlustushind { background: transparent; box-shadow: inset 0 0 0 2px var(--elektrihind); }
.dot--none { background: var(--text-3); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.pill--neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-fg); }
.pill--green { background: var(--pill-green-bg); color: var(--pill-green-fg); }
.pill--amber { background: var(--pill-amber-bg); color: var(--pill-amber-fg); }
.pill--orange { background: var(--pill-orange-bg); color: var(--pill-orange-fg); }
.pill--red { background: var(--pill-red-bg); color: var(--pill-red-fg); }
.pill--blue { background: var(--pill-blue-bg); color: var(--pill-blue-fg); }
.pill--dark { background: var(--ink); color: var(--on-ink); }

/* ---------- Funnel ---------- */
.funnel { display: grid; gap: 12px; }
.funnel__chart { border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; }
.funnel__cols { display: grid; }
.funnel__col { padding: 14px 16px 10px; border-left: 1px solid var(--border-soft); min-width: 0; }
.funnel__col:first-child { border-left: 0; }
.funnel__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: inline-flex; gap: 4px; align-items: center; }
.funnel__value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.funnel__sub { font-size: 12px; color: var(--text-3); min-height: 18px; }
.funnel__art { position: relative; height: 140px; }
.funnel__svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.funnel__grid { position: absolute; inset: 0; display: grid; pointer-events: none; }
.funnel__grid span { border-left: 1px solid var(--border-soft); }
.funnel__grid span:first-child { border-left: 0; }
.funnel__shape--mail { fill: var(--funnel-mail); }
.funnel__shape--biz { fill: var(--funnel-biz); }
.funnel__foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.funnel__list { display: none; list-style: none; margin: 0; padding: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--pad)); }
.table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table th, .table td { padding: 0 14px; height: 44px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border-soft); }
.table th:first-child, .table td:first-child { padding-left: var(--pad); }
.table th:last-child, .table td:last-child { padding-right: var(--pad); }
.table th { background: var(--head); font-size: 12px; font-weight: 500; color: var(--text-2); height: 38px; border-bottom: 1px solid var(--border); }
.table th.left, .table td.left { text-align: left; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; background: var(--head); }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: var(--row-hover); }
.table td.empty { color: var(--text-2); }
.table td.muted { color: var(--text-3); }
.table .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table th.sticky, .table tfoot .sticky { background: var(--head); }
.th-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.th-sort .icon { color: var(--text-3); }
th[aria-sort='ascending'] .th-sort, th[aria-sort='descending'] .th-sort { color: var(--text); }
.cell-title { display: flex; align-items: center; gap: 10px; min-width: 260px; white-space: normal; }
.table .cell-title__main { white-space: nowrap; }
.cell-title__text { display: flex; flex-direction: column; min-width: 0; }
.cell-title__main { font-weight: 500; color: var(--text); }
.cell-title__sub { font-size: 12px; color: var(--text-3); }
.split { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.split small { color: var(--text-3); font-size: 11.5px; }

/* ---------- Filters inside cards ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 0 12px; background: var(--surface); color: var(--text-3); }
.search input { border: 0; outline: 0; font: inherit; font-size: 13px; padding: 7px 0; width: 180px; color: var(--text); background: transparent; }

/* ---------- Lists (next sends, latest campaigns, schedule) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border-soft); }
.list__item:first-child { border-top: 0; padding-top: 0; }
.list__date { font-size: 12.5px; color: var(--text-2); line-height: 1.3; }
.list__date strong { display: block; color: var(--text); font-weight: 500; font-size: 13px; }
.list__main { display: flex; flex-direction: column; min-width: 0; }
.list__title { display: flex; align-items: center; gap: 8px; font-weight: 500; min-width: 0; }
.list__title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__sub { font-size: 12px; color: var(--text-3); padding-left: 16px; }
.list__meta { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.list__item.is-clickable { cursor: pointer; border-radius: 8px; }
.list__item.is-clickable:hover { background: var(--row-hover); }
.card__more { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); text-decoration: none; }
.card__more:hover { color: var(--text); }

.week { display: grid; gap: 0; }
.week + .week { margin-top: 20px; }
.week__head { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); padding: 0 0 8px; border-bottom: 1px solid var(--border); }
.sched { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); align-items: start; }
.sched__date { font-size: 13px; font-weight: 500; line-height: 1.3; }
.sched__date span { display: block; font-size: 12px; color: var(--text-2); font-weight: 400; }
.sched__title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sched__meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.sched__desc { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.sched__reply { margin-top: 8px; font-size: 12.5px; background: var(--head); border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px; }
.sched__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.sched.is-past { opacity: 0.7; }

/* ---------- Drawer and modal ---------- */
.has-layer { overflow: hidden; }
.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 50; display: flex; }
.drawer-backdrop { justify-content: flex-end; }
.modal-backdrop { align-items: center; justify-content: center; padding: 16px; }
.drawer { width: min(480px, 100vw); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-layer); }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); background: var(--surface); border-radius: var(--radius); display: flex; flex-direction: column; box-shadow: var(--shadow-layer); }
.drawer__head, .modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 14px; border-bottom: 1px solid var(--border-soft); }
.drawer__title, .modal__title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.drawer__sub, .modal__sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.drawer__body, .modal__body { padding: 18px 20px 24px; overflow-y: auto; display: grid; gap: 20px; align-content: start; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.subject { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: start; padding: 9px 12px; border-radius: 10px; background: var(--head); border: 1px solid var(--border-soft); font-size: 13px; }
.subject + .subject { margin-top: 6px; }
.subject__tag { font-weight: 600; color: var(--text-2); }
.prose { font-size: 13px; color: var(--text); white-space: pre-wrap; background: var(--head); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field textarea, .field input { font: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); background: var(--surface); resize: vertical; }
.field textarea:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.form-error { color: var(--neg); font-size: 12.5px; min-height: 18px; }

/* Mini funnel in the drawer */
.mini-funnel { display: grid; gap: 8px; }
.mini-funnel__row { display: grid; grid-template-columns: 120px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.mini-funnel__bar { height: 8px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.mini-funnel__bar span { display: block; height: 100%; background: var(--bar); border-radius: 4px; }
.mini-funnel__row.is-biz .mini-funnel__bar span { background: var(--funnel-biz); }
.mini-funnel__val { text-align: right; font-variant-numeric: tabular-nums; }
.mini-funnel__val small { color: var(--text-3); margin-left: 6px; }

/* ---------- Similar campaigns (drawer) ---------- */
.similar { display: grid; gap: 10px; }
.table--compact { table-layout: fixed; }
.table--compact th, .table--compact td { height: 36px; font-size: 12.5px; padding: 0 8px; }
.table--compact th { white-space: normal; line-height: 1.25; height: auto; padding-top: 8px; padding-bottom: 8px; }
.table--compact th:first-child { width: 34%; }
.table--compact td:first-child { white-space: normal; }
.table--compact tr.is-primary td { font-weight: 600; }
.table--compact tr.is-muted td { color: var(--text-2); }
.similar .table-wrap { margin: 0; border: 1px solid var(--border-soft); border-radius: 10px; }
.similar .table th:first-child, .similar .table td:first-child { padding-left: 12px; }
.similar .table th:last-child, .similar .table td:last-child { padding-right: 12px; }
.similar__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.similar__item { border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; }
.similar__top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.similar__date { font-weight: 500; font-variant-numeric: tabular-nums; }
.similar__subject { font-size: 13px; font-weight: 500; }
.similar__nums { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.similar__reasons { display: flex; gap: 4px; flex-wrap: wrap; }
.expect { font-size: 13px; background: var(--head); border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px; }
.sched__expect { color: var(--text-2); }
.vs-similar { font-size: 11px; }

/* ---------- Internal (limits, sync) ---------- */
.limits { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.limits--compact { grid-template-columns: 1fr; gap: 10px; }
.limit { display: grid; gap: 6px; }
.limits--compact .limit { grid-template-columns: 150px 1fr 64px; align-items: center; gap: 10px; }
.limits--compact .limit__head { display: contents; }
.limits--compact .limit__label { order: 0; }
.limits--compact .limit__track { order: 1; }
.limits--compact .limit__value { order: 2; text-align: right; font-size: 14px; }
.limits--compact .limit__foot { display: none; }
.limit__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.limit__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.limit__value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.limit__track { position: relative; height: 6px; border-radius: 3px; background: var(--hover); }
.limit__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--text-3); }
.limit__fill--ok { background: var(--pos); }
.limit__fill--warn { background: var(--warn); }
.limit__fill--bad { background: var(--neg); }
.limit__marker { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--neg); border-radius: 1px; }
.limit__marker--half { background: var(--warn); opacity: 0.7; }
.limit__foot { font-size: 11.5px; color: var(--text-3); }
.card--bad { border-color: var(--border-bad); }
.card--warn { border-color: var(--border-warn); }
.problems { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.pair { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.25; }
.pair__base { color: var(--text-3); font-size: 12px; }
.pair__own { font-weight: 600; }
.pair__diff { font-weight: 400; font-size: 11.5px; color: var(--text-2); margin-left: 4px; }

/* ---------- State ---------- */
.state { padding: 64px 0; text-align: center; color: var(--text-2); }
.loading .page { opacity: 0.5; }
.refreshing .page { opacity: 0.6; transition: opacity 120ms; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; background: var(--bg); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card { width: min(400px, 100%); padding: 32px 28px 26px; display: grid; gap: 6px; }
.login__dots { display: flex; gap: 6px; margin-bottom: 12px; }
.login__card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
.login__sub { color: var(--text-2); font-size: 13px; margin: 0 0 18px; }
.login__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.login__label--next { margin-top: 10px; }
.login__input { font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; width: 100%; }
.login__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.login__button { margin-top: 14px; width: 100%; justify-content: center; padding: 11px 14px; font-size: 14px; border-radius: 10px; }
.login__error { color: var(--neg); font-size: 13px; min-height: 20px; margin: 8px 0 0; }
.login__info { color: var(--text-2); font-size: 13px; margin: 0; background: var(--head); border: 1px solid var(--border-soft); border-radius: 10px; padding: 8px 10px; }

/* ---------- Motion (addendum C.3–C.6) ----------
   Only opacity and transform animate (plus colours during a theme switch). Motion only answers
   something the user did; prefers-reduced-motion turns all of it off (bottom of this section). */
.content { view-transition-name: page; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.content.is-leaving { opacity: 0; transition-duration: var(--dur-fast); }
.content.is-entering { opacity: 0; transform: translateY(8px); transition: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: vt-out var(--dur-fast) var(--ease) both; }
::view-transition-new(page) { animation: vt-in var(--dur) var(--ease) both; }
html.vt-theme::view-transition-old(root), html.vt-theme::view-transition-old(page) { animation: vt-out 250ms var(--ease) both; }
html.vt-theme::view-transition-new(root), html.vt-theme::view-transition-new(page) { animation: vt-fade 250ms var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes vt-fade { from { opacity: 0; } }
/* Fallback theme switch: colour transitions on every element for 250 ms only — never left on. */
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), fill var(--dur) var(--ease), stroke var(--dur) var(--ease) !important;
}
/* In-page swaps (range, product, filter): new table bodies and secondary lines fade in. */
.is-swapping .table tbody, .is-swapping .table tfoot, .is-swapping .kpi__delta, .is-swapping .kpi__sub,
.is-swapping .funnel__sub, .is-swapping .list, .is-swapping .week, .is-swapping .portal__secondary, .is-swapping .mini__sub {
  animation: fade-in 150ms var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } }
/* Drawer slides in from the right (220 ms) over a fading backdrop; the modal fades and scales up (180 ms). */
.drawer-backdrop, .modal-backdrop { opacity: 0; transition: opacity 220ms var(--ease); }
.drawer-backdrop.is-open, .modal-backdrop.is-open { opacity: 1; }
.drawer { transform: translateX(100%); transition: transform 220ms var(--ease); }
.is-open > .drawer { transform: none; }
.modal-backdrop { transition-duration: 180ms; }
.modal { opacity: 0; transform: scale(0.98); transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
.is-open > .modal { opacity: 1; transform: none; }
/* Sidebar collapse: width animates; labels fade out first and back in afterwards. */
.app { transition: grid-template-columns var(--dur) var(--ease); }
.nav__text, .nav__label, .sidebar__name, .sidebar__who { transition: opacity var(--dur-fast) var(--ease); }
.app.labels-out .nav__text, .app.labels-out .nav__label, .app.labels-out .sidebar__name, .app.labels-out .sidebar__who { opacity: 0; }
.range__pop { animation: fade-in var(--dur-fast) var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
  .app { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .app .nav__text, .app .nav__label, .app .sidebar__name, .app .sidebar__who { display: none; }
  .app .nav__item { justify-content: center; padding: 0; }
  .app .sidebar__brand { justify-content: center; padding-inline: 0; }
  .app .sidebar__user { justify-content: center; padding: 8px; border: 0; }
  .sidebar__collapse { display: none; }
  .main { padding: 24px 28px 56px; }
  .kpis { grid-template-columns: repeat(min(var(--cols, 5), 3), minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  :root { --gap: 16px; --pad: 16px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.nav-open .sidebar {
    display: flex; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60; box-shadow: var(--shadow-layer);
  }
  .app.nav-open .nav__text, .app.nav-open .nav__label, .app.nav-open .sidebar__name, .app.nav-open .sidebar__who { display: initial; }
  .app.nav-open .nav__item { justify-content: flex-start; padding: 0 10px; }
  .app.nav-open .sidebar__brand { justify-content: flex-start; padding-inline: 8px; }
  .app.nav-open .sidebar__user { justify-content: flex-start; padding: 10px; border: 1px solid var(--border); }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: var(--backdrop); z-index: 55; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
  .main { padding: 18px 16px 48px; }
  .header__title { font-size: 21px; }
  .header__controls { width: 100%; }
  .card__actions .segmented { width: 100%; }
  .card__actions .segmented button { flex: 1; padding: 6px 8px; }
  .range__quick { display: none; }
  .range, .range__menu { flex: 1; }
  .range__button { width: 100%; justify-content: center; }
  .range__pop { position: fixed; left: 0; right: 0; bottom: 0; top: auto; grid-template-columns: 1fr 1fr; border-radius: 16px 16px 0 0; max-height: 85vh; overflow-y: auto; z-index: 70; }
  .row--3, .row--2-60 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 24px; }
  .funnel__chart { display: none; }
  .funnel__list { display: grid; gap: 12px; }
  .funnel__row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
  .funnel__bar { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; margin-top: 4px; }
  .funnel__fill { display: block; height: 100%; border-radius: 3px; background: var(--bar); }
  .funnel__fill--biz { background: var(--funnel-biz); }
  .list__item { grid-template-columns: 1fr; gap: 4px; }
  .list__meta { justify-content: flex-start; }
  .sched { grid-template-columns: 1fr; gap: 6px; }
  .sched__actions { justify-content: flex-start; }
  .limits { grid-template-columns: 1fr; }
  .limits--compact .limit { grid-template-columns: 120px 1fr 56px; }
  .mini-funnel__row { grid-template-columns: 100px 1fr 92px; }
  .search input { width: 120px; }
  .card__head { flex-wrap: wrap; }
}

/* ---------- Print (A4) ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  :root { --gap: 12px; --pad: 12px; }
  body { background: var(--surface); font-size: 10.5px; }
  .app { display: block; }
  .sidebar, .topbar, .header__controls, .button, .icon-button, .card__actions, .card__more, .portal__open, .filters, .nav-scrim { display: none !important; }
  .main { padding: 0; }
  .header { margin-bottom: 12px; }
  .header__title { font-size: 18px; }
  .card { box-shadow: none; break-inside: avoid; }
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .kpi__value { font-size: 20px; }
  .row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row--2-60 { grid-template-columns: 3fr 2fr; }
  .table-wrap { overflow: visible; margin: 0; }
  .table { font-size: 9px; }
  .table th, .table td { height: 26px; padding: 0 5px; }
  .table .sticky { position: static; }
  .funnel__art { height: 90px; }
  .funnel__value { font-size: 16px; }
  .meter, .meter__fill, .funnel__svg, .dot, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* A4 is narrower than the phone breakpoint: keep the desktop structure on paper. */
  :root, html { background: var(--surface); }
  .card { padding: 12px; border-radius: 10px; }
  .card__head { margin-bottom: 8px; }
  .kpis { grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); }
  .kpi { padding: 10px 12px; gap: 2px; }
  .portal { gap: 8px; }
  .portal__main strong { font-size: 24px; }
  .portal__secondary { padding-top: 8px; gap: 8px; }
  .mini__value { font-size: 14px; }
  .list__item { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 8px; padding: 5px 0; }
  .list__date, .list__date strong { font-size: 10px; }
  .list__meta { justify-content: flex-end; }
  .funnel__chart { display: block; }
  .funnel__list { display: none; }
  .funnel__col { padding: 8px 10px 6px; }
  .sched { grid-template-columns: 70px minmax(0, 1fr) auto; padding: 8px 0; }
  .cell-title__sub, .split small { font-size: 8px; }
  .th-sort .icon { display: none; }
}
