/* Панель Wexeros — системные шрифты, никаких внешних CDN (грабля РФ).
   Тема: тёмная по умолчанию, светлая через prefers-color-scheme (API темы у MAX нет). */

:root {
  --bg: #101216;
  --bg-card: #1a1d23;
  --bg-raised: #23272f;
  --text: #e8e9eb;
  --text-dim: #9aa0a8;
  --accent: #e8a23d;       /* янтарь Wexeros */
  --accent-text: #1a1300;
  --danger: #e05d5d;
  --ok: #4cae6e;
  --border: #2c313a;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --bg-card: #ffffff;
    --bg-raised: #eceef1;
    --text: #1c1e22;
    --text-dim: #6a7077;
    --accent: #c97f14;
    --accent-text: #fff;
    --danger: #c43d3d;
    --ok: #2c7a48;
    --border: #d8dbe0;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* --- гейт --- */
#gate { align-items: center; justify-content: center; }
.gate-box { text-align: center; padding: 24px; }
.gate-icon { font-size: 44px; margin-bottom: 12px; }
.gate-text { font-size: 18px; font-weight: 600; }
.gate-sub { margin-top: 8px; color: var(--text-dim); font-size: 14px; }

/* --- шапка/табы --- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 10px;
}
.brand { font-weight: 700; font-size: 18px; flex: 1; }
.icon-btn {
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 17px; padding: 6px 11px; cursor: pointer;
}
.tabs { display: flex; gap: 8px; padding: 4px 16px 10px; overflow-x: auto; }
.tab {
  background: var(--bg-raised); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* --- список движений (уровень 1) --- */
.content { padding: 6px 16px calc(env(safe-area-inset-bottom, 0px) + 24px); }
.item-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 12px; cursor: pointer; color: var(--text);
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 16px; font-weight: 700; }
.item-sub { margin-top: 3px; color: var(--text-dim); font-size: 13px; }
.item-status { margin-top: 6px; color: var(--accent); font-size: 12px; }
.chevron { color: var(--text-dim); font-size: 26px; line-height: 1; }

/* --- экран движения (уровень 2) --- */
.detail-head { padding: 4px 2px 12px; }
.detail-title { font-size: 19px; font-weight: 800; }
.detail-head .item-status { margin-top: 6px; }

/* --- кнопки-действия --- */
.action {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
}
.action-btn {
  display: block; width: 100%;
  background: var(--accent); color: var(--accent-text);
  border: none; border-radius: 10px;
  padding: 12px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.action-btn:disabled { opacity: .55; }
.action-btn.kind-report { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); }
.action-btn.kind-link { background: var(--bg-raised); color: var(--accent); border: 1px solid var(--accent); }
.action-hint { margin-top: 8px; color: var(--text-dim); font-size: 13px; }

/* --- калькулятор --- */
.calc-intro { margin-top: 0; margin-bottom: 14px; }
.calc-form { display: flex; flex-direction: column; gap: 12px; }
.calc-field { display: flex; flex-direction: column; gap: 5px; }
.calc-field-label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.calc-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.calc-out { margin-top: 14px; }
.calc-loading { color: var(--text-dim); font-size: 14px; padding: 8px 0; }
.calc-headline { font-size: 17px; font-weight: 700; }
.calc-headline b { color: var(--accent); }
.calc-sub { margin-top: 2px; color: var(--text-dim); font-size: 13px; }
.calc-formula {
  margin-top: 8px; padding: 8px 10px; font-size: 13px; color: var(--text-dim);
  background: var(--bg-raised); border-radius: 8px; font-variant-numeric: tabular-nums;
}
.calc-econ { margin-top: 14px; }
.calc-econ .rep-row:last-child { border-bottom: none; }
.calc-econ .rep-row:last-child .rep-k,
.calc-econ .rep-row:last-child .rep-v { font-weight: 800; color: var(--text); font-size: 15px; }
.calc-maxbox {
  margin-top: 14px; padding: 13px 14px;
  background: var(--bg-raised); border: 1px solid var(--accent); border-radius: 12px;
}
.calc-maxlabel { font-size: 12px; font-weight: 700; color: var(--accent); }
.calc-maxval { margin-top: 3px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.calc-maxval span { font-size: 15px; color: var(--text-dim); font-weight: 700; }
.calc-maxnote { margin-top: 6px; font-size: 12px; color: var(--text-dim); line-height: 1.4; }
/* ползунок скидки */
.calc-slider-wrap { margin-top: 14px; }
.calc-slider-top { display: flex; align-items: baseline; justify-content: space-between; }
.calc-slider-top .rep-h { margin: 0; }
.calc-slider-val { font-size: 20px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.calc-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px;
  border-radius: 999px; margin: 10px 0 6px; cursor: pointer; outline: none;
  background: linear-gradient(90deg, var(--accent) var(--p, 0%), var(--bg-raised) var(--p, 0%));
  border: 1px solid var(--border);
}
.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-card);
  box-shadow: 0 1px 5px rgba(0,0,0,.45); cursor: pointer;
}
.calc-slider::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--bg-card); box-shadow: 0 1px 5px rgba(0,0,0,.45); cursor: pointer;
}
.calc-slider-note { color: var(--text-dim); font-size: 12px; }

/* таблица по срокам */
.calc-table {
  width: 100%; margin-top: 14px; border-collapse: collapse; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.calc-table th {
  text-align: right; color: var(--text-dim); font-size: 11px; font-weight: 600;
  padding: 0 0 6px; border-bottom: 1px solid var(--border);
}
.calc-table th:first-child { text-align: left; }
.calc-table td { text-align: right; padding: 10px 0; border-bottom: 1px solid var(--border); }
.calc-table td:first-child { text-align: left; font-weight: 700; }
.calc-table tr:last-child td { border-bottom: none; }
.calc-td-classic { color: var(--text-dim); }
.calc-td-pays { font-weight: 700; }
.calc-td-net { font-weight: 800; color: var(--ok); }
.calc-td-net.net-low { color: var(--accent); }
.calc-td-net.net-zero { color: var(--danger); }
.calc-td-sub { display: block; color: var(--text-dim); font-size: 10px; font-weight: 400; text-decoration: none; }
.calc-foot { margin-top: 12px; color: var(--text-dim); font-size: 12px; line-height: 1.4; }
.calc-waba { color: var(--accent); }
.calc-year {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-raised); border: 1px solid var(--accent);
  font-size: 14px; line-height: 1.6;
}
.calc-year b { font-variant-numeric: tabular-nums; }
.calc-year-save { color: var(--ok); font-size: 16px; }
.calc-pdf-btn { margin-top: 16px; }
.calc-save-btn { margin-top: 10px; }
.calc-saverow { display: flex; gap: 8px; margin-top: 10px; }
.calc-name {
  flex: 1; min-width: 0; background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
.calc-savego {
  background: var(--accent); color: var(--accent-text); border: none; border-radius: 10px;
  padding: 0 16px; font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.calc-saved { margin-top: 16px; }
.saved-title { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.saved-empty { color: var(--text-dim); font-size: 13px; }
.saved-item {
  position: relative; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 12px; margin-bottom: 10px;
}
.saved-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-right: 26px; }
.saved-head b { font-size: 15px; }
.saved-date { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.saved-pkg { margin-top: 4px; font-size: 13px; color: var(--text-dim); }
.saved-meta { margin-top: 3px; font-size: 13px; color: var(--text-dim); }
.saved-net { margin-top: 5px; font-size: 13px; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }
.saved-del {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px;
  background: transparent; border: none; cursor: pointer; font-size: 15px; opacity: .6;
}
.saved-del:active { opacity: 1; }

/* --- рубильник --- */
.toggle-card { display: flex; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.toggle-state { font-size: 16px; font-weight: 700; }
.toggle-state.on { color: var(--ok); }
.toggle-state.off { color: var(--text-dim); }
.toggle-state.unknown { color: var(--text-dim); }
.switch {
  position: relative; width: 58px; height: 33px; border-radius: 999px;
  border: none; cursor: pointer; padding: 0; transition: background .15s;
}
.switch.on { background: var(--ok); }
.switch.off { background: var(--bg-raised); border: 1px solid var(--border); }
.switch:disabled { opacity: .5; }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 27px; height: 27px;
  background: #fff; border-radius: 50%; transition: left .15s;
}
.switch.on .knob { left: 28px; }

/* --- карточка job --- */
.job {
  margin-top: 12px; padding: 12px;
  background: var(--bg-raised); border-radius: 10px; font-size: 14px;
}
.job-running { color: var(--text); }
.job-status { font-weight: 600; }
.job .spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid var(--text-dim); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .9s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.job-ok { border-left: 3px solid var(--ok); }
.job-err { border-left: 3px solid var(--danger); }
.job-msg { margin-top: 6px; color: var(--text-dim); }
.job-headline { font-size: 16px; font-weight: 700; line-height: 1.3; }
.job-when { margin-top: 4px; color: var(--text-dim); font-size: 12px; }
.job-metrics {
  margin-top: 10px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px;
}
.job-metrics > div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 3px 0; }
.job-metrics span { color: var(--text-dim); font-size: 13px; }
.job-metrics b { font-variant-numeric: tabular-nums; }
/* --- структурированный отчёт (report) --- */
.rep-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.rep-sub { margin-top: 2px; color: var(--text-dim); font-size: 13px; }
.rep-rows { margin-top: 10px; }
.rep-h { margin: 12px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--accent); text-transform: none; }
.rep-h:first-child { margin-top: 0; }
.rep-row { display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 0; border-bottom: 1px solid var(--border); }
.rep-k { color: var(--text-dim); font-size: 13px; flex: 0 0 auto; }
.rep-v { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.rep-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.job details { margin-top: 8px; }
.job summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.job pre {
  margin: 8px 0 0; padding: 10px; overflow-x: auto;
  background: var(--bg); border-radius: 8px; font-size: 12px;
}

/* --- история --- */
.hist-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 10px; font-size: 14px;
}
.hist-head { display: flex; justify-content: space-between; gap: 8px; }
.hist-date { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.empty { color: var(--text-dim); text-align: center; padding: 32px 0; }

/* --- модалка подтверждения --- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-box {
  background: var(--bg-card); border-radius: 16px; padding: 20px;
  max-width: 360px; width: 100%;
}
.modal-text { font-size: 15px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-raised); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
