/* Aurum Pulse — дашборд. Без сборщиков и библиотек. */
:root {
  --bg: #f6f4ef; --card: #ffffff; --line: #e6e1d6; --text: #1d1b16; --muted: #6f6a5f;
  --gold: #a87b23; --gold-soft: #f3e8cf;
  --ok: #1f7a3a; --ok-soft: #e3f3e7; --bad: #b3261e; --bad-soft: #fbe5e3;
  --warn: #8a5a00; --warn-soft: #fff1cc; --info: #1f5fa8; --info-soft: #e2edfa;
  --s-sent: #7a8699; --s-delivered: #1f5fa8; --s-read: #1f7a3a; --s-replied: #a87b23;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f; --card: #1f1d18; --line: #34312a; --text: #efece4; --muted: #a39e92;
    --gold: #d6a84a; --gold-soft: #3a311c;
    --ok: #5fc27a; --ok-soft: #1c3322; --bad: #f08a80; --bad-soft: #3d1f1c;
    --warn: #f0c060; --warn-soft: #3a3016; --info: #7fb2ee; --info-soft: #1b2a3d;
    --s-sent: #9aa5b8; --s-delivered: #7fb2ee; --s-read: #5fc27a; --s-replied: #d6a84a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ── Шапка ── */
header.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1280px; margin: 0 auto; }
.logo { font-weight: 700; font-size: 18px; white-space: nowrap; color: var(--text); }
.logo span { color: var(--gold); }
nav.main { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav.main::-webkit-scrollbar { display: none; }
nav.main a { padding: 7px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
nav.main a:hover { background: var(--bg); text-decoration: none; }
nav.main a.active { background: var(--gold-soft); color: var(--text); }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.menu-btn { display: none; }
@media (max-width: 1180px) { .who .name { display: none; } }
@media (max-width: 860px) {
  .top-row { flex-wrap: wrap; }
  nav.main { order: 3; flex-basis: 100%; }
  .who .name { display: none; }
}

.banner { padding: 8px 16px; text-align: center; font-weight: 600; font-size: 14px; }
.banner.dry { background: var(--warn-soft); color: var(--warn); }
.banner.test { background: var(--info-soft); color: var(--info); }
.banner.live { background: var(--ok-soft); color: var(--ok); }
.banner.stopped { background: var(--bad); color: #fff; }
.banner .btn { margin-left: 10px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

/* ── Кнопки и поля ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
       border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 500;
       cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn-stop { background: var(--bad); color: #fff; border: 0; font-weight: 700; letter-spacing: .02em; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
       border-radius: 9px; padding: 8px 10px; min-height: 38px; max-width: 100%; }
textarea { width: 100%; min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
label.field input:not([type=checkbox]):not([type=radio]), label.field select { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--gold-soft); color: var(--text); font-weight: 600; }

/* ── Карточки и плитки ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12.5px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.tile .sub { font-size: 12.5px; color: var(--muted); }
.tile.bad .value { color: var(--bad); }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }

/* ── Таблицы ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--card); position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
         background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.code { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; min-width: 80px; margin-top: 4px; }
.progress > div { height: 100%; background: var(--gold); border-radius: 99px; }

/* ── Воронка ── */
.funnel .step { display: grid; grid-template-columns: 120px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; }
.funnel .bar { height: 22px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.funnel .bar > div { height: 100%; border-radius: 6px; min-width: 2px; }
@media (max-width: 520px) { .funnel .step { grid-template-columns: 90px 1fr 70px; } }

/* ── График ── */
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ── Предпросмотр сообщений ── */
.bubbles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bubble { background: #dcf8c6; color: #111; border-radius: 10px 10px 10px 2px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; box-shadow: var(--shadow); }
.bubble-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
@media (prefers-color-scheme: dark) { .bubble { background: #054740; color: #e9edef; } }

.steps { counter-reset: s; }
.steps > .card > h2::before { counter-increment: s; content: counter(s) ". "; color: var(--gold); }
.report { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.report div { background: var(--bg); border-radius: 9px; padding: 8px 10px; }
.report b { display: block; font-size: 22px; }
details { margin: 6px 0; } summary { cursor: pointer; font-weight: 500; }
.alert { padding: 10px 12px; border-radius: 9px; margin: 8px 0; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.feed .item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.feed .item:last-child { border-bottom: 0; }
.msg-text { white-space: pre-wrap; background: var(--bg); padding: 10px 12px; border-radius: 9px; }

/* ── Вход ── */
.login { max-width: 360px; margin: 10vh auto; }
.login .logo { font-size: 26px; text-align: center; margin-bottom: 18px; }

/* ── Уведомления ── */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);
         padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }
#toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); max-width: min(480px, calc(100% - 32px)); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
