:root {
  --bg: #f4f6f9; --card: #ffffff; --text: #1b2230; --muted: #6a7488; --line: #e3e7ee;
  --primary: #2f5fe0; --pos: #1f9d6b; --neg: #d64545; --warn: #d98a1c; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1318; --card: #181d25; --text: #e6e9ef; --muted: #8d97aa; --line: #2a3140; --primary: #6c8cff; --pos: #3cc08c; --neg: #ef6a6a; --warn: #e5a043; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }

.top { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.top nav a { padding: .3rem .65rem; border-radius: 8px; color: var(--muted); }
.top nav a.active, .top nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.top-right { display: flex; gap: .75rem; align-items: center; }
.top-right form { margin: 0; }

main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
@media (max-width: 480px) { .grid.two { grid-template-columns: 1fr; } }
.kpi .card { margin: 0; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .45rem; vertical-align: baseline; }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--bg); border: 1px solid var(--line); }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input, select, button, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; }
input[type=color] { padding: 0; width: 2.4rem; height: 2rem; }
input[type=checkbox] { width: auto; }
button, .btn { cursor: pointer; background: var(--primary); color: #fff; border-color: var(--primary); display: inline-block; text-decoration: none; }
button.secondary, .btn.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
button.danger { background: var(--neg); border-color: var(--neg); }
button.link { background: none; border: 0; color: var(--muted); padding: .2rem; }
button.link:hover { color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters input[type=search] { min-width: 200px; }
.form-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.form-row label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-color: var(--pos); } .flash.err { border-color: var(--neg); }
.pager { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.month-nav { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.month-nav strong { min-width: 9rem; text-align: center; font-size: 1.05rem; }
.bar { height: .5rem; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; }
input[type=range] { width: 100%; padding: 0; accent-color: var(--primary); }
.login { max-width: 360px; margin: 12vh auto; }
.saved-flash { outline: 2px solid var(--pos); }
