/* ============================================================
   WOW Studio CRM — Component Set (Phase 1)
   Depends on tokens.css. Plain CSS, no build step.
   ============================================================ */

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-app);
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }
p  { margin: 0 0 var(--space-3); }
a  { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
small, .text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.money.neg { color: var(--color-danger-700); }
.datetime, .date, .time { font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: 0.01em; }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ---------- Layout utilities ---------- */
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.divider { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-4) 0; }

/* ============================================================
   APP SHELL (admin portal)
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; min-width: var(--admin-min-width); }
.sidebar {
  background: var(--bg-sidebar); color: rgba(255,255,255,0.86);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); height: var(--topbar-height); border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-mark { width: 28px; height: 28px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--color-accent-500), var(--color-primary-400)); display: grid; place-items: center; font-weight: var(--weight-bold); color: #fff; font-size: var(--text-sm); flex: none; }
.brand-name { font-weight: var(--weight-semibold); color: #fff; letter-spacing: 0.02em; line-height: 1.1; }
.brand-sub { font-size: var(--text-xs); color: rgba(255,255,255,0.55); display: block; font-weight: var(--weight-regular); }
.nav { padding: var(--space-3) var(--space-2); flex: 1; }
.nav-section { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.45); padding: var(--space-4) var(--space-3) var(--space-1); }
.nav-item { display: flex; align-items: center; gap: var(--space-3); padding: 8px var(--space-3); border-radius: var(--radius-md); color: rgba(255,255,255,0.82); font-weight: var(--weight-medium); font-size: var(--text-sm); cursor: pointer; }
.nav-item:hover { background: var(--bg-sidebar-hover); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--bg-sidebar-active); color: #fff; }
.nav-item .icon { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav-item .count { margin-left: auto; background: var(--color-accent-500); color: #1c1200; font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 0 6px; border-radius: var(--radius-full); min-width: 18px; text-align: center; }
.nav-sub { padding-left: 30px; }
.nav-sub .nav-item { padding: 5px var(--space-3); font-weight: var(--weight-regular); color: rgba(255,255,255,0.7); }
.sidebar-footer { padding: var(--space-3) var(--space-4); border-top: 1px solid rgba(255,255,255,0.08); font-size: var(--text-xs); color: rgba(255,255,255,0.5); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-height); background: var(--bg-surface); border-bottom: 1px solid var(--border-default);
  display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--content-padding); position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar .search-input { flex: 1; max-width: 420px; }
.branch-switcher { display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px 10px 6px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); font-weight: var(--weight-medium); font-size: var(--text-sm); cursor: pointer; }
.branch-switcher .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-success-500); }
.branch-switcher.all .dot { background: var(--color-accent-500); }
.user-menu { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary-100); color: var(--color-primary-700); display: grid; place-items: center; font-weight: var(--weight-semibold); font-size: var(--text-sm); flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.user-meta { line-height: 1.2; }
.user-meta .name { font-weight: var(--weight-medium); font-size: var(--text-sm); }
.user-meta .role { font-size: var(--text-xs); color: var(--text-muted); }
.content { padding: var(--content-padding); flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-header .title-block h1 { margin-bottom: 2px; }
.page-header .subtitle { color: var(--text-muted); font-size: var(--text-sm); }
.page-actions { display: flex; gap: var(--space-2); align-items: center; }
.breadcrumb { display: flex; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-2); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { color: var(--color-gray-300); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-md);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary-600); color: #fff; }
.btn-primary:hover { background: var(--color-primary-700); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-danger { background: var(--color-danger-500); color: #fff; }
.btn-danger:hover { background: var(--color-danger-700); }
.btn-danger-outline { background: var(--bg-surface); color: var(--color-danger-700); border-color: var(--color-danger-100); }
.btn-danger-outline:hover { background: var(--color-danger-50); }
.btn-success { background: var(--color-success-500); color: #fff; }
.btn-success:hover { background: var(--color-success-700); }
.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn .icon { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.btn-group .btn-secondary + .btn-secondary { border-left: 0; }

/* Segmented control (view switchers e.g. Week by Room / Teacher / Day / Year) */
.segmented { display: inline-flex; background: var(--bg-subtle); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 4px; font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); cursor: pointer; }
.segmented button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* ============================================================
   FORMS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); }
.field .hint { font-size: var(--text-xs); color: var(--text-muted); }
.field .error-msg { font-size: var(--text-xs); color: var(--color-danger-700); }
.req::after { content: " *"; color: var(--color-danger-500); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 var(--space-3); font: inherit; font-size: var(--text-sm);
  color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input::placeholder { color: var(--color-gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--color-primary-100); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--color-danger-500); }
.input.mono, .input-date, .input-time, .input-datetime { font-family: var(--font-mono); font-size: var(--text-sm); letter-spacing: 0.01em; }
.input-date { max-width: 140px; }
.input-time { max-width: 90px; }
.input-datetime { max-width: 200px; }
.textarea { height: auto; min-height: 84px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: var(--leading-normal); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737380' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 var(--space-3); border: 1px solid var(--border-strong); background: var(--bg-subtle); color: var(--text-muted); font-size: var(--text-sm); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); white-space: nowrap; }
.input-group .input { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }
.search-input { position: relative; }
.search-input .input { padding-left: 34px; }
.search-input .icon { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--color-gray-400); }
.check, .radio { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input, .radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-primary-600); }
.toggle { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--color-gray-300); position: relative; transition: background var(--duration-base); flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--duration-base) var(--ease-out); }
.toggle input:checked + .track { background: var(--color-primary-600); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4) var(--space-5); }
.form-grid .span-2 { grid-column: span 2; }
.form-section { padding: var(--space-5) 0; border-top: 1px solid var(--border-default); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section h3 { margin-bottom: var(--space-4); }
.form-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding-top: var(--space-5); border-top: 1px solid var(--border-default); }

/* ============================================================
   BADGES / STATUS CHIPS
   ============================================================ */
.badge {
  --c: var(--color-gray-500);
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; line-height: 1;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 28%, white);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.badge.solid { background: var(--c); color: #fff; border-color: var(--c); }
.badge.solid::before { background: rgba(255,255,255,0.7); }
.badge.outline { background: transparent; }
.badge.no-dot::before { display: none; }
.badge.lg { height: 26px; padding: 0 10px; font-size: var(--text-sm); }

/* Slot */
.badge[data-status="scheduled"]   { --c: var(--status-scheduled); }
.badge[data-status="used"]        { --c: var(--status-used); }
.badge[data-status="cancelled"]   { --c: var(--status-cancelled); }
.badge[data-status="released"]    { --c: var(--status-released); border-style: dashed; }
.badge[data-status="rescheduled"] { --c: var(--status-rescheduled); }
/* Invoice + fee run */
.badge[data-status="draft"]          { --c: var(--status-draft); }
.badge[data-status="issued"]         { --c: var(--status-issued); }
.badge[data-status="partially-paid"] { --c: var(--status-partially-paid); }
.badge[data-status="paid"]           { --c: var(--status-paid); }
.badge[data-status="void"]           { --c: var(--status-void); text-decoration: line-through; }
.badge[data-status="unpaid"]         { --c: var(--status-unpaid); }
.badge[data-status="needs-checking"] { --c: var(--status-needs-checking); }
/* Salary */
.badge[data-status="confirmed"]  { --c: var(--status-confirmed); }
.badge[data-status="signed-off"] { --c: var(--status-signed-off); }
.badge[data-status="rejected"]   { --c: var(--status-rejected); }
/* Lead */
.badge[data-status="new"]            { --c: var(--status-new); }
.badge[data-status="contacted"]      { --c: var(--status-contacted); }
.badge[data-status="trial-booked"]   { --c: var(--status-trial-booked); }
.badge[data-status="trial-attended"] { --c: var(--status-trial-attended); }
.badge[data-status="converted"]      { --c: var(--status-converted); }
.badge[data-status="lost"]           { --c: var(--status-lost); }
/* Room booking */
.badge[data-status="tentative"] { --c: var(--status-tentative); }
.badge[data-status="locked"]    { --c: var(--status-locked); }
/* Attendance */
.badge[data-status="present"] { --c: var(--status-present); }
.badge[data-status="absent"]  { --c: var(--status-absent); }
.badge[data-status="late"]    { --c: var(--status-late); }
.badge[data-status="pending"] { --c: var(--status-pending); border-style: dashed; }
/* Flags */
.badge[data-status="chargeable"]     { --c: var(--color-warning-700); }
.badge[data-status="not-chargeable"] { --c: var(--color-gray-500); }
.badge[data-status="flagged"]        { --c: var(--color-danger-500); }
.badge[data-status="proof-received"] { --c: var(--color-success-700); }
.badge[data-status="trial"]          { --c: var(--color-accent-700); }
.badge[data-status="member"]         { --c: var(--color-primary-600); }

/* Plain tags (non-status labels: style, branch, role) */
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; }
.tag.primary { background: var(--color-primary-50); color: var(--color-primary-700); }
.tag.accent { background: var(--color-accent-50); color: var(--color-accent-700); }

/* Capacity meter (e.g. 8/12) */
.capacity { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.capacity .bar { width: 48px; height: 6px; background: var(--color-gray-200); border-radius: var(--radius-full); overflow: hidden; }
.capacity .bar i { display: block; height: 100%; background: var(--color-primary-500); }
.capacity.full .bar i { background: var(--color-danger-500); }

/* ============================================================
   CARDS / STAT TILES
   ============================================================ */
.card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-default); }
.card-header h3 { font-size: var(--text-md); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-default); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); font-size: var(--text-sm); }
.card.flush .card-body { padding: 0; }

.stat { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); }
.stat .stat-label { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-1); }
.stat .stat-value { font-size: var(--text-3xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -0.01em; }
.stat .stat-value small { font-size: var(--text-md); font-weight: var(--weight-medium); color: var(--text-muted); margin-right: 4px; }
.stat .stat-delta { font-size: var(--text-xs); margin-top: var(--space-2); display: flex; gap: 6px; align-items: center; }
.stat .stat-delta.up { color: var(--color-success-700); }
.stat .stat-delta.down { color: var(--color-danger-700); }
.stat.accent { border-left: 4px solid var(--color-primary-500); }
.stat.warn { border-left: 4px solid var(--color-warning-500); }
.stat.danger { border-left: 4px solid var(--color-danger-500); }
.stat.success { border-left: 4px solid var(--color-success-500); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table th, .table td { padding: 10px var(--space-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-default); }
.table thead th { position: sticky; top: 0; background: var(--bg-subtle); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); white-space: nowrap; z-index: 1; }
.table thead th.sortable { cursor: pointer; }
.table thead th.sortable::after { content: " ↕"; color: var(--color-gray-400); font-size: 10px; }
.table thead th.sorted-asc::after { content: " ↑"; color: var(--text-primary); }
.table thead th.sorted-desc::after { content: " ↓"; color: var(--text-primary); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--color-gray-50); }
.table tbody tr.selected td { background: var(--color-primary-50); }
.table tbody tr.flagged td { background: var(--color-danger-50); }
.table tbody tr.muted td { color: var(--text-muted); }
.table td.money, .table th.money { text-align: right; }
.table .row-actions { display: flex; gap: var(--space-1); justify-content: flex-end; opacity: 0; transition: opacity var(--duration-fast); }
.table tr:hover .row-actions { opacity: 1; }
.table tfoot td { background: var(--bg-subtle); font-weight: var(--weight-semibold); border-top: 2px solid var(--border-strong); border-bottom: 0; }
.table.compact th, .table.compact td { padding: 6px var(--space-3); }
.table .primary-cell { font-weight: var(--weight-medium); color: var(--text-primary); }
.table .sub { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-regular); }
.table-toolbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border-default); border-bottom: 0; background: var(--bg-surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.table-toolbar + .table-wrap { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-toolbar .search-input { width: 280px; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); font-size: var(--text-sm); color: var(--text-muted); border-top: 1px solid var(--border-default); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button { min-width: 28px; height: 28px; border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); font: inherit; font-size: var(--text-sm); cursor: pointer; color: var(--text-secondary); }
.pagination .pages button.active { background: var(--color-primary-600); color: #fff; }
.pagination .pages button:hover:not(.active) { background: var(--bg-subtle); }

/* Key-value list (detail panels) */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); margin: 0; }
.kv dt { color: var(--text-muted); margin: 0; }
.kv dd { margin: 0; color: var(--text-primary); }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--space-5); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px var(--space-3); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { color: var(--text-primary); }
.tabs button.active { color: var(--color-primary-700); border-bottom-color: var(--color-primary-600); }
.tabs .count { background: var(--bg-subtle); color: var(--text-secondary); border-radius: var(--radius-full); padding: 0 6px; font-size: 11px; }
.tabs button.active .count { background: var(--color-primary-100); color: var(--color-primary-700); }
.tab-panel[hidden] { display: none; }

/* ============================================================
   ALERTS / BANNERS / TOASTS
   ============================================================ */
.alert { --c: var(--color-info-500); display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid color-mix(in srgb, var(--c) 30%, white); background: color-mix(in srgb, var(--c) 8%, white); font-size: var(--text-sm); }
.alert .icon { width: 18px; height: 18px; color: var(--c); flex: none; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert.success { --c: var(--color-success-500); }
.alert.warning { --c: var(--color-warning-500); }
.alert.danger  { --c: var(--color-danger-500); }
.alert.info    { --c: var(--color-info-500); }
.alert .alert-actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }

.toast-stack { position: fixed; right: var(--space-6); bottom: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); z-index: var(--z-toast); }
.toast { --c: var(--color-gray-800); display: flex; align-items: center; gap: var(--space-3); min-width: 300px; max-width: 420px; padding: var(--space-3) var(--space-4); background: var(--color-gray-900); color: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--text-sm); border-left: 4px solid var(--c); }
.toast.success { --c: var(--color-success-500); }
.toast.danger  { --c: var(--color-danger-500); }
.toast.warning { --c: var(--color-warning-500); }
.toast .close { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,0.6); cursor: pointer; font-size: 16px; }

/* ============================================================
   MODAL / DRAWER
   ============================================================ */
.overlay { position: fixed; inset: 0; background: rgba(23,23,27,0.45); z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.overlay[hidden] { display: none; }
.modal { background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal.lg { max-width: 840px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-default); }
.modal-body { padding: var(--space-5); overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-default); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(23,23,27,0.35); z-index: var(--z-drawer); }
.drawer-overlay[hidden] { display: none; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: 520px; background: var(--bg-surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.drawer.wide { width: 720px; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-default); }
.drawer-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.drawer-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-default); }
.icon-close { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); }
.icon-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* ============================================================
   EMPTY STATE / SKELETON
   ============================================================ */
.empty { text-align: center; padding: var(--space-12) var(--space-6); color: var(--text-muted); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto var(--space-3); color: var(--color-gray-300); display: block; }
.empty h3 { color: var(--text-primary); margin-bottom: var(--space-1); }
.empty p { max-width: 360px; margin: 0 auto var(--space-4); font-size: var(--text-sm); }
.skeleton { background: linear-gradient(90deg, var(--color-gray-100) 25%, var(--color-gray-200) 37%, var(--color-gray-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ============================================================
   TIMELINE / LOG (follow-up log, audit trail, approval history)
   ============================================================ */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding-bottom: var(--space-4); position: relative; }
.timeline li::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--border-default); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--bg-surface); border: 2px solid var(--color-primary-400); margin-top: 1px; }
.timeline .dot.success { border-color: var(--color-success-500); }
.timeline .dot.danger { border-color: var(--color-danger-500); }
.timeline .dot.muted { border-color: var(--color-gray-300); }
.timeline .meta { font-size: var(--text-xs); color: var(--text-muted); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.timeline .body { font-size: var(--text-sm); margin-top: 2px; }

/* ============================================================
   TIMETABLE PRIMITIVES (used in Phase 2)
   ============================================================ */
.tt-grid { display: grid; grid-template-columns: 64px repeat(var(--tt-cols, 7), 1fr); border: 1px solid var(--border-default); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); font-size: var(--text-xs); }
.tt-grid .tt-head { background: var(--bg-subtle); padding: 8px; font-weight: var(--weight-semibold); border-bottom: 1px solid var(--border-default); border-left: 1px solid var(--border-default); text-align: center; }
.tt-grid .tt-head:first-child { border-left: 0; }
.tt-grid .tt-head .day { display: block; font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tt-grid .tt-head .date { display: block; font-size: var(--text-md); font-variant-numeric: tabular-nums; }
.tt-grid .tt-time { padding: 4px 8px; color: var(--text-muted); font-variant-numeric: tabular-nums; border-top: 1px solid var(--border-default); height: 28px; text-align: right; }
.tt-grid .tt-cell { border-top: 1px solid var(--border-default); border-left: 1px solid var(--border-default); height: 28px; position: relative; }
.tt-grid .tt-cell.half { border-top-style: dashed; }
.tt-grid .tt-cell.off { background: repeating-linear-gradient(135deg, var(--color-gray-100) 0 6px, var(--bg-surface) 6px 12px); }
.tt-grid .tt-cell.idle { background: var(--color-success-50); }
.slot-chip { --c: var(--color-primary-500); position: absolute; left: 3px; right: 3px; top: 2px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 14%, white); border-left: 3px solid var(--c); padding: 3px 6px; overflow: hidden; cursor: pointer; z-index: 1; }
.slot-chip .t { font-weight: var(--weight-semibold); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-chip .s { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-chip.ballet { --c: #B5468A; }
.slot-chip.jazz { --c: var(--color-accent-500); }
.slot-chip.piano { --c: var(--color-info-500); }
.slot-chip.contemporary { --c: #2A9D8F; }
.slot-chip.rental { --c: var(--color-gray-500); }
.slot-chip.cancelled { opacity: 0.5; text-decoration: line-through; }
.slot-chip.rescheduled { border-left-style: dashed; }
.slot-chip.trial::after { content: "TRIAL"; position: absolute; top: 3px; right: 4px; font-size: 9px; font-weight: var(--weight-bold); color: var(--color-accent-700); }

/* Year view cell */
.year-day { width: 22px; height: 22px; display: inline-grid; place-items: center; font-size: 10px; border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.year-day.holiday { background: var(--color-danger-100); color: var(--color-danger-700); font-weight: var(--weight-semibold); }
.year-day.term-break { background: var(--color-accent-100); color: var(--color-accent-700); }
.year-day.off-day { background: var(--color-gray-200); color: var(--text-secondary); }
.year-day.today { outline: 2px solid var(--color-primary-500); }

/* ============================================================
   PIPELINE / KANBAN (CRM)
   ============================================================ */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-2); }
.kanban-col { background: var(--bg-subtle); border-radius: var(--radius-lg); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.kanban-col .col-head { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-sm); font-weight: var(--weight-semibold); padding: 0 var(--space-1) var(--space-2); }
.lead-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: var(--space-3); cursor: pointer; box-shadow: var(--shadow-sm); }
.lead-card:hover { border-color: var(--color-primary-300); }
.lead-card .name { font-weight: var(--weight-medium); font-size: var(--text-sm); }
.lead-card .meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.lead-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-2); font-size: var(--text-xs); }
.lead-card .due { color: var(--color-danger-700); font-weight: var(--weight-medium); }

/* ============================================================
   STEPPER (approval workflow, convert-to-client wizard)
   ============================================================ */
.stepper { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.stepper .step { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); white-space: nowrap; }
.stepper .step .n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--color-gray-300); display: grid; place-items: center; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.stepper .step.done { color: var(--color-success-700); }
.stepper .step.done .n { background: var(--color-success-500); border-color: var(--color-success-500); color: #fff; }
.stepper .step.current { color: var(--text-primary); font-weight: var(--weight-medium); }
.stepper .step.current .n { border-color: var(--color-primary-600); color: var(--color-primary-700); }
.stepper .step.rejected { color: var(--color-danger-700); }
.stepper .step.rejected .n { border-color: var(--color-danger-500); color: var(--color-danger-700); }
.stepper .line { flex: 1; min-width: 24px; height: 2px; background: var(--color-gray-300); }
.stepper .line.done { background: var(--color-success-500); }

/* ============================================================
   MOBILE SHELL (teacher portal)  — 360px+, bottom tab bar
   ============================================================ */
.phone { width: 360px; height: 720px; border: 10px solid var(--color-gray-900); border-radius: 36px; overflow: hidden; background: var(--bg-app); position: relative; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.m-topbar { height: 52px; background: var(--color-primary-900); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-4); font-weight: var(--weight-semibold); flex: none; }
.m-topbar .branch { font-size: var(--text-xs); font-weight: var(--weight-regular); color: rgba(255,255,255,0.7); }
.m-body { flex: 1; overflow-y: auto; padding: var(--space-4); }
.m-tabbar { height: 60px; background: var(--bg-surface); border-top: 1px solid var(--border-default); display: grid; grid-template-columns: repeat(4, 1fr); flex: none; }
.m-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--text-muted); font-weight: var(--weight-medium); }
.m-tab .icon { width: 22px; height: 22px; }
.m-tab.active { color: var(--color-primary-600); }
.m-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); }
.m-list-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-default); }
.m-list-item:last-child { border-bottom: 0; }
.att-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.att-btn { height: 40px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg-surface); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; }
.att-btn.present.active { background: var(--color-success-500); color: #fff; border-color: var(--color-success-500); }
.att-btn.late.active { background: var(--color-warning-500); color: #fff; border-color: var(--color-warning-500); }
.att-btn.absent.active { background: var(--color-danger-500); color: #fff; border-color: var(--color-danger-500); }
.touch { min-height: 44px; }

/* ============================================================
   MISC
   ============================================================ */
.icon { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tooltip { position: relative; }
.tooltip[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--color-gray-900); color: #fff; padding: 4px 8px; border-radius: var(--radius-sm); font-size: var(--text-xs); white-space: nowrap; z-index: var(--z-dropdown); }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-1); z-index: var(--z-dropdown); }
.dropdown-menu[hidden] { display: none; }
.dropdown-menu a, .dropdown-menu button { display: block; width: 100%; text-align: left; padding: 8px var(--space-3); border: 0; background: none; font: inherit; font-size: var(--text-sm); color: var(--text-primary); border-radius: var(--radius-sm); cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg-subtle); text-decoration: none; }
.dropdown-menu .danger { color: var(--color-danger-700); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-1) 0; }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius-sm); background: var(--bg-subtle); }
.proto-note { background: var(--color-accent-50); border: 1px dashed var(--color-accent-500); color: var(--color-accent-700); font-size: var(--text-xs); padding: 6px 10px; border-radius: var(--radius-sm); }
