:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dde3ec;
  --text: #1d2531;
  --muted: #6b7a90;
  --accent: #1f6feb;
  --accent-dark: #17539c;
  --good: #1a7f4b;
  --bad: #b42318;
  --head: #eef2f8;
  --shadow: 0 1px 3px rgba(16, 30, 54, .08), 0 6px 20px rgba(16, 30, 54, .06);
}

* { box-sizing: border-box; }

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

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

/* ── верхняя полоса ─────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.topbar .nav { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.topbar .nav a.active { font-weight: 600; color: var(--text); }
.topbar form { margin: 0; }

.wrap { padding: 16px 18px; max-width: none; margin: 0 auto; }

/* ── панели ─────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; }
.panel .hint { color: var(--muted); font-size: 13px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field.grow { flex: 1; min-width: 260px; }

input, select, textarea, button {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31,111,235,.25); border-color: var(--accent);
}
select { min-width: 260px; max-width: 100%; }

button {
  cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent);
  font-weight: 600; transition: background .15s;
}
button:hover { background: var(--accent-dark); }
button.ghost { background: #fff; color: var(--text); border-color: var(--line); font-weight: 500; }
button.ghost:hover { background: var(--head); }

.status { font-size: 13px; color: var(--muted); min-height: 18px; }
.status.err { color: var(--bad); }
.status.ok { color: var(--good); }

/* ── таблица отчёта ─────────────────────────────────────────────────── */
.report-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.report-head h2 { margin: 0; font-size: 16px; }
.report-head .period { color: var(--muted); font-size: 13px; }

.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; }
/* строки компактные: высоту задаёт поле ячейки, а не шрифт и не кнопки */
table.grid th, table.grid td { padding: 3px 10px; line-height: 1.2; border-bottom: 1px solid var(--line); }
table.grid thead th { padding: 6px 10px; }
table.grid thead th {
  background: var(--head); font-weight: 600; font-size: 13px;
  text-align: left; position: sticky; top: 0; z-index: 2;
}
table.grid thead th a { color: inherit; text-decoration: none; white-space: nowrap; }
table.grid thead th a:hover { color: var(--accent); text-decoration: none; }
table.grid thead th .arrow { color: var(--accent); font-size: 11px; }
table.grid tbody tr:hover { background: #f8faff; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.unit { color: var(--muted); }
table.grid td .uid { color: var(--muted); font-size: 11px; }
table.grid tfoot td {
  font-weight: 700; background: #fbfcfe; border-top: 2px solid var(--line);
}
table.grid tr.empty td { color: var(--muted); text-align: center; padding: 22px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; background: var(--head); color: var(--muted);
}
.badge.admin { background: #e8f0ff; color: var(--accent-dark); }

.alert {
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid var(--line); background: var(--head);
}
.alert.err { border-color: #f3c1bd; background: #fdf1f0; color: var(--bad); }
.alert.ok { border-color: #bfe3cf; background: #f0f9f4; color: var(--good); }

/* ── вход ───────────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.login-card .field { margin-bottom: 12px; }
.login-card button { width: 100%; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 12px; font-size: 14px; }
.kv .k { color: var(--muted); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .kv { grid-template-columns: 1fr; }
}

/* ── блокировка на время загрузки из iiko ───────────────────────────── */
.busy-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(244, 246, 249, .82);
  backdrop-filter: blur(2px);
}
.busy-overlay[hidden] { display: none; }
.busy-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 22px 30px; text-align: center; min-width: 260px;
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-title { font-weight: 600; margin-bottom: 4px; }
.busy-hint { color: var(--muted); font-size: 13px; }
