:root {
  --bg: #f6f7f9;
  --card: #fff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f24;
    --ink: #e8eaed;
    --muted: #9aa1ab;
    --line: #2c3038;
    --accent: #60a5fa;
    --good: #4ade80;
    --bad: #f87171;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .9em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* --- каркас --- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.topbar nav { display: flex; gap: 18px; margin-right: auto; }
.topbar nav a { color: var(--muted); }
.topbar nav a.on { color: var(--ink); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.me .role {
  background: var(--bg); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 999px;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.head h1 { font-size: 22px; margin: 0; }
.actions { display: flex; gap: 8px; }

h2 { font-size: 15px; margin: 24px 0 10px; }
.card h2:first-child { margin-top: 0; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.card.narrow { max-width: 520px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* --- плитки --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.tile b { display: block; font-size: 22px; }
.tile span { color: var(--muted); font-size: 12px; }

/* --- таблицы --- */
table { width: 100%; border-collapse: collapse; }
.card > table, table.card { display: table; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.bar { width: 30%; }
.bar i { display: block; height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }

/* Широкие таблицы скроллятся сами, страница — нет */
table.card { overflow-x: auto; display: block; }
@media (min-width: 900px) { table.card { display: table; } }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--line); background: var(--bg);
}
.tag.s-paid, .tag.s-renewed { color: var(--good); border-color: currentColor; }
.tag.s-expired { color: var(--bad); border-color: currentColor; }

/* --- формы --- */
input, select, button {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
input[type=checkbox] { padding: 0; }
button, .btn {
  background: var(--accent); color: #fff; border-color: transparent;
  cursor: pointer; padding: 8px 14px; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.quiet, a.quiet {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
a.quiet { padding: 7px 12px; border-radius: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { min-width: 220px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.inline { display: flex; gap: 8px; align-items: center; }

.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.stack input, .stack select { color: var(--ink); }
.stack button { justify-self: start; }

.props { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.props dt { color: var(--muted); font-size: 13px; }
.props dd { margin: 0; }

/* --- прочее --- */
.login { width: min(420px, 100%); text-align: center; }
.login h1 { margin-top: 0; }
.alert { color: var(--bad); }
.ok { color: var(--good); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12px; min-width: 120px; }
.timeline .what { font-weight: 600; }

.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager b { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.pager b { background: var(--accent); color: #fff; border-color: transparent; }

a.tile { color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
