/* Sky Wool brand: indigo #5F72B7, yellow #F5CE14, graphite #2C2C2C.
   Light by default; dark follows the OS ("Авто") unless the user picks a
   theme, which sets <html data-theme="light|dark">. */
:root {
  color-scheme: light;
  --page: #f6f6f6;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-2: #505050;
  --muted: #8a8a8a;
  --grid: #ececec;
  --axis: #cecece;
  --border: rgba(44, 44, 44, 0.08);
  --shadow: 0 1px 2px rgba(44, 44, 44, 0.04), 0 4px 16px rgba(44, 44, 44, 0.04);
  --brand: #5f72b7;           /* series color (validated >= 3:1 on surface) */
  --brand-soft: #9faae0;      /* partial (current) month */
  --brand-wash: #eef0f8;
  --yellow: #f5ce14;
  --on-yellow: #2c2c2c;
  --chip: #efefef;
  --good: #1f7a3a;
  --bad: #d03b3b;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #17191c;
    --surface: #23272c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --grid: #30343a;
    --axis: #454a52;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: none;
    --brand: #7a8ce0;
    --brand-soft: #4a58a0;
    --brand-wash: #2b3142;
    --chip: #2f343b;
    --good: #3fbf62;
    --bad: #ef7373;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #17191c;
  --surface: #23272c;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --grid: #30343a;
  --axis: #454a52;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: none;
  --brand: #7a8ce0;
  --brand-soft: #4a58a0;
  --brand-wash: #2b3142;
  --chip: #2f343b;
  --good: #3fbf62;
  --bad: #ef7373;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 32px; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
.muted { color: var(--text-2); margin: 0; }
.small { font-size: 13px; }

/* ------------------------------------------------------------ top bar */
.brandbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.brandbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { color: var(--brand); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; letter-spacing: 0.01em; }
.brand-logo { width: 52px; height: 39px; object-fit: contain; }
.brand-logo-wrap { display: inline-flex; }
.brand-sub { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 15px; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 16px 56px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.filters { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* segmented controls: periods and theme */
.seg { display: inline-flex; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--text-2);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.periods button[aria-checked="true"] { background: var(--yellow); color: var(--on-yellow); box-shadow: none; }
.theme button { font-size: 13px; padding: 5px 10px; }
button:focus-visible, input:focus-visible, .link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.range label { display: flex; align-items: center; gap: 6px; }
.range input {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px;
}
.range.active input { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

/* --------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 12px; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.hero { background: var(--brand-wash); border-color: transparent; }
.label { color: var(--text-2); font-size: 14px; }
.hero-value { white-space: nowrap; font-size: clamp(32px, 4vw, 48px); font-weight: 650; line-height: 1.1; margin: 8px 0 6px; letter-spacing: -0.02em; }
.value { font-size: clamp(18px, 2.1vw, 24px); font-weight: 600; margin: 6px 0 2px; white-space: nowrap; }
.delta { font-size: 13px; color: var(--text-2); min-height: 1.4em; }
.delta .good { color: var(--good); font-weight: 600; }
.delta .bad { color: var(--bad); font-weight: 600; }

/* -------------------------------------------------------------- charts */
.chart-card { margin-bottom: 12px; }
.chart-head { display: flex; flex-direction: column; gap: 2px; }
.chart { position: relative; height: 260px; margin-top: 14px; }
.chart-tall { height: 300px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.value-label { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; fill: var(--text-2); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.value-label.strong { fill: var(--text); font-weight: 600; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.bar { fill: var(--brand); transition: opacity .12s; }
.bar.partial { fill: var(--brand-soft); }
.bar.dim { opacity: 0.4; }
.line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { fill: var(--brand); opacity: 0.1; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.hit { fill: transparent; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,.14);
  max-width: 260px;
}
.tooltip b { display: block; margin-bottom: 3px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-2); }
.tooltip .row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- table */
.table-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.link { font: inherit; font-size: 14px; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font-weight: 500; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-2); font-weight: 500; font-size: 13px; }
tbody tr:hover { background: var(--brand-wash); }

.notes { margin-top: 20px; max-width: 860px; }
.error { background: var(--chip); border-left: 3px solid var(--bad); padding: 10px 14px; border-radius: 6px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .filters { align-items: flex-start; }
}
@media (max-width: 420px) {
  h1 { font-size: 26px; }
  .brand-sub { display: none; }
}

/* ----------------------------------------------------------- customers */
:root { --series-2: #eb6834; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-2: #d95926; } }
:root[data-theme="dark"] { --series-2: #d95926; }

.section-title { font-size: 22px; margin: 28px 0 12px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
.bar.s2 { fill: var(--series-2); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key.s1 { background: var(--brand); }
.key.s2 { background: var(--series-2); }

.grid-cohort { grid-template-columns: 3fr 2fr; }
.cohort-wrap { margin-top: 12px; }
table.cohort { font-size: 12px; border-collapse: separate; border-spacing: 2px; }
table.cohort th, table.cohort td { border: 0; padding: 5px 6px; text-align: center; }
table.cohort th:first-child, table.cohort td:first-child { text-align: left; }
table.cohort td.cell { border-radius: 4px; min-width: 34px; }
table.cohort td.size { color: var(--text-2); text-align: right; }
table.cohort tbody tr:hover { background: transparent; }

.gap-bars { margin-top: 14px; display: grid; gap: 8px; }
.gap-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; font-size: 13px; }
.gap-row .name { color: var(--text-2); }
.gap-row .track { height: 14px; }
.gap-row .fill { height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; min-width: 2px; }
.gap-row.muted-row .fill { background: var(--axis); }
.gap-row .pct { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .tiles-3 { grid-template-columns: 1fr 1fr; }
  .grid-cohort { grid-template-columns: 1fr; }
}

/* logo: light pastel outline needs a light plate on dark backgrounds */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo { background: #ffffff; border-radius: 10px; padding: 3px 4px; width: 56px; height: 44px; }
}
:root[data-theme="dark"] .brand-logo { background: #ffffff; border-radius: 10px; padding: 3px 4px; width: 56px; height: 44px; }

/* ------------------------------------------------------------ channels */
table.channels { margin-top: 12px; }
table.channels .share-col { width: 26%; min-width: 150px; }
.share-bar { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 8px; }
.share-bar .track { height: 12px; display: block; }
.share-bar .fill { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; min-width: 2px; }
.share-bar .pct { text-align: right; }
table.channels td.delta { font-size: 13px; }
table.channels tr.muted-row .fill { background: var(--axis); }
table.channels tr.muted-row td:first-child { color: var(--text-2); }
tr.total-row td { font-weight: 600; border-bottom: 0; }
table.cohort.mix td.cell { min-width: 52px; }
table.cohort.mix td:first-child { white-space: nowrap; padding-right: 12px; }
table.cohort.mix tr.total-row td { color: var(--text-2); font-weight: 500; padding-top: 8px; }
table.channels th.share-col { text-align: left; }

/* --------------------------------------------------------------- reels */
.tiles-5 { grid-template-columns: repeat(5, 1fr); margin-bottom: 12px; }
.share-bar.rev { grid-template-columns: 1fr 84px; }
table.channels td.name-col { text-align: left; white-space: normal; min-width: 140px; max-width: 260px; color: var(--text-2); }
table.channels th:nth-child(2) { text-align: left; }
#channel-table th:nth-child(2) { text-align: left; }
td.empty { text-align: center; color: var(--muted); padding: 24px; }
@media (max-width: 900px) { .tiles-5 { grid-template-columns: 1fr 1fr; } .tiles-5 .tile:last-child { grid-column: span 2; } }
.first-touch-note { margin: -4px 0 12px; } .first-touch-note b { color: var(--text); }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; margin-left: 24px; }
.tabs a {
  color: var(--text-2); text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 8px 14px; border-radius: 10px; transition: background .15s, color .15s;
}
.tabs a:hover { color: var(--text); background: var(--chip); }
.tabs a[aria-selected="true"] { color: var(--text); background: var(--brand-wash); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
.tabs a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tab-panel > .section-title:first-child { margin-top: 0; }
@media (max-width: 700px) {
  .tabs { order: 3; width: 100%; margin: 4px 0 0; }
  .tabs a { flex: 1; text-align: center; padding: 8px 6px; }
}

/* reels funnel: 6 steps in a row on wide screens */
.tiles-6 { grid-template-columns: repeat(6, 1fr); margin-bottom: 12px; }
@media (max-width: 1100px) { .tiles-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .tiles-6 { grid-template-columns: 1fr 1fr; } }
table.channels td.name-col a { color: var(--brand); text-decoration: none; }
table.channels td.name-col a:hover { text-decoration: underline; }

/* days whose payments are not posted yet */
.dot.partial { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.pending-note { color: var(--text-2); margin-top: 4px; }

/* ------------------------------------------------------------- login */
body.locked .tab-panel, body.locked .intro, body.locked .tabs { display: none; }
.login { max-width: 420px; margin: 24px auto; }
.login form { display: grid; gap: 12px; margin-top: 14px; }
.login label { display: grid; gap: 4px; font-size: 14px; color: var(--text-2); }
.login input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 10px; padding: 9px 12px;
}
.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--yellow); color: var(--on-yellow);
}
.btn:disabled { opacity: .6; cursor: default; }
.logout { font-size: 14px; }
