:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --text: #1c2420;
  --muted: #5d6963;
  --line: #dfe4e0;
  --accent: #166534;
  --accent-text: #ffffff;
  --ok: #2f855a;
  --warn: #c27c0e;
  --over: #c53030;
  --none: #8a8f8c;
  --row-hover: #eef3ef;
  --sub-bg: #fafbfa;
  --error-bg: #fdecec;
  --error-text: #8b1d1d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141917;
    --panel: #1c2320;
    --text: #e4ebe7;
    --muted: #9aa8a1;
    --line: #2e3833;
    --accent: #3fa86a;
    --accent-text: #0e1411;
    --ok: #4cc283;
    --warn: #e0a43a;
    --over: #f06464;
    --none: #7d8682;
    --row-hover: #232c28;
    --sub-bg: #18201c;
    --error-bg: #3a1c1c;
    --error-text: #ffb4b4;
  }
}
:root[data-theme="dark"] {
  --bg: #141917; --panel: #1c2320; --text: #e4ebe7; --muted: #9aa8a1; --line: #2e3833;
  --accent: #3fa86a; --accent-text: #0e1411; --ok: #4cc283; --warn: #e0a43a; --over: #f06464;
  --none: #7d8682; --row-hover: #232c28; --sub-bg: #18201c; --error-bg: #3a1c1c; --error-text: #ffb4b4;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h2 { font-size: 15px; margin: 0 0 10px; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--muted);
}
.tab.active { background: var(--row-hover); color: var(--text); font-weight: 600; }

.period {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px;
}
.period label { display: flex; align-items: center; gap: 6px; }
input, select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
button.primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 7px 14px;
  font-weight: 600; cursor: pointer;
}
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; text-decoration: underline; }
button.danger { color: var(--over); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }

main { padding: 0 16px 40px; }
.error {
  background: var(--error-bg); color: var(--error-text); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
  white-space: pre-wrap;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }

.quality { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.quality ul { margin: 6px 0 0; padding-left: 18px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.dot.over { background: var(--over); } .dot.none { background: var(--none); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table.plan { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.plan th, .plan td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.plan th { font-size: 12.5px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.plan .num { text-align: right; }
.plan tr.group td { cursor: pointer; }
.plan tr.group:hover td { background: var(--row-hover); }
.plan tr.date-start td { border-top: 2px solid var(--line); }
.plan td.customers { white-space: normal; max-width: 380px; }
.chip { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; margin: 1px 3px 1px 0; font-size: 12px; }
.plan tr.sub td { background: var(--sub-bg); font-size: 13px; }
.plan tr.sub td:first-child { padding-left: 24px; }
.left-over { color: var(--over); font-weight: 600; }
.status-bar { position: relative; width: 120px; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.status-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.fill-ok { background: var(--ok); } .fill-warn { background: var(--warn); }
.fill-over { background: var(--over); } .fill-none { background: var(--none); }
.fill-label { font-size: 12px; color: var(--muted); margin-left: 6px; }
.fill { min-width: 170px; }
.fill-cell { display: flex; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; max-width: 980px; }
.booking-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; max-width: none; }
.booking-form h2, .booking-form .wide, .booking-form .actions { grid-column: 1 / -1; }
.booking-form label, .settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.booking-form input, .booking-form select { color: var(--text); }
.actions { display: flex; gap: 10px; align-items: center; }
.settings label { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 8px; color: var(--text); }
.settings label span { width: 140px; }
.settings input { width: 90px; }

@media (max-width: 640px) {
  .tabs { order: 3; flex-basis: 100%; }
  .period label { flex: 1 1 140px; }
}

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.login-card h1 { font-size: 20px; margin: 0; }
.login-card p { margin: 0; }
.login-card label, .user-form label, .password-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.login-card input, .user-form input, .password-form input { color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-form, .password-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 12px; align-items: end; }
.user-form h2, .password-form h2, .user-form .hint, .password-form .hint { grid-column: 1 / -1; }
.check { flex-direction: row !important; align-items: center; color: var(--text) !important; }
tr.inactive td { color: var(--muted); }
