:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7385;
  --line: #d9dee8;
  --primary: #3d5bdb;
  --primary-soft: #e3e8fb;
  --danger: #d64545;
  --ok: #1f9d55;
  --warn: #c98a00;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--primary); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { background: none; color: var(--text); border: none; padding: 8px 14px; border-radius: 999px; }
.tabs button.active { background: var(--primary); color: #fff; }
main { max-width: 1500px; margin: 0 auto; padding: 20px 16px 60px; }
.tab { display: none; }
.tab.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.card.highlight { border-color: var(--primary); background: var(--primary-soft); }
h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
h3 { margin: 18px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.req::first-line { }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); margin-top: 6px; }
label small { color: var(--muted); font-size: 12px; }
label.accent { color: var(--primary); font-weight: 600; }
input, select { font: inherit; color: var(--text); padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input.invalid, select.invalid, .ms.invalid .ms-box { border-color: var(--danger); }
button { font: inherit; cursor: pointer; border: none; border-radius: 999px; padding: 9px 18px; background: var(--primary); color: #fff; font-weight: 600; }
button.secondary { background: var(--primary-soft); color: var(--primary); }
button.danger { background: #fbe9e9; color: var(--danger); }
button.small { padding: 5px 12px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.grow { flex: 1; }
.filters { margin-bottom: 12px; }
.grid2, .grid3, .grid4 { display: grid; gap: 14px; margin-bottom: 12px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
@media (max-width: 800px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.capping { display: flex; align-items: end; gap: 8px; }
.capping label { flex: 1; }
.capping span { padding-bottom: 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.rate-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
@media (max-width: 800px) { .rate-row { grid-template-columns: 1fr; } }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice-grid.small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 800px) { .choice-grid, .choice-grid.small { grid-template-columns: 1fr 1fr; } }
.choice { border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); cursor: pointer; position: relative; }
.choice input { position: absolute; top: 12px; right: 12px; }
.choice span { color: var(--muted); font-size: 12px; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.tokens { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.token { background: var(--primary-soft); color: var(--primary); padding: 4px 10px; font-family: ui-monospace, monospace; font-weight: 500; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.presets button { background: #fff; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.presets button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; background: #f1f3f8; padding: 10px; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: #eef0f4; color: var(--muted); }
.badge.ok { background: #e3f5ea; color: var(--ok); }
.badge.stop { background: #fbe9e9; color: var(--danger); }
.badge.wait { background: #fdf3dc; color: var(--warn); }
.progress { width: 140px; }
.progress .bar { height: 6px; background: #eef0f4; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress .bar div { height: 100%; background: var(--primary); }
.progress.full .bar div { background: var(--danger); }
.actions { display: flex; gap: 6px; white-space: nowrap; }
.alert { padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.alert.error { background: #fbe9e9; color: var(--danger); }
.alert.ok { background: #e3f5ea; color: var(--ok); }
.alert.warn { background: #fdf3dc; color: #7a5600; }
.acc { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.acc:first-child { border-top: none; }
.balance.error-text { color: var(--danger); font-weight: 600; max-width: 520px; font-size: 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 50; max-width: 90vw; }
/* multi-select */
.ms { position: relative; }
.ms-box { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 40px; align-items: center; cursor: text; }
.ms-chip { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.ms-chip button { background: none; color: inherit; padding: 0 6px; font-weight: 700; }
.ms-box input { border: none; outline: none; padding: 4px; flex: 1; min-width: 80px; }
.ms-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: 240px; overflow-y: auto; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.ms-list div { padding: 7px 12px; cursor: pointer; }
.ms-list div:hover, .ms-list div.sel { background: var(--primary-soft); }
.ms-list div.sel::before { content: "✓ "; color: var(--primary); }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; }
/* campaigns list, Galaksion style */
.camp-list { margin-top: 8px; overflow-x: auto; }
.camp-head, .camp-row { display: grid; grid-template-columns: 24px 84px 86px 104px 104px 110px 50px minmax(200px, 1fr) 100px 120px 168px; gap: 10px; align-items: center; min-width: 1230px; }
.camp-head { padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.camp-row { padding: 12px 14px; border-radius: 14px; margin-bottom: 8px; background: #fff; border: 1px solid var(--line); }
.camp-row:nth-child(even) { background: #f6f7fb; }
.camp-row:hover { border-color: var(--primary); }
.camp-row input[type=checkbox], .camp-head input[type=checkbox] { width: 18px; height: 18px; }
.cid { color: var(--primary); font-weight: 600; display: flex; flex-direction: column; }
.cid small { color: var(--muted); font-weight: 400; font-size: 11px; }
.cname { font-weight: 500; }
.pill { display: inline-block; min-width: 96px; text-align: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; background: #e6e8ee; color: #555; }
.pill.ok { background: #2e9d4f; color: #fff; }
.pill.stop { background: #d64545; color: #fff; }
.pill.wait { background: #e0a400; color: #fff; }
.camp-row span:nth-child(5) .pill.ok { background: #4a6fdc; }
.round { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: var(--primary); color: #fff; }
.round.stop { background: #d64545; }
.round.go { background: #2e9d4f; }
.bulk { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--primary-soft); border-radius: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: #e6e8ee; color: var(--text); }
.page-num { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; align-items: center; justify-content: center; font-weight: 700; }
/* statistics table, Galaksion style */
.stats-table { border-collapse: separate; border-spacing: 0 6px; }
.stats-table th { background: #eef0f6; padding: 12px 14px; }
.stats-table th:first-child { border-radius: 12px 0 0 12px; }
.stats-table th:last-child { border-radius: 0 12px 12px 0; }
.stats-table th.sortable { cursor: pointer; user-select: none; }
.stats-table th .arrow { color: var(--muted); font-weight: 400; }
.stats-table tbody td { border-top: none; padding: 12px 14px; background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats-table tbody tr:nth-child(even) td { background: #f6f7fb; }
.stats-table tbody td:first-child { border-left: 1px solid var(--line); border-radius: 12px 0 0 12px; }
.stats-table tbody td:last-child { border-right: 1px solid var(--line); border-radius: 0 12px 12px 0; }
.stats-table tfoot td { border-top: 2px solid var(--line); padding: 14px; }
/* minimum cost per geo */
.rate-info { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; margin-top: -2px; }
.rate-info:empty { display: none; }
.geo-info { display: inline-flex; gap: 8px; align-items: center; background: #f6f7fb; border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 10px; color: var(--muted); }
.geo-info b { color: var(--text); }
.min-cost { background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 10px; font-weight: 600; }
small.error-text { color: var(--danger); font-weight: 600; }
input:disabled, select:disabled { background: #eef0f4; color: var(--muted); cursor: not-allowed; }
/* traffic forecast graph */
.forecast { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
#fc-chart { position: relative; }
.fc-svg { width: 100%; height: auto; display: block; }
.fc-grid { stroke: #dfe3ec; stroke-dasharray: 3 4; }
.fc-grid.v { stroke: #eceff5; }
.fc-axis { font-size: 12px; fill: var(--muted); }
.fc-area { fill: #8fa8d6; opacity: .75; }
.fc-line { fill: none; stroke: #4a6fb5; stroke-width: 2; }
.fc-dot { fill: #4a6fb5; }
.fc-bid { stroke: #d64545; stroke-width: 2; stroke-dasharray: 5 4; }
.fc-bid-dot { fill: #d64545; stroke: #fff; stroke-width: 2; }
.fc-bid-text { font-size: 12px; font-weight: 700; fill: #d64545; }
.fc-hover { stroke: var(--text); stroke-width: 1; }
.fc-hit { fill: transparent; cursor: crosshair; }
.fc-tip { position: absolute; transform: translate(-50%, -120%); background: var(--text); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; pointer-events: none; white-space: nowrap; }
/* recommended rates inside cohort cards */
.rec-title { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 600; font-size: 12px; color: var(--text); }
.rec-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.rec-box { border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; }
.rec-box small { display: block; font-size: 11px; color: var(--text); font-weight: 600; }
.rec-box b { font-size: 17px; }
.rec-box.min { background: #fbefd9; color: #d4890a; }
.rec-box.opt { background: #e3e8fb; color: var(--primary); }
.rec-box.high { background: #fbe4e4; color: #d64545; }
.rec-box:hover { outline: 2px solid currentColor; }

.muted.small { font-size: 12px; margin-top: 2px; }

.userbar { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.login-card h2 { margin: 0; }
.u-actions { text-align: right; white-space: nowrap; }
.u-actions button { margin-left: 6px; }

.who { display: flex; flex-direction: column; }
.who small { color: var(--muted); font-size: 11px; }

#edit-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#edit-banner.hidden { display: none; }
