:root {
  color-scheme: light;
  --ink: #1f2a22;
  --muted: #5e6a60;
  --green: #214b2b;
  --green-2: #285735;
  --gold: #bca34e;
  --gold-soft: #f1e8cb;
  --paper: #fffdf8;
  --bg: #f5f2e9;
  --line: #e4ddcc;
  --danger: #9b2c2c;
  --warn: #7a5a10;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--green-2); text-decoration: none; }
a:hover { color: var(--green); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font: 500 clamp(30px, 4.2vw, 50px)/1.08 Georgia, "Times New Roman", serif; letter-spacing: -.02em; margin-bottom: 8px; color: var(--green); }
h2 { font: 500 22px/1.25 Georgia, "Times New Roman", serif; margin: 0; color: var(--green); }

.wrap { width: min(1200px, calc(100% - 32px)); margin-inline: auto; }
.top { background: var(--green); color: #f4eddb; }
.mast { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 10px 0; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; font-weight: 650; letter-spacing: .01em; }
.brand small { display: block; font-weight: 400; font-size: 12px; opacity: .8; letter-spacing: .04em; }
.mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #f4eddb; color: var(--green); font: 600 15px/1 Georgia, serif; letter-spacing: .04em; }
.gate .mark { background: var(--green); color: #f4eddb; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a { color: #f4eddb; padding: 6px 12px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff; }
.plain { background: transparent; border: 1px solid rgba(244, 237, 219, .45); color: #f4eddb; border-radius: 8px; padding: 6px 14px; }
.plain:hover { background: rgba(255, 255, 255, .1); }

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: clamp(24px, 4vw, 44px) 0 20px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #8a7530; margin-bottom: 8px; }
.subtitle, .muted { color: var(--muted); margin: 0; }
.muted { font-size: 13px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.block { padding: 20px 22px; margin-bottom: 16px; }
.narrow { max-width: 460px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 14px; }

.primary, .secondary { border-radius: 10px; min-height: 40px; padding: 8px 18px; font-weight: 600; }
.primary { background: var(--green-2); border: 1px solid var(--green-2); color: #fff8e6; }
.primary:hover { background: var(--green); }
.secondary { background: var(--paper); border: 1px solid var(--gold); color: var(--green); }
.secondary:hover { background: var(--gold-soft); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { min-height: 40px; padding: 6px 10px; border: 1px solid #d6cdb8; border-radius: 10px; background: #fff; color: var(--ink); min-width: 0; }

.filters { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 8px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { min-height: 38px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line); background: #faf7ef; color: var(--muted); }
.pills button[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); color: var(--green); font-weight: 600; }
#period { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
#status { min-height: 1.5em; font-size: 13px; color: var(--muted); margin: 6px 2px 14px; }
#status.problem, .error { color: var(--danger); }
.error { font-size: 13px; margin: 6px 0 0; }
.error:empty { display: none; }
.preview-note { margin: 16px 0 0; padding: 10px 14px; border-radius: 10px; background: #fbe9d6; border: 1px solid #e8b98a; color: #7a3d0c; font-weight: 600; font-size: 14px; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--gold-soft); color: var(--green); font-size: 14px; }

.crumbs { margin: 20px 0 -14px; font-size: 14px; }
.funnels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; padding-bottom: 40px; align-items: start; }
#funnels-status { min-height: 1.5em; margin: 0 2px 10px; font-size: 13px; color: var(--muted); }
.funnel { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; color: var(--ink); }
a.funnel:hover { border-color: var(--gold); color: var(--ink); box-shadow: 0 6px 20px rgba(33, 75, 43, .08); }
.funnel.off { background: transparent; border-style: dashed; border-color: #d6cdb8; }
.funnel.off h2 { color: var(--muted); }
.funnel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.funnel-head .eyebrow { margin-bottom: 4px; }
.funnel h2 { font-size: 26px; }
.badge { flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); background: #faf7ef; }
.badge.on { background: var(--gold-soft); border-color: #e2d29f; color: var(--green); }
.funnel dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; margin: 0; }
.funnel dt { font-size: 12px; font-weight: 600; color: var(--muted); }
.funnel dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.funnel dd strong { display: block; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.funnel dd span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.funnel-visits { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.funnel-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.funnel-foot .go { color: var(--green-2); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles > .tile { grid-column: span 3; }
.tiles > .visit { grid-column: span 4; background: #fbf6e6; border-color: #e8dcb6; }
.tiles .tile-label { line-height: 1.3; }
.tile-note .line { display: block; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; min-height: 132px; display: flex; flex-direction: column; }
.tile:first-child { background: var(--green); border-color: var(--green); color: #f4eddb; }
.tile:first-child .tile-label, .tile:first-child .tile-note { color: #e3d9bd; }
.tile-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.tile-value { font-size: clamp(28px, 3vw, 40px); font-weight: 650; letter-spacing: -.03em; line-height: 1.05; margin: 0; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 13px; color: var(--muted); margin: auto 0 0; padding-top: 8px; font-variant-numeric: tabular-nums; }

.channels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.channel { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fcfaf4; }
.channel strong { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.channel span { font-size: 13px; color: var(--muted); }
.channel.total { background: var(--gold-soft); border-color: #e2d29f; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
th, td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
thead th { border-top: 0; font-size: 12px; font-weight: 600; color: var(--muted); background: #faf7ef; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
tbody th { font-weight: 600; }
tr.total th, tr.total td { font-weight: 700; background: #faf7ef; }
tr.subtle th, tr.subtle td { color: var(--muted); }
.na { color: var(--muted); font-size: 12px; font-weight: 500; }
.pending-source { margin: 0; color: var(--muted); }
.more { margin-top: 12px; }
.more summary { cursor: pointer; color: var(--green-2); font-weight: 600; font-size: 14px; }
.more table { margin-top: 10px; }

/* Таблица групп: одно число в ячейке, линии только между эфирами. */
.cohorts th, .cohorts td { padding: 9px 9px; font-size: 14px; }
.cohorts thead th { font-size: 12px; vertical-align: bottom; text-align: right; }
.cohorts thead tr.groups th { font-size: 13px; color: var(--green); text-align: center; border-bottom: 1px solid var(--line); }
.cohorts thead tr.groups th:first-child { text-align: left; }
.cohorts .g { border-left: 2px solid #d9cfb6; }
.cohorts td.reg { font-weight: 700; }
.cohorts td.zero { color: #716b60; }
.cohorts td.share { color: var(--green-2); font-weight: 600; }
.cohorts td.orders { font-weight: 700; color: var(--ink); }
.cohorts td.date { color: var(--muted); font-size: 13px; }
.cohorts td.date.today { color: var(--green); font-weight: 700; background: #ecdca5; }
.cohorts td.ahead { text-align: center; color: #716b60; font-size: 13px; background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(188, 163, 78, .07) 6px 12px); }
.cohorts tbody th { position: sticky; left: 0; z-index: 1; background: inherit; }
.cohorts thead tr.groups th:first-child { position: sticky; left: 0; z-index: 2; }
.cohorts tbody tr { background: var(--paper); }
.cohorts tbody tr:hover { background: var(--gold-soft); }
.unmatched th + th, .unmatched th + td, .unmatched td + td { border-left: 1px solid var(--line); }
/* Полосы по строкам — глазу проще идти по длинной строке. */
tbody tr:nth-child(even) { background: #fbf8ef; }
.cohorts tbody tr:nth-child(even) { background: #faf6ea; }
.cohorts tbody tr:nth-child(even):hover, .cohorts tbody tr:hover { background: var(--gold-soft); }
.unmatched th, .unmatched td { text-align: center; }
.unmatched th:first-child, .unmatched td:first-child { text-align: left; }
.cohort-note { margin: 10px 2px 20px; }
.sub-head { font: 500 17px/1.3 Georgia, "Times New Roman", serif; color: var(--green); margin: 0 0 4px; }
.cohort-heading { margin-top: 24px; }
.visit-days thead th { text-align: center; }
.visit-days thead th:first-child[rowspan] { text-align: left; }
.visit-days thead tr:first-child th:not(:first-child),
.visit-days thead tr:nth-child(2) th:is(:nth-child(1), :nth-child(4), :nth-child(7)),
.visit-days :is(tbody, tfoot) td:is(:nth-child(2), :nth-child(5), :nth-child(8)) { border-left: 2px solid var(--line); }
.visit-days td:is(:nth-child(4), :nth-child(7), :nth-child(8)) { font-weight: 700; color: var(--green); }
#daily-groups td.week-heading { padding: 0; text-align: left; background: #f3efe3; }
.week-current, .week-toggle { display: block; padding: 9px 12px; color: var(--green); font-size: 14px; line-height: 1.45; }
.week-current { font-weight: 650; }
.week-toggle { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; font-weight: 600; }
.week-toggle::before { display: inline-block; margin-right: 8px; content: ''; border-style: solid; border-width: 4px 0 4px 6px; border-color: transparent transparent transparent currentColor; }
.week-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.week-toggle:hover { background: var(--gold-soft); }
.week-toggle:focus-visible { outline-offset: -3px; }
.sub-head + .muted { margin-bottom: 10px; }
.sites { display: grid; gap: 8px; }
.site { border: 1px solid var(--line); border-radius: 12px; background: #fcfaf4; padding: 0 14px; }
.site summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 12px 0; font-weight: 600; color: var(--green); list-style: none; }
.site summary::-webkit-details-marker { display: none; }
.site summary::before { content: "▸"; color: var(--gold); }
.site[open] summary::before { content: "▾"; }
.site[open] summary { border-bottom: 1px solid var(--line); }
.site-count { margin-left: auto; }
.site.unknown summary { color: var(--muted); }
.site-count { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.site table { margin: 6px 0 12px; }
.site > .na { display: block; margin: 0; padding: 10px 0 12px; }

.issues { margin: 0; padding-left: 18px; color: var(--warn); }
.issues li { margin: 4px 0; }
.feeds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feed h3 { font-size: 15px; margin: 0 0 6px; }
.feed p { font-size: 13px; color: var(--muted); margin: 4px 0; }
.feed .bad { color: var(--danger); }
.notes { color: var(--muted); font-size: 13px; max-width: 900px; padding: 12px 2px 40px; }
.notes h2 { font: 600 14px/1.5 inherit; color: var(--ink); margin-bottom: 4px; }
.notes p { margin: 4px 0; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 180px; }
.stack { display: grid; gap: 6px; }
.stack .primary { margin-top: 8px; }
.secret { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--gold-soft); }
.secret p { margin: 4px 0; font-size: 14px; }
.secret-value { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.secret code { font-size: 17px; background: #fff; border: 1px solid #e2d29f; padding: 4px 10px; border-radius: 8px; user-select: all; }
.users th, .users td { text-align: left; }
.users th:last-child, .users td:last-child { text-align: right; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.actions button { min-height: 32px; padding: 4px 10px; font-size: 13px; }

.gate { min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(ellipse at 15% 10%, #ece4cc, transparent 50%), var(--bg); }
.login { width: min(420px, calc(100% - 32px)); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 30px; }
.login .brand { color: var(--green); margin-bottom: 26px; }
.login .brand small { color: var(--muted); opacity: 1; }
.login h1 { font-size: 34px; }
.login form { display: grid; gap: 6px; margin-top: 18px; }
.login .primary { margin-top: 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 16px 0 0; }

@media (max-width: 960px) {
  .tile { padding: 14px; }
  .feeds { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles > .tile { grid-column: auto; min-height: 110px; }
  .tiles > .visit { grid-column: 1 / -1; min-height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .visit .tile-label { margin: 0; }
  .visit .tile-note { grid-column: 1 / -1; }
  .channels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .block { padding: 16px; }
  .filters { display: grid; }
  #period { display: grid; grid-template-columns: 1fr 1fr; }
  #period button { grid-column: span 2; }
  th, td { padding: 9px 10px; }
  .mast { min-height: 58px; }
}
