:root {
  --bg: #0a0c10;
  --bg-elev: #10131a;
  --card: #131720;
  --card-2: #171c27;
  --line: #232a36;
  --line-soft: #1b212c;
  --text: #eef1f6;
  --muted: #7d8696;
  --muted-2: #5a6271;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --rev: #3b82f6;
  --prof: #2dd4bf;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --r: 12px;
  --r-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: .55rem .9rem;
  font-weight: 600; font-size: 13px; cursor: pointer; transition: .14s; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06231f; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted-2); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-sm { padding: .4rem .7rem; font-size: 12px; }
.btn-block { width: 100%; }

input, select {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: .6rem .75rem; font-size: 14px; font-family: inherit;
  transition: .14s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,191,.12); }
select { cursor: pointer; }
label { display: block; font-size: 12px; color: var(--muted); margin: .65rem 0 .3rem; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(45,212,191,.10), transparent 60%),
    radial-gradient(700px 500px at 20% 110%, rgba(59,130,246,.08), transparent 55%),
    var(--bg);
  padding: 1rem;
}
.login-card {
  width: min(380px, 94vw); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 2rem 1.75rem; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 1.6rem; font-weight: 800; letter-spacing: .06em; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--muted); margin: .25rem 0 1.5rem; font-size: 13px; }
.login-card .btn { margin-top: 1.1rem; }
.form-err { color: var(--red); font-size: 12px; min-height: 16px; margin-top: .6rem; text-align: center; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-elev); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: .06em; padding: .25rem .5rem 1.25rem; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; background: transparent; border: none;
  color: var(--muted); padding: .65rem .7rem; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 500; text-align: left; font-family: inherit; transition: .12s;
}
.nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); transition: .12s; }
.nav-item:hover { color: var(--text); background: var(--card); }
.nav-item.active { color: var(--text); background: var(--card); }
.nav-item.active .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.sidebar-foot { display: flex; flex-direction: column; gap: .6rem; }
.live-row { display: flex; align-items: center; gap: .45rem; font-size: 12px; color: var(--muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,.5); } 50% { opacity: .5; box-shadow: 0 0 0 5px rgba(52,211,153,0); } }

.main { padding: 1.5rem 1.75rem 3rem; max-width: 1500px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.head h1 { font-size: 1.5rem; font-weight: 700; }
.head .muted { font-size: 13px; margin-top: .15rem; }
.period { display: inline-flex; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.period button { background: transparent; border: none; color: var(--muted); padding: .4rem .7rem; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; }
.period button.active { background: var(--card-2); color: var(--text); }

/* ---------- live strip ---------- */
.live-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.live-tile { background: linear-gradient(135deg, var(--card), var(--card-2)); border: 1px solid var(--line); border-radius: var(--r); padding: .85rem 1rem; }
.live-tile .lt-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: .4rem; }
.live-tile .lt-value { font-size: 1.4rem; font-weight: 700; margin-top: .25rem; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, rgba(45,212,191,.08), transparent 70%); }
.kpi .k-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .k-value { font-size: 1.55rem; font-weight: 700; margin-top: .35rem; letter-spacing: -.01em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: .2rem; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; gap: 1rem; }
.card-head h2 { font-size: 1rem; font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 1rem; font-size: 12px; color: var(--muted); }
.lg { display: flex; align-items: center; gap: .4rem; }
.lg::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.lg-rev::before { background: var(--rev); }
.lg-prof::before { background: var(--prof); }

/* ---------- chart ---------- */
.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis { stroke: var(--line-soft); stroke-width: 1; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; stroke-dasharray: 3 4; opacity: .5; }
.chart .lbl { fill: var(--muted-2); font-size: 10px; }
.tooltip {
  position: fixed; pointer-events: none; background: #0c0f15; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .65rem; font-size: 12px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .1s;
}
.tooltip b { color: var(--text); } .tooltip .t-row { color: var(--muted); margin-top: 2px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: .55rem .55rem; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--card-2); }
.click { cursor: pointer; }

/* ---------- plans / funnel ---------- */
.bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .7rem; }
.bar-row .br-label { width: 42px; font-size: 13px; color: var(--muted); }
.bar-track { flex: 1; height: 10px; background: var(--bg-elev); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 6px; }
.bar-row .br-val { width: 120px; text-align: right; font-size: 13px; }
.funnel-step { margin-bottom: .8rem; }
.funnel-step .fs-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: .3rem; }
.funnel-step .fs-top span:last-child { color: var(--muted); }
.fs-track { height: 8px; background: var(--bg-elev); border-radius: 5px; overflow: hidden; }
.fs-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--rev), var(--accent)); }

/* ---------- growth ---------- */
.growth { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 1.5rem; align-items: center; background: linear-gradient(135deg, var(--card), var(--card-2)); }
@media (max-width: 760px) { .growth { grid-template-columns: 1fr; } }
.growth-main { display: flex; flex-direction: column; gap: .35rem; }
.growth-num { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.growth-lbl { font-size: 14px; font-weight: 600; }
.growth-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem 1.4rem; }
@media (max-width: 560px) { .growth-metrics { grid-template-columns: 1fr; } }
.gm-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: .3rem; }
.gm-track { height: 6px; background: var(--bg-elev); border-radius: 4px; overflow: hidden; }
.gm-fill { height: 100%; border-radius: 4px; }
.gm-fill.pos { background: linear-gradient(90deg, var(--accent-2), var(--green)); }
.gm-fill.neg { background: linear-gradient(90deg, #b91c1c, var(--red)); }

/* ---------- big stat ---------- */
.big-stat { text-align: center; padding: .4rem 0 .2rem; }
.bs-num { font-size: 2.8rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.bs-lbl { color: var(--muted); font-size: 13px; margin-top: .35rem; }
.bs-ring { height: 8px; background: var(--bg-elev); border-radius: 5px; overflow: hidden; margin-top: 1rem; }
.bs-ring-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ---------- campaigns ---------- */
.camp-toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.camp-toolbar #camp-search { flex: 1; min-width: 200px; }
.camp-toolbar select { width: auto; }
.spend-mini { cursor: pointer; transition: .12s; border: 1px solid transparent; }
.spend-mini:hover { border-color: var(--accent); background: var(--card-2); }
.camp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 1rem; }
.camp { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem; transition: .14s; }
.camp:hover { border-color: #2f3a4a; }
.camp.off { opacity: .62; }
.camp-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; margin-bottom: .35rem; }
.camp-top h3 { font-size: 1.02rem; font-weight: 650; }
.badge { font-size: 10px; font-weight: 700; padding: .2rem .5rem; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.badge.on { background: rgba(52,211,153,.14); color: var(--green); }
.badge.off { background: rgba(125,134,150,.16); color: var(--muted); }
.camp-link { font-size: 11px; color: var(--rev); word-break: break-all; cursor: pointer; display: inline-block; margin-bottom: .8rem; }
.camp-link:hover { text-decoration: underline; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .6rem; }
.mini { background: var(--bg-elev); border-radius: 9px; padding: .5rem .6rem; }
.mini .m-k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mini .m-v { font-size: 1.05rem; font-weight: 650; margin-top: .15rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0 .7rem; }
.chip { font-size: 11px; background: var(--bg-elev); border: 1px solid var(--line-soft); color: var(--muted); padding: .2rem .5rem; border-radius: 999px; }
.camp-acts { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- expenses / settings forms ---------- */
.exp-form { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; align-items: end; }
.exp-form .btn { height: 40px; }
@media (max-width: 1100px) { .exp-form { grid-template-columns: 1fr 1fr; } }
.set-form label:first-child { margin-top: 0; }
.set-form .btn { margin-top: 1rem; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(4,6,10,.7); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); width: min(880px, 96vw); max-height: 88vh; overflow: auto; padding: 1.35rem; box-shadow: 0 30px 70px rgba(0,0,0,.6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; gap: 1rem; }
.modal-head h2 { font-size: 1.1rem; }
.modal-btns { display: flex; gap: .4rem; flex-shrink: 0; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #283040; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
