:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475467;
  --muted: #5d6679;
  --line: #e4e7ec;
  --line-2: #f0f2f5;
  --accent: #1e3a8a;
  --accent-soft: #eef2ff;
  --good: #067647;
  --good-bg: #ecfdf3;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --warn-bg: #fffaeb;
  --warn-line: #fedf89;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --font: "Inter", "Noto Sans Georgian", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
h3 { font-size: 13px; font-weight: 600; margin: 22px 0 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--line-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; margin-left: 6px; }
.strong { font-weight: 600; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }

/* App shell: sidebar + content */
.shell { display: flex; min-height: 100vh; }
.side { flex: 0 0 252px; box-sizing: border-box; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px 16px;
  display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--ink); }
.side .brand:hover { text-decoration: none; }
.side .brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.side .brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.side .brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.side-nav a, .side-nav .soon { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: #344054; font-weight: 500; }
.side-nav a span { flex: 1; }
.side-nav a:hover { background: var(--line-2); text-decoration: none; }
.side-nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-nav a svg { flex: none; }
.side-nav .dot { margin: 0 4px; }
.side-nav .soon { color: #98a2b3; cursor: default; font-weight: 400; }
.side-nav .soon .dot { background: #d0d5dd; }
.side-nav .soon span { flex: 1; }
.side-nav .soon small { font-size: 11px; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--line-2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.side-user .who { flex: 1; min-width: 0; line-height: 1.3; }
.side-user .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .signout { color: var(--muted); padding: 6px; border-radius: 8px; display: inline-flex; }
.side-user .signout:hover { background: var(--line-2); color: var(--ink); }
main.content { flex: 1 1 auto; min-width: 0; padding: 28px 36px 48px; box-sizing: border-box; max-width: 1480px; }

/* Top bar (old layout, still used by nothing but kept harmless) */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 28px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 200deg, #5B5BD6, #1A9BD7, #E8A317, #5B5BD6); }
.brand-lg { font-size: 20px; margin-bottom: 4px; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs .soon { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.tabs a:hover { background: var(--line-2); text-decoration: none; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.tabs .soon { color: #b4b8c0; cursor: default; font-weight: 400; }
.user { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.user a { color: var(--ink-2); font-weight: 500; }
.user a.on { color: var(--accent); }
.user .who { color: var(--ink); font-weight: 600; padding-left: 16px; border-left: 1px solid var(--line); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; text-align: center; line-height: 18px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; }
.tabs .dot { margin-right: 0; }
.dot-lg { width: 12px; height: 12px; margin: 0; }

/* Page head & filters */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.back { display: inline-block; font-size: 13px; margin-bottom: 6px; }
.filters { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); }
.presets { display: flex; gap: 2px; flex-wrap: wrap; }
.presets button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font: inherit; color: var(--ink-2); cursor: pointer; font-weight: 500; }
.presets button.on { font-weight: 600; }
.presets button:hover { background: var(--line-2); }
.presets button.on { background: var(--ink); color: #fff; }
.custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period { margin: 10px 2px 18px; color: var(--ink-2); font-size: 13px; }

input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn, .btn-apply { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover, .btn-apply:hover { background: var(--line-2); text-decoration: none; }
.btn-primary, .btn-apply { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover, .btn-apply:hover { background: #2f2d9a; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.link-danger { border: 0; background: none; color: var(--bad); font: inherit; cursor: pointer; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 8px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-chg { font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-chg .muted { font-weight: 400; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; background: #f2f4f7; color: #344054; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral, .pill.flat { background: #f2f4f7; color: #344054; }
.kpi-sub { font-size: 12px; margin-top: 2px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.pad { padding: 6px 0; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2-1 > .card { margin-bottom: 16px; }
.chart { overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .g { stroke: #f0f1f4; stroke-width: 1; }
.chart .g0 { stroke: #dfe1e6; stroke-width: 1; }
.chart text { font: 11.5px var(--font); fill: #8a8f99; }
.chart .ya { text-anchor: end; }
.chart .yr { text-anchor: start; }
.chart .xa { text-anchor: middle; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.on { fill: rgba(22, 24, 29, .045); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.ln, .tip i.ln { height: 2px; border-radius: 1px; width: 14px; }
.tip { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; background: #16181d; color: #fff; border-radius: 8px; padding: 9px 11px; font-size: 12px; min-width: 170px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-variant-numeric: tabular-nums; }
.tip-t { font-weight: 600; margin-bottom: 5px; }
.tip-r { display: flex; align-items: center; gap: 7px; line-height: 1.75; }
.tip-r i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-r span { flex: 1; color: #c9ccd3; }
.tip-total { border-top: 1px solid #3a3d45; margin-top: 4px; padding-top: 3px; }

.shares { list-style: none; margin: 0; padding: 0; }
.shares li { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.shares li:last-child { border-bottom: 0; }
.shares li.is-soon { padding: 7px 0; color: var(--muted); }
.share-top { display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--line-2); margin: 7px 0 4px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 3px; }
.share-sub { font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -22px -20px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 10px 16px; background: #f9fafb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th:first-child, .data td:first-child { padding-left: 22px; }
.data th:last-child, .data td:last-child { padding-right: 22px; }
.data td.wrapcell { white-space: normal; }
.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.data tbody tr:hover td { background: #f8f9fc; }
.data tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; background: #f9fafb; }
.data .num { text-align: right; }
.data td.muted { color: #c2c5cc; }
.data tr.is-off td { opacity: .55; }
.card-warn .data th, .card-warn .data tbody tr:hover td { background: transparent; }
.actions { text-align: right; }
.actions a, .actions form { display: inline-block; margin-left: 14px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--line-2); color: var(--ink-2); vertical-align: 1px; }
.tag-strong { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-flex; align-items: center; font-size: 12px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 12px; margin: 2px 4px 2px 0; white-space: nowrap; }
form.inline { display: flex; gap: 6px; align-items: center; }
form.inline select { max-width: 220px; padding: 5px 8px; }

/* Forms */
.form-card label, .auth-card label { display: block; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.form-card label input, .form-card label select, .auth-card input { display: block; width: 100%; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
label.check { display: flex !important; align-items: center; gap: 8px; color: var(--ink); font-weight: 400; }
label.check input { width: auto !important; margin: 0 !important; }
.hotel-picks { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 2px; margin: 6px 0 14px; }
.hotel-picks legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.hotel-picks[disabled] { opacity: .45; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 8px; margin-top: 6px; }
.alias-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.danger-zone { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Notices, empty, auth */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash-ok { background: #edf8f1; border-color: #c4e6d1; color: #17643a; }
.flash-err { background: #fdf0f0; border-color: #f2c9c9; color: #9b2c2c; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.empty { background: var(--surface); border: 1px dashed #d3d6dc; border-radius: var(--radius); padding: 48px 24px; text-align: center; }
.empty-title { font-weight: 600; font-size: 16px; }
.empty p { color: var(--muted); max-width: 520px; margin: 6px auto 0; }
.auth { min-height: 78vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .muted { margin: 0 0 18px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
  .user .who { display: none; }
  .side { flex-basis: 220px; }
  main.content { padding: 24px 22px 40px; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { position: static; height: auto; flex: none; width: 100%; border-right: 0; border-bottom: 1px solid var(--line);
    flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 10px 18px; padding: 12px 16px; }
  .side .brand { flex-basis: 100%; }
  .side-nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .side-title, .side-nav .soon { display: none; }
  .side-user { margin: 0 0 0 auto; border-top: 0; padding: 0; }
  .side-user .who { display: none; }
  main.content { padding: 20px 16px 40px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; gap: 10px; font-size: 13px; }
  .chart svg { min-width: 620px; }
  .legend { justify-content: flex-start; }
  .kpis, .kpis-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .table-wrap { margin: 0 -18px -18px; }
}

/* Ad accounts */
.presets a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.presets a:hover { background: var(--line-2); text-decoration: none; }
.presets a.on { background: var(--ink); color: #fff; }
.presets .count { color: var(--muted); font-weight: 400; }
.presets a.on .count { color: #c9ccd3; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk select, .data td select { max-width: 240px; padding: 5px 8px; }
.data tr.is-free td { background: var(--warn-bg); }

/* Sessions */
textarea { font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; resize: vertical; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-card label textarea { display: block; width: 100%; margin-top: 5px; }
.small-note { font-size: 12px; margin: 0 0 12px; }
.warn-text { color: #9a6700; }

/* Manual data & corrections */
.tag-warn { background: var(--warn-bg); color: #9a6700; border: 1px solid var(--warn-line); }
.data td.neg, .neg { color: var(--bad); }
.note-cell { max-width: 260px; font-size: 12px; color: var(--ink-2); }
.form-card .card-head .presets a { padding: 5px 10px; font-size: 13px; }
table.data.compact { margin: 4px 0 14px; }
.compact th, .compact td { padding: 7px 8px; }
.compact td input { width: 120px; text-align: right; padding: 5px 8px; }
.color-input { height: 38px; padding: 3px; cursor: pointer; }
.notice-bad { background: #fdf0f0; border-color: #f2c9c9; }

/* Budgets */
.bbar { position: relative; height: 8px; border-radius: 4px; background: var(--line-2); overflow: visible; min-width: 120px; }
.bbar span { display: block; height: 100%; border-radius: 4px; background: var(--good); }
.bbar i { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); border-radius: 1px; opacity: .55; }
.bbar-over span { background: var(--bad); }
.bbar-risk span { background: #e3a008; }
.bbar-under span { background: #8a8f99; }
.bbar-planned span { background: #b4b8c0; }
.bar-col { width: 200px; }
.bar-col .bbar { display: inline-block; vertical-align: middle; width: 140px; }
.bar-pct { margin-left: 8px; font-size: 12px; color: var(--ink-2); }
.btag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.btag-over { background: #fdf0f0; color: #9b2c2c; }
.btag-risk { background: var(--warn-bg); color: #9a6700; }
.btag-ok { background: #edf8f1; color: #17643a; }
.btag-under, .btag-planned { background: var(--line-2); color: var(--ink-2); }
.chip-over { border-color: #f2c9c9; background: #fdf0f0; }
.chip-risk { border-color: var(--warn-line); background: var(--warn-bg); }
.budget-list { display: grid; gap: 10px; }
.budget-line { display: grid; grid-template-columns: minmax(120px, 180px) minmax(120px, 1fr) minmax(170px, auto) 120px; align-items: center; gap: 14px; }
.budget-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.budget-nums { font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-edit td input { width: 110px; text-align: right; padding: 5px 8px; }
.budget-edit .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.year-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.year-kpis > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.year-kpis .kpi-value { font-size: 20px; }
.year-kpis .kpi-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.year-table { margin: 14px -22px 0; }
.year-table .bbar { min-width: 90px; }
.data tr.is-future td { color: var(--muted); }
.pos { color: var(--good); }
.data td.pos { color: var(--good); }
.year-note { margin: 12px 0 0; }
.presets .sep { width: 1px; background: var(--line); margin: 4px 6px; }

/* Metric explanations (app.js) */
.help { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; margin-left: 5px; border-radius: 50%;
  border: 1px solid #c2c5cc; color: #8a8f99; font: 700 9px/1 var(--font); font-style: normal; cursor: help; vertical-align: 1px; user-select: none; }
.help:hover, .help:focus { border-color: var(--accent); color: var(--accent); outline: none; }
.help-tip { position: fixed; left: 0; top: 0; z-index: 60; max-width: 300px; background: #16181d; color: #fff; padding: 8px 11px; border-radius: 8px;
  font-size: 12px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0; white-space: normal; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
@media (max-width: 1100px) { .year-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .budget-line { grid-template-columns: 1fr auto; }
  .budget-meter { grid-column: 1 / -1; order: 3; }
}
