:root {
  --bg: #0f1115; --panel: #171a21; --line: #262b36; --text: #e6e8ee; --muted: #8b93a7;
  --accent: #f0b90b; --ok: #26a69a; --bad: #ef5350; --warn: #f5a623;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }
button { background: var(--accent); color: #111; border: 0; border-radius: 8px; padding: 10px 14px;
  font-weight: 600; cursor: pointer; }
button.link { background: none; color: var(--muted); padding: 6px; font-weight: 400; }
button.icon { background: none; color: var(--text); font-size: 20px; padding: 4px 10px; }
button.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost.on { border-color: var(--accent); color: var(--accent); }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font-size: 15px; width: 100%; }
label { display: block; margin: 10px 0; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow-x: auto; min-width: 0; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; }
.login h1 { margin: 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.sim { color: var(--ok); border-color: var(--ok); }
#logout { margin-left: auto; }
#app { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto 1fr auto; min-height: 100vh; }
.top { grid-column: 1 / -1; }
.nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; border-right: 1px solid var(--line); }
.nav a { color: var(--text); text-decoration: none; padding: 9px 10px; border-radius: 8px; }
.nav a.active { background: var(--panel); color: var(--accent); }
main { padding: 16px; min-width: 0; }
.foot { grid-column: 1 / -1; padding: 8px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
#menu-btn { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.row > select, .row > input { width: auto; min-width: 140px; }
.tfs { display: flex; gap: 4px; flex-wrap: wrap; }
.tfs button { padding: 7px 10px; }
.chart { height: 62vh; min-height: 320px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.source { font-size: 13px; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--bad); }
.dot.ok { background: var(--ok); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 0 0 8px; font-size: 16px; }

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  #menu-btn { display: inline-block; }
  .nav { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav.open { display: flex; }
  main { padding: 12px; }
  .row > select, .row > input { flex: 1 1 140px; }
  .chart { height: 55vh; }
}
