:root {
  --ink: #0e0d0c;
  --panel: #151311;
  --panel-deep: #1c1916;
  --line: #2b2621;
  --cream: #efe6d8;
  --muted: #968a79;
  --gold: #c9a15a;
  --gold-2: #ab8e53;
  --profit: #2f9e5f;
  --loss: #e0564b;
  --caution: #d0a03c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
}

#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }

h1, h2, h3 { margin: 0; font-weight: 600; }

a { color: inherit; }

/* ── Вход ──────────────────────────────────────────────────────────────── */

.login {
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.login .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}

.login .brand img { width: 40px; height: 40px; border-radius: 10px; }
.login .brand span { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.field input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
}
.field input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

.btn {
  background: var(--gold);
  color: var(--panel-deep);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.error {
  background: rgba(224, 86, 75, 0.12);
  border: 1px solid var(--loss);
  color: var(--loss);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── Дашборд ───────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 18px;
}
.topbar .title { display: flex; align-items: center; gap: 8px; }
.topbar .title img { width: 26px; height: 26px; border-radius: 7px; }
.topbar .title span { font-size: 17px; font-weight: 700; }
.topbar .updated { font-size: 11px; color: var(--muted); }
.topbar .actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
}
.icon-btn:active { background: var(--panel); }
.icon-btn svg { width: 18px; height: 18px; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.gauges { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
.gauge-cell { text-align: center; }
.gauge { width: 100%; max-width: 280px; height: auto; display: block; margin: 0 auto; }
.gauge-sub { font-size: 12px; color: var(--muted); margin-top: -6px; }

@media (min-width: 460px) {
  .gauges { grid-template-columns: 1fr 1fr 1fr; gap: 0; }
}

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.kpi {
  background: var(--panel-deep);
  border-radius: 12px;
  padding: 10px 12px;
}
.kpi .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi .val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.kpi .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.bar-track {
  height: 6px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin-top: 6px;
}
.bar-fill { height: 100%; border-radius: 4px; }

.hist { display: flex; align-items: flex-end; gap: 6px; height: 72px; margin-top: 14px; }
.hist .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hist .bars { width: 100%; display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.hist .bars > div { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.hist .m { font-size: 9px; color: var(--muted); }

.pulse-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.pulse-row .seg-label { width: 74px; font-size: 11px; color: var(--muted); flex-shrink: 0; }
.pulse-row .seg-track { flex: 1; height: 16px; background: var(--panel-deep); border-radius: 6px; overflow: hidden; }
.pulse-row .seg-fill { height: 100%; border-radius: 6px; }
.pulse-row .seg-count { width: 32px; text-align: right; font-size: 13px; font-weight: 700; flex-shrink: 0; }

.flow-summary { display: flex; gap: 14px; margin-bottom: 12px; }
.flow-summary .fs { flex: 1; text-align: center; }
.flow-summary .fs .n { font-size: 18px; font-weight: 700; }
.flow-summary .fs .l { font-size: 10px; color: var(--muted); text-transform: uppercase; }

.sparkline { width: 100%; height: 48px; display: block; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 10px;
}

.footer-link {
  text-align: center;
  margin-top: 10px;
}
.footer-link button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

@media (min-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr 1fr; }
}
