:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #667085;
  --line: #e3e6ec;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --ok-bg: #e3f6ea;      --ok-fg: #17663a;
  --frozen-bg: #e6eefb;  --frozen-fg: #2a4f8f;
  --muted-bg: #eef0f3;   --muted-fg: #566070;
  --err-bg: #fdeaea;     --err-fg: #a12222;
  --warn-bg: #fff4d6;    --warn-fg: #7a5200;
  --code-bg: #f0f2f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e7e9ee;
    --muted: #98a1b0;
    --line: #272b34;
    --accent: #6d8dff;
    --accent-text: #0f1115;
    --ok-bg: #143323;      --ok-fg: #7fdca4;
    --frozen-bg: #18294a;  --frozen-fg: #9dbcf5;
    --muted-bg: #242830;   --muted-fg: #a5aebb;
    --err-bg: #3a1717;     --err-fg: #ff9c9c;
    --warn-bg: #3a2e10;    --warn-fg: #f5cf73;
    --code-bg: #22262e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

code {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

/* ---------- шапка ---------- */

.top, main, footer {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
  padding-bottom: 8px;
}

h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.sub { margin: 2px 0 0; color: var(--muted); }

h2 {
  margin: 36px 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-text);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  font-weight: 500;
  padding: 6px 12px;
}
button.ghost:hover, a.ghost:hover { color: var(--text); }

a.ghost {
  display: inline-block;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.top-actions form { margin: 0; }

.notice {
  margin: 18px 0 0;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-radius: 8px;
  padding: 10px 14px;
}
.notice a { color: inherit; font-weight: 600; }
.login-card .notice { margin: 0; font-size: 14px; }
.back { text-align: center; font-size: 14px; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- сводка ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- карточки ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-frozen { opacity: .78; }

.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }

.badge {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-bg);     color: var(--ok-fg); }
.badge-frozen { background: var(--frozen-bg); color: var(--frozen-fg); }
.badge-muted  { background: var(--muted-bg);  color: var(--muted-fg); }

.desc { margin: 8px 0 0; }

.links { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.links a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.links a:hover { text-decoration: underline; }

.meta {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 14px;
  font-size: 13.5px;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.notes {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13.5px;
}
.notes li + li { margin-top: 3px; }

.data-error, .form-error {
  background: var(--err-bg);
  color: var(--err-fg);
  border-radius: 8px;
  padding: 10px 14px;
}
.data-error { margin: 18px 0 0; }

footer { color: var(--muted); font-size: 13px; padding-top: 28px; padding-bottom: 40px; }

/* ---------- вход ---------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-sub { margin: -10px 0 4px; color: var(--muted); }
.login-card label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.login-card input {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}
.form-error { margin: 0; font-size: 14px; }

@media (max-width: 520px) {
  .top, main, footer { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; }
}
