:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1b2028;
  --muted: #6b7482;
  --accent: #2f6fd0;
  --ok: #2f9e63;
  --warn: #d69a2a;
  --bad: #d0503f;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --border: #2a303a;
    --text: #e7eaf0;
    --muted: #939cab;
    --accent: #5b9bf0;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Шапка */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}

.top .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.brand-name {
  font-weight: 650;
  font-size: 18px;
  line-height: 1.2;
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
}

.clock {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Секции */
main {
  padding: 28px 20px 40px;
}

section {
  margin-bottom: 32px;
}

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

/* Карточки состояния */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-value.state-ok {
  color: var(--ok);
}

.stat-value.state-bad {
  color: var(--bad);
}

.stat-hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
}

/* Индикатор заполнения */
.meter {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-top: 10px;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.meter-fill.ok {
  background: var(--ok);
}

.meter-fill.warn {
  background: var(--warn);
}

.meter-fill.bad {
  background: var(--bad);
}

/* Плитки разделов */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  opacity: 0.72;
}

.tile-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.tile-note {
  color: var(--muted);
  font-size: 13px;
}

.tile-badge {
  display: inline-block;
  margin-top: 12px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

/* Ссылки */
.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.link-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.link-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.link-title {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.link-note {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.updated {
  color: var(--muted);
  font-size: 12.5px;
  margin: 8px 0 0;
}

/* Подвал */
.bottom {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 520px) {
  .stats,
  .tiles,
  .links {
    grid-template-columns: 1fr;
  }

  main {
    padding: 20px 16px 32px;
  }
}
/* Подвал: строка с кнопкой выхода */
.bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.logout-form {
  margin: 0;
}

.logout {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.logout:hover {
  color: var(--accent);
}

/* Страница входа */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.auth-title {
  font-size: 20px;
  margin: 20px 0 6px;
}

.auth-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.auth-error {
  color: var(--bad);
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin: 0 0 14px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.auth-field input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.auth-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-submit {
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit:hover {
  filter: brightness(1.06);
}