/* Токены темы. Правило проекта: в разметке никаких literal-цветов, только var(--…).
   Перенесено из конвенций боевого проекта — там это себя оправдало. */
:root {
  --bg:            #f5f6f8;
  --surface:       #ffffff;
  --border:        #e2e5ea;
  --text:          #1c2024;
  --text-muted:    #6b7280;
  --accent:        #1f6feb;
  --accent-text:   #ffffff;
  --ok-bg:         #e8f5ec;
  --ok-text:       #1a7f37;
  --error-bg:      #fdecec;
  --error-text:    #b42318;
  --warn-bg:       #fff6e5;
  --warn-text:     #9a6700;
  --radius:        8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #14171a;
    --surface:     #1c2024;
    --border:      #2c3238;
    --text:        #e6e8ea;
    --text-muted:  #9aa3ad;
    --accent:      #4c8dff;
    --ok-bg:       #16281c;
    --ok-text:     #5fd07f;
    --error-bg:    #2c1a1a;
    --error-text:  #ff8a80;
    --warn-bg:     #2a2312;
    --warn-text:   #e0b341;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Шапка ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a {
  color: var(--text-muted); text-decoration: none;
  padding: 4px 0; border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.account { display: flex; align-items: center; gap: 12px; color: var(--text-muted); }
.tenant { font-weight: 500; color: var(--text); }

/* ── Страница ──────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.page-narrow { max-width: 420px; margin: 64px auto; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 12px; }
p.hint { color: var(--text-muted); margin: 4px 0 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}

/* ── Показатели ────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase;
               letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 6px; }

/* ── Таблицы ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
         white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px;
     text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Формы ─────────────────────────────────────────────── */
label { display: block; margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-size: 14px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { margin-bottom: 16px; }

button, .btn {
  padding: 9px 16px; border: none; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--text);
                 border: 1px solid var(--border); }
.btn-link { background: none; border: none; color: var(--text-muted);
            cursor: pointer; padding: 0; font-size: 14px; }
.btn-link:hover { color: var(--text); text-decoration: underline; }
form.inline { display: inline; }

/* ── Сообщения ─────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-ok    { background: var(--ok-bg);    color: var(--ok-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-warn  { background: var(--warn-bg);  color: var(--warn-text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px;
         font-size: 12px; background: var(--bg); border: 1px solid var(--border);
         color: var(--text-muted); }

.muted { color: var(--text-muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
