:root {
  --bg: #0b0f14;
  --bg-2: #121821;
  --bg-3: #1a2230;
  --line: #243044;
  --txt: #e6edf6;
  --txt-2: #93a4bd;
  --txt-3: #5f7189;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0 0 .4rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; color: var(--txt-2); font-weight: 600; }

.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- login ---------- */
#login {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #16233a 0%, var(--bg) 60%);
}
#login .card { width: min(380px, 92vw); }
#login .logo {
  font-size: 2rem; margin-bottom: .25rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 80px; }

header.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
header.top .brand span { color: var(--accent); }

nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
nav.tabs button {
  background: transparent; border: 1px solid transparent; color: var(--txt-2);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem;
  font-family: inherit; transition: .16s;
}
nav.tabs button:hover { color: var(--txt); background: var(--bg-2); }
nav.tabs button.active {
  color: #04140a; background: var(--accent); font-weight: 650;
}

section.page { display: none; }
section.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- cards ---------- */
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.metric { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.metric .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--txt-2); }
.metric .value { font-size: 1.5rem; font-weight: 680; margin-top: 4px; }
.metric .sub { font-size: .8rem; color: var(--txt-2); margin-top: 2px; }
.metric.pos .value { color: var(--accent); }
.metric.neg .value { color: var(--danger); }

.big-value { font-size: 2.4rem; font-weight: 700; letter-spacing: -.02em; }
.delta-up { color: var(--accent); }
.delta-down { color: var(--danger); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--txt-2); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: var(--bg-3); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: .72rem; background: var(--bg-3); color: var(--txt-2); border: 1px solid var(--line);
}
.tag.auto { color: var(--accent-2); border-color: #1c4b57; }
.tag.manual { color: var(--warn); border-color: #4d3f14; }

/* ---------- forms ---------- */
label { display: block; font-size: .8rem; color: var(--txt-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
  font-family: inherit; font-size: .9rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #1f4b3a; border-color: var(--accent); }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

button.btn {
  background: var(--accent); color: #04140a; border: 0; padding: 9px 16px;
  border-radius: 9px; font-weight: 650; cursor: pointer; font-family: inherit; font-size: .9rem;
  transition: .16s;
}
button.btn:hover { filter: brightness(1.08); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.ghost { background: transparent; color: var(--txt-2); border: 1px solid var(--line); }
button.btn.ghost:hover { color: var(--txt); background: var(--bg-3); }
button.btn.sm { padding: 5px 11px; font-size: .8rem; }
button.btn.danger { background: transparent; color: var(--danger); border: 1px solid #4a2020; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(4, 8, 13, .78);
  display: flex; align-items: center; justify-content: center; z-index: 90; padding: 18px;
}
.modal { width: min(560px, 96vw); max-height: 92vh; overflow: auto; }
.modal h2 { margin-bottom: 14px; }

/* ---------- misc ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.short { height: 230px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); padding: 11px 18px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 200; font-size: .88rem;
  max-width: 90vw;
}
.toast.err { border-color: #5a2626; color: #ffc9c9; }
.toast.ok { border-color: #1f4b3a; color: #b9f5cf; }

.empty { color: var(--txt-2); font-size: .88rem; padding: 14px 0; text-align: center; }
.hint { color: var(--txt-2); font-size: .8rem; margin-top: 6px; }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--txt-2); margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.bar { height: 6px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.split { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
