/* unlimit hub — дизайн-токены и базовые компоненты. Mobile-first. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #15171d;
  --muted: #646b7b;
  --border: #e1e4ec;
  --accent: #5a4ff0;
  --accent-soft: #ecebfe;
  --accent-ink: #ffffff;
  --danger: #cf3b3b;
  --danger-soft: #fdecec;
  --warn: #8a6100;
  --warn-soft: #fff4d4;
  --ok: #19864a;
  --ok-soft: #e4f5ea;

  --radius: 14px;
  --radius-sm: 9px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --shadow: 0 1px 2px rgb(20 22 30 / 6%), 0 4px 16px rgb(20 22 30 / 6%);
  --shadow-hover: 0 2px 4px rgb(20 22 30 / 8%), 0 10px 28px rgb(20 22 30 / 12%);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8ebf1;
    --muted: #98a0b2;
    --border: #2a2f3b;
    --accent: #8f87ff;
    --accent-soft: #25224a;
    --accent-ink: #0e1015;
    --danger: #ff7a7a;
    --danger-soft: #3a1c1f;
    --warn: #f3c65a;
    --warn-soft: #3a3016;
    --ok: #5fd28f;
    --ok-soft: #173326;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-hover: 0 8px 28px rgb(0 0 0 / 45%);
    color-scheme: dark;
  }
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-4); }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }

.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Шапка */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  view-transition-name: topbar;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; }
.topbar nav a, .linklike {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.topbar nav a:hover, .linklike:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.page { max-width: 1100px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }

/* Карточки сервисов на главной */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-4);
}
.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--accent); text-decoration: none; }
.card .icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  font-size: 1.6rem;
  border-radius: 12px;
  background: var(--accent-soft);
}
.card h2 { margin: var(--space-2) 0 0; }
.card p { margin: 0; color: var(--muted); }
.badges { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.badge {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.panel + .panel, .panel + section, section + .panel { margin-top: var(--space-4); }

/* Формы */
.auth { max-width: 400px; margin: 8vh auto 0; }
.form { display: grid; gap: var(--space-3); }
.form label, label.field { display: grid; gap: var(--space-1); font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.check { display: flex !important; align-items: center; gap: var(--space-2); color: var(--text) !important; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}
.button:hover { filter: brightness(0.97); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.button.danger { color: var(--danger); }
.button.small { min-height: 34px; padding: 6px 12px; font-size: .9rem; }

.form-error:not(:empty), .notice.error {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
}
.form-error ul { margin: 0; padding-left: 1.1em; }
.field-error { color: var(--danger); font-size: .85rem; }
.field-error:empty { display: none; }
.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  margin-bottom: var(--space-4);
}
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* Таблицы: на телефоне прокручиваются в своей рамке */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
th a { color: inherit; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.stack { display: grid; gap: var(--space-3); }

/* Калькулятор */
.subnav, .chips { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-4); }
.subnav a, .chips a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .9rem;
}
.subnav a:hover, .chips a:hover { color: var(--text); text-decoration: none; }
.subnav a[aria-current="page"], .chips a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.totals dl { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--space-4); margin: 0; }
.totals dt, .totals dd { padding: 7px 0; border-bottom: 1px solid var(--border); }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals dt:last-of-type, .totals dd:last-of-type { border-bottom: 0; }
.totals .key { color: var(--text); font-weight: 650; }
.totals .muted { font-weight: 400; font-size: .85rem; }
@media (min-width: 900px) {
  .totals dl { grid-template-columns: 1fr auto 1fr auto; }
}
.neg { color: var(--danger) !important; }
.pos { color: var(--ok) !important; }

input.count { width: 5.5em; }
.grow { flex: 1 1 260px; }
.park tr.off td { opacity: .6; }
.add-row { margin-top: var(--space-4); }
.add-row select:first-child { flex: 1 1 220px; }
.qr svg { width: 220px; height: auto; background: #fff; padding: 8px; border-radius: var(--radius-sm); }
fieldset { border: 0; padding: 0; margin: 0; }

/* Широкие таблицы на телефоне — карточками: подпись столбца из data-label */
@media (max-width: 719px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
  table.responsive td { display: flex; justify-content: space-between; gap: var(--space-3); padding: 4px 0; border: 0; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  table.responsive td:first-child { font-size: 1.05rem; }
  table.responsive td:first-child::before, table.responsive td:not([data-label])::before { content: none; }
}

.status-page { text-align: center; margin-top: 12vh; }
.status-page .code { font-size: 3.5rem; font-weight: 800; color: var(--accent); }

@media (min-width: 720px) {
  h1 { font-size: 2rem; }
  .page { padding-top: var(--space-6); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  @view-transition { navigation: none; }
}
