:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #718096;
  --line: #e5eaf1;
  --panel: #ffffff;
  --soft: #f6f8fb;
  --accent: #5b5ce2;
  --accent-2: #7c3aed;
  --green: #38b878;
  --red: #d92d20;
  --bg-1: #f8faff;
  --bg-2: #eef2f8;
  --shadow: 0 8px 24px #2538580a;
}

body.dark {
  color-scheme: dark;
  --ink: #eef2ff;
  --muted: #aab4c5;
  --line: #3a4354;
  --panel: #202938;
  --soft: #182130;
  --bg-1: #151c29;
  --bg-2: #111827;
  --shadow: 0 8px 24px #00000033;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-2);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #172033;
  color: #fff;
  box-shadow: 0 4px 18px #17203333;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #38b878;
  color: #081a13;
  font-weight: 850;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav { display: flex; gap: 14px; align-items: center; }
nav a { color: #b9c2d2; text-decoration: none; font-weight: 600; }
nav a:hover { color: #fff; }

.logout { margin: 0; }
.logout button,
.theme-toggle {
  border: 1px solid #ffffff33;
  background: #ffffff12;
  color: #fff;
  padding: 7px 11px;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.logout button:hover,
.theme-toggle:hover { background: #ffffff22; }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}

.cabinet-shell {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid #dbe2ee;
  border-radius: 22px;
  box-shadow: 0 10px 28px #25385818;
  padding: 26px 30px 40px;
}

body.dark .cabinet-shell { border-color: var(--line); }

h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
h2 { margin: 0 0 12px; font-size: 19px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.error { color: var(--red); }

.overview-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
  padding: 20px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, #30358d, #6966e8);
  color: #fff;
  box-shadow: 0 12px 26px #4b4ac733;
}
.overview-hero h1,
.overview-hero h2 { color: #fff; margin: 0; }
.overview-hero p { margin: 5px 0 0; color: #dfe2ff; }
.overview-hero .hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.overview-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 999px;
  background: #ffffff20;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.overview-live:before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #52e39b;
  box-shadow: 0 0 0 4px #52e39b33;
}

.overview-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.overview-kpi {
  position: relative;
  min-height: 108px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 5px 15px #2538580a;
}
.overview-kpi .kpi-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #eef0ff;
  color: var(--accent);
  font-size: 18px;
}
.overview-kpi b { display: block; color: var(--muted); font-size: 12px; }
.overview-kpi strong { display: block; margin-top: 4px; font-size: 27px; letter-spacing: -0.03em; }
.overview-kpi small { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 540px; margin: 40px auto; }

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.header-row h1 { margin: 0; }
.header-row h2 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  background: var(--soft);
  font-size: 14px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th {
  background: #f7f9fc;
  color: #667085;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}
body.dark th { background: #182130; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td a { color: var(--accent); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

.button,
button {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.button:hover,
button:hover { border-color: var(--accent); }
.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button.primary:hover,
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.button.danger,
button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.button.danger:hover,
button.danger:hover { background: #b42318; border-color: #b42318; }
.hero-actions .button {
  background: #ffffff18;
  border-color: #ffffff55;
  color: #fff;
  font-weight: 700;
}
.hero-actions .button:hover { background: #fff; color: #30358d; }

.error-card {
  border-color: #f5b8b5;
  background: #fff0f0;
  color: #b42318;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.form-grid label,
.form-grid fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
  padding: 0;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8deea;
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid #5b5ce233;
  border-color: var(--accent);
}
.form-grid .wide { grid-column: 1 / -1; }
.form-grid legend { margin-bottom: 8px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
}
.check input { width: auto; }
.actions { display: flex; flex-direction: row !important; align-items: center; justify-content: flex-end; gap: 14px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form select {
  padding: 7px 8px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.inline-form button { padding: 7px 10px; }

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-booked { background: #e1ddff; color: #4d35a6; }
.status-attended { background: #d9f8e7; color: #168052; }
.status-no_show { background: #ffe0df; color: #b42318; }
.status-waitlist { background: #fff4cc; color: #8a5b00; }
.status-canceled,
.status-late_cancel { background: #e5e7eb; color: #4b5563; }

.login-wrap {
  min-height: 60vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 12px 30px #25385814;
}
.login-card h1 { margin-bottom: 10px; }
.login-card p { color: var(--muted); }

@media (max-width: 900px) {
  .overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page { padding: 12px; }
  .cabinet-shell { padding: 20px 16px 28px; border-radius: 16px; }
  h1 { font-size: 24px; }
  .overview-hero { flex-direction: column; align-items: flex-start; }
  .overview-kpis { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .topbar-actions { gap: 10px; flex-wrap: wrap; }
  nav { gap: 10px; }
}

.form-hint { color: var(--red); font-size: 14px; min-height: 18px; }
.form-hint:empty { display: none; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pagination a, .pagination span {
  min-width: 36px;
  text-align: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  font-size: 14px;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.overview-kpi {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 10px;
  align-items: center;
}
.overview-kpi .kpi-icon { grid-column: 1; grid-row: 1; margin-bottom: 0; }
.overview-kpi b { grid-column: 2; grid-row: 1; margin: 0; line-height: 1.2; }
.overview-kpi strong { grid-column: 1 / -1; grid-row: 2; margin-top: 8px; }
.overview-kpi small { grid-column: 1 / -1; grid-row: 3; }

.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bulk-bar .muted { font-size: 13px; }
.check-cell { width: 38px; text-align: center; }
.check-cell input { width: auto; margin: 0; }

.danger-strong { background: #991b1b !important; border-color: #991b1b !important; color: #fff !important; }
.danger-strong:hover { background: #7f1d1d !important; border-color: #7f1d1d !important; }
