/* ReservaPro — Panel de administración
   Estilo SaaS: sidebar oscura + contenido claro (con modo oscuro opcional). */

:root {
  --font-head: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --text: #16213a;
  --text-muted: #6b7489;
  --primary: #4f6df5;
  --primary-600: #3b58e0;
  --primary-soft: #e9edfe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --neutral: #64748b;
  --neutral-soft: #e2e8f0;

  --sidebar-bg: #121a2f;
  --sidebar-text: #aab4cf;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(79, 109, 245, 0.22);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px -8px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 20px 50px -12px rgba(16, 24, 40, 0.35);
  --sidebar-w: 256px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: #0d1220;
  --surface: #151c2e;
  --surface-2: #1b2338;
  --border: #273149;
  --text: #e8ecf6;
  --text-muted: #94a0bc;
  --primary-soft: rgba(79, 109, 245, 0.18);
  --success-soft: rgba(22, 163, 74, 0.18);
  --warning-soft: rgba(217, 119, 6, 0.18);
  --danger-soft: rgba(220, 38, 38, 0.18);
  --info-soft: rgba(37, 99, 235, 0.18);
  --neutral-soft: rgba(100, 116, 139, 0.22);
  --sidebar-bg: #0a0f1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px -8px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 8px; }
a { color: var(--primary); text-decoration: none; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(79, 109, 245, 0.25), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(227, 195, 158, 0.3), transparent 60%),
    var(--sidebar-bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin-top: 20px; }
.login-card form { margin-top: 20px; display: grid; gap: 14px; }
.login-hint { margin-top: 18px; font-size: 12.5px; text-align: center; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin: 0;
}

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand strong { display: block; font-family: var(--font-head); font-size: 15px; line-height: 1.1; }
.brand small { display: block; font-size: 11.5px; opacity: 0.7; line-height: 1.2; margin-top: 2px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 14px -4px rgba(79, 109, 245, 0.6);
}
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 22px; }
.brand-lg strong { font-size: 18px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 30;
}
.sidebar-top { padding: 20px 18px 10px; display: flex; align-items: center; justify-content: space-between; }
.sidebar .brand strong { color: #fff; }
.sidebar-close { display: none; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-ico { width: 22px; text-align: center; font-size: 15px; opacity: 0.9; }
.sidebar-bottom { padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: grid; gap: 10px; }
.nav-link-ext { color: var(--sidebar-text); font-size: 13px; padding: 6px 12px; }
.nav-link-ext:hover { color: #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #e3c39e, #c8a24c); color: #1b2a49; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-chip .icon-btn { color: var(--sidebar-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-date { color: var(--text-muted); font-size: 13px; }
.topbar .menu-btn { display: none; }
.view { padding: 24px; flex: 1; }
.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 28, 0.55); z-index: 25; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; line-height: 1.2;
  background: var(--surface-2); color: var(--text);
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 14px -6px rgba(79, 109, 245, 0.7); }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none; background: transparent;
  color: var(--text-muted); display: inline-grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.sidebar .sidebar-close { display: none; }
[data-theme="dark"] .stat-ico.violet { background: rgba(124, 58, 237, 0.2); color: #c4b5fd; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; font-size: 13.5px; }
.field > span { font-weight: 600; color: var(--text); }
.field .hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
input[type="url"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"],
select, textarea {
  font: inherit; color: var(--text);
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 90px; resize: vertical; }
input[type="color"] { width: 48px; height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="text"] { max-width: 120px; }
.input-row { display: flex; gap: 8px; align-items: center; }

/* ---------- Tarjetas / grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stat { padding: 18px; }
.stat .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat .value { font-family: var(--font-head); font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; margin-bottom: 10px; }
.stat-ico.blue { background: var(--info-soft); color: var(--info); }
.stat-ico.green { background: var(--success-soft); color: var(--success); }
.stat-ico.amber { background: var(--warning-soft); color: var(--warning); }
.stat-ico.red { background: var(--danger-soft); color: var(--danger); }
.stat-ico.violet { background: #ede9fe; color: #7c3aed; }
.stat-ico.gray { background: var(--neutral-soft); color: var(--neutral); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 22px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; min-width: 160px; }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }
.loading { padding: 40px; text-align: center; color: var(--text-muted); }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { background: var(--warning-soft); color: var(--warning); }
.badge.confirmed { background: var(--info-soft); color: var(--info); }
.badge.completed { background: var(--success-soft); color: var(--success); }
.badge.cancelled { background: var(--neutral-soft); color: var(--neutral); }
.badge.no_show { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.plain::before { display: none; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--primary-soft); color: var(--primary-600); margin: 2px 4px 2px 0; }
[data-theme="dark"] .tag { color: #a5b4ff; }

/* ---------- Gráfico ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--primary); opacity: 0.9; transition: opacity 0.15s; }
.chart .bar:hover { opacity: 1; }
.chart .bar.today { fill: #8b5cf6; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--text-muted); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .val { font-weight: 600; fill: var(--text); }

/* ---------- Listas ---------- */
.list { display: grid; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
}
.list-item .time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; font-family: var(--font-head); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .grow small { color: var(--text-muted); }
.rank { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank:last-child { border-bottom: none; }
.rank .n { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-600); font-weight: 700; font-size: 12px; }
.rank .bar-bg { height: 6px; background: var(--border); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.rank .bar-fg { height: 100%; background: var(--primary); border-radius: 4px; }

/* ---------- Agenda ---------- */
.cal-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cal { min-width: 860px; display: grid; grid-template-columns: 56px repeat(7, 1fr); }
.cal-head { display: contents; }
.cal-head > div {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 6px; text-align: center; font-size: 12.5px;
}
.cal-head .day-name { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.cal-head .day-num { font-family: var(--font-head); font-weight: 700; font-size: 18px; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; margin-top: 2px; }
.cal-head .today .day-num { background: var(--primary); color: #fff; }
.cal-gutter { position: relative; }
.cal-gutter .hour { position: absolute; left: 0; right: 6px; text-align: right; font-size: 11px; color: var(--text-muted); transform: translateY(-50%); }
.cal-col { position: relative; border-left: 1px solid var(--border); }
.cal-col.today { background: var(--primary-soft); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.cal-col .hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.cal-col .hline.half { border-top-style: dashed; opacity: 0.5; }
.cal-block {
  position: absolute; left: 2px; right: 2px;
  border-radius: 8px; padding: 4px 7px; font-size: 11.5px; line-height: 1.25;
  overflow: hidden; cursor: pointer; border: none; text-align: left; font-family: inherit;
  color: #fff; box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  transition: filter 0.12s, transform 0.12s;
}
.cal-block:hover { filter: brightness(1.08); transform: scale(1.01); z-index: 3; }
.cal-block strong { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block span { display: block; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block.pending { background: #f59e0b; color: #3b2a00; }
.cal-block.confirmed { background: var(--primary); }
.cal-block.completed { background: #16a34a; }
.cal-block.cancelled { background: #94a3b8; text-decoration: line-through; }
.cal-block.no_show { background: #dc2626; }
.cal-now { position: absolute; left: 0; right: 0; border-top: 2px solid #ef4444; z-index: 2; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .pending::before { background: #f59e0b; }
.legend .confirmed::before { background: var(--primary); }
.legend .completed::before { background: #16a34a; }
.legend .cancelled::before { background: #94a3b8; }
.legend .no_show::before { background: #dc2626; }
.week-label { font-family: var(--font-head); font-weight: 700; font-size: 15px; min-width: 200px; text-align: center; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: auto; padding: 2px; }
.slot {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); font-family: inherit;
}
.slot:hover { border-color: var(--primary); }
.slot.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Detalle (drawer) ---------- */
.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd { margin: 0; font-weight: 500; }
.detail-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.detail-section h4 { margin-bottom: 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

/* ---------- Profesionales ---------- */
.pro-card { display: grid; gap: 12px; }
.pro-head { display: flex; align-items: center; gap: 12px; }
.pro-head img, .pro-head .avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; font-size: 18px; }
.pro-head .grow { flex: 1; min-width: 0; }
.pro-head small { color: var(--text-muted); }
.hours-mini { display: grid; gap: 3px; font-size: 12.5px; }
.hours-mini div { display: flex; justify-content: space-between; gap: 8px; }
.hours-mini .d { color: var(--text-muted); width: 36px; }
.hours-mini .closed { color: var(--text-muted); font-style: italic; }
.sched-day { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sched-day:last-child { border-bottom: none; }
.sched-day .dname { font-weight: 600; padding-top: 8px; }
.sched-ranges { display: grid; gap: 6px; }
.sched-range { display: flex; align-items: center; gap: 6px; }
.sched-range input[type="time"] { width: 110px; }
.sched-range .sep { color: var(--text-muted); }
.sched-closed { color: var(--text-muted); font-size: 13px; padding-top: 8px; }

/* ---------- Reseñas ---------- */
.review { display: grid; gap: 8px; }
.review .stars { color: #f59e0b; letter-spacing: 1px; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.review p.comment { font-size: 14px; }

/* ---------- Mi negocio ---------- */
.preview-site {
  border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
}
.preview-cover { height: 80px; display: flex; align-items: flex-end; padding: 12px; color: #fff; font-family: var(--font-head); font-weight: 800; }
.preview-body { padding: 12px; display: flex; gap: 8px; align-items: center; }
.preview-btn { padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; }

/* ---------- Notificaciones ---------- */
.payload { max-width: 420px; white-space: pre-wrap; font-size: 12px; color: var(--text-muted); word-break: break-word; }
details.payload-det summary { cursor: pointer; color: var(--primary); font-size: 12.5px; }

/* ---------- Modal / Drawer ---------- */
.modal-root, .drawer-root { position: fixed; inset: 0; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 15, 28, 0.55); backdrop-filter: blur(2px); }
.modal {
  position: relative; margin: 6vh auto; width: min(640px, calc(100% - 32px));
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: pop 0.18s ease-out;
}
.modal.wide { width: min(860px, calc(100% - 32px)); }
.modal-head, .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal-foot:empty { display: none; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide 0.2s ease-out;
}
.drawer-body { padding: 20px 22px; overflow: auto; flex: 1; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(380px, calc(100% - 32px)); }
.toast {
  background: #16213a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: toast-in 0.2s ease-out;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }
.toast.out { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.22s ease;
    width: min(290px, 86vw);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-close { display: inline-grid; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .topbar-date { display: none; }
  #topbar-new { display: none; }
  .view { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { margin-top: 8px; font-size: 12px; }
  .section-head h2 { font-size: 19px; }
  .modal { margin: 2vh auto; max-height: 96vh; }
  .sched-day { grid-template-columns: 1fr; }
  .toolbar select, .toolbar input { min-width: 0; flex: 1; }
  .week-label { min-width: 0; font-size: 14px; }
  .card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
