/* ==========================================================================
   Rhythm Tutoring — design system
   Palette is built from the subject: ECG paper (salmon grid), telemetry
   traces (pink/teal), and the deep plum of a darkened reading room.
   ========================================================================== */

:root {
  /* colour */
  --ink:        #1B1140;
  --ink-2:      #3A2A6B;
  --pulse:      #FF2D6F;
  --pulse-soft: #FFE3ED;
  --sinus:      #00C2A8;
  --sinus-soft: #D6F7F2;
  --violet:     #7C4DFF;
  --violet-soft:#EDE6FF;
  --amber:      #FFB020;
  --amber-soft: #FFF1D6;
  --sky:        #2E9BFF;
  --sky-soft:   #DDEEFF;

  --bg:         #F5F3FC;
  --surface:    #FFFFFF;
  --surface-2:  #FBFAFF;
  --line:       #E7E2F5;
  --line-soft:  #F1EDFB;
  --text:       #1F1A33;
  --muted:      #6E6790;
  --faint:      #A29BC0;

  --danger:     #E5304F;
  --danger-soft:#FFE5EA;
  --ok:         #12B76A;
  --ok-soft:    #D8F6E7;

  /* type
     ONE typeface runs the whole application. The only exception is the logo
     in the header / side rail, which keeps its own display face. */
  --logo:    "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --body:    "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --display: var(--body);
  --mono:    var(--body);

  /* shape */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(27, 17, 64, .06), 0 4px 12px rgba(27, 17, 64, .05);
  --shadow-md: 0 8px 30px rgba(27, 17, 64, .10);
  --shadow-lg: 0 24px 60px rgba(27, 17, 64, .22);

  --rail: 250px;
  --hour-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  letter-spacing: -.02em;
  margin: 0;
  font-weight: 700;
}

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

button, input, select, textarea { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Times, durations and totals stay column-aligned without a second typeface. */
.mono,
.stat-label,
.rail-label,
.brand-sub,
.ev-time,
.gutter-slot span,
.cal-dayhead .dow,
.bar-label,
.detail .k,
table.data th {
  font-family: var(--body);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Shell
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- side rail */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  background:
          radial-gradient(140% 90% at 0% 0%, #4C2A8F 0%, transparent 60%),
          linear-gradient(180deg, #241552 0%, #351E6E 45%, #6A2E86 100%);
  color: #EFE9FF;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 20px;
}

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--pulse), #FF6B3D);
  box-shadow: 0 8px 22px rgba(255, 45, 111, .45);
  flex: none;
}

.brand-name {
  font-family: var(--logo);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.brand-name span { display: block; }
.brand-sub {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #C0AEF2;
  margin-top: 4px;
}

.rail-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #A896DD;
  padding: 14px 12px 8px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  color: #D7CCF7;
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  border: 1px solid transparent;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item svg { flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(100deg, rgba(255,45,111,.28), rgba(124,77,255,.20));
  border-color: rgba(255,255,255,.18);
  color: #fff;
}
.nav-item.active svg { opacity: 1; }

.rail-foot { margin-top: auto; padding-top: 16px; }

.rail-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border-radius: 15px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.rail-user .avatar {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--sinus), var(--sky));
  font-family: var(--display); font-weight: 700; font-size: 14px; color: #06283A;
  flex: none;
}
.rail-user-name { font-size: 13.5px; font-weight: 700; line-height: 1.2; }
.rail-user-role { font-size: 11px; color: #B5A6E4; }

.rail-signout {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.16);
  background: transparent;
  color: #D9CDFA;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.rail-signout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ------------------------------------------------------------------ ECG
   A real P-QRS-T complex: small P wave, sharp QRS spike, broad T wave.
   The whole strip scrolls by exactly one beat, so the loop is seamless. */
.ecg { display: block; width: 100%; }
.ecg-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.rail-trace { margin-top: 14px; opacity: .55; }
.rail-trace .ecg-scroll { animation: ecg-rail 3.4s linear infinite; }
@keyframes ecg-rail {
  from { transform: translateX(0); }
  to   { transform: translateX(-110px); }
}

/* ------------------------------------------------------------------- main */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(245, 243, 252, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 { font-size: 22px; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.rail-toggle {
  display: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.page { padding: 24px 28px 8px; flex: 1; min-width: 0; }
.view { display: none; }
.view.active { display: block; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.footer {
  padding: 20px 28px 26px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: 24px;
}
.footer .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--pulse); }
.footer strong { color: var(--text); }

/* ==========================================================================
   Building blocks
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 16px; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 0; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* -------------------------------------------------------------- stat tiles */
.stat {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 18px 18px 16px;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}
.stat .stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .75;
}
.stat .stat-value {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-top: 6px;
  line-height: 1;
}
.stat .stat-foot { font-size: 12.5px; margin-top: 8px; opacity: .8; }
.stat .stat-icon { position: absolute; right: -8px; bottom: -12px; opacity: .16; }

.stat.tone-pulse  { background: linear-gradient(150deg, #FFF0F5, #FFE0EC); color: #7A0B33; border-color: #FFD0E0; }
.stat.tone-sinus  { background: linear-gradient(150deg, #E6FBF7, #CFF6EF); color: #04564B; border-color: #B8EDE4; }
.stat.tone-violet { background: linear-gradient(150deg, #F2EDFF, #E5DCFF); color: #351A82; border-color: #D9CDFF; }
.stat.tone-amber  { background: linear-gradient(150deg, #FFF6E4, #FFEBC6); color: #7A4A00; border-color: #FFDFA5; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .16s ease, background .16s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(120deg, var(--pulse), #FF6B3D);
  color: #fff;
  box-shadow: 0 8px 20px rgba(255, 45, 111, .32);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 26px rgba(255, 45, 111, .42); }

.btn-secondary {
  background: linear-gradient(120deg, var(--violet), #4E7BFF);
  color: #fff;
  box-shadow: 0 8px 20px rgba(124, 77, 255, .28);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #D8CFF0; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #FFC9D3; }
.btn-danger:hover:not(:disabled) { background: #FFD3DB; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
}
.badge-scheduled { background: var(--sky-soft); color: #0B5FA8; }
.badge-completed { background: var(--ok-soft); color: #076B42; }
.badge-cancelled { background: #EFEDF6; color: #6E6790; text-decoration: line-through; }
.badge-reschedule { background: var(--amber-soft); color: #7A4A00; }
.badge-paid      { background: var(--sinus-soft); color: #04564B; }
.badge-unpaid    { background: var(--amber-soft); color: #7A4A00; }
.badge-active    { background: var(--sinus-soft); color: #04564B; }
.badge-left      { background: #EFEDF6; color: #6E6790; }
.badge-online    { background: var(--violet-soft); color: #4A22B8; }
.badge-in_person { background: var(--pulse-soft); color: #A31048; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
}
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ------------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--faint); font-weight: 500; margin-top: 5px; }
.field.required label::after { content: " *"; color: var(--pulse); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--violet-soft);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}
.textarea { min-height: 84px; resize: vertical; }
.input[type="time"], .input[type="date"], .input[type="datetime-local"] { font-family: var(--mono); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}
.checkbox input { margin-top: 3px; accent-color: var(--violet); width: 16px; height: 16px; }

.daypicker { display: flex; gap: 7px; flex-wrap: wrap; }
.daypicker input { position: absolute; opacity: 0; pointer-events: none; }
.daypicker label {
  min-width: 46px;
  text-align: center;
  padding: 9px 6px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
  transition: all .14s;
}
.daypicker input:checked + label {
  background: linear-gradient(120deg, var(--violet), #4E7BFF);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(124, 77, 255, .3);
}
.daypicker input:focus-visible + label { outline: 3px solid var(--violet); outline-offset: 2px; }

.swatch-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch-picker input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-picker label {
  width: 28px; height: 28px;
  border-radius: 9px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .12s;
}
.swatch-picker label:hover { transform: scale(1.12); }
.swatch-picker input:checked + label { border-color: var(--ink); transform: scale(1.12); }

.form-error {
  display: none;
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--danger-soft);
  border: 1px solid #FFC9D3;
  color: #A0142C;
  font-size: 13px;
  font-weight: 600;
}
.form-error.show { display: block; }

.segmented { display: inline-flex; padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); gap: 3px; }
.segmented button {
  padding: 7px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 12px; color: #fff;
  flex: none;
}
.person { display: flex; align-items: center; gap: 10px; }
.person-name { font-weight: 700; }
.person-meta { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.list-row .bar { width: 4px; align-self: stretch; border-radius: 4px; flex: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 700; font-size: 13.5px; }
.list-row .s { font-size: 12px; color: var(--muted); }

.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--muted);
}
.empty .empty-title { font-family: var(--display); font-weight: 700; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { margin: 0 0 14px; font-size: 13.5px; }

/* ------------------------------------------------------------------ charts */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 8px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; gap: 5px; height: 100%; width: 100%; justify-content: center; }
.bar {
  width: 16px;
  border-radius: 6px 6px 3px 3px;
  min-height: 4px;
  transition: height .5s cubic-bezier(.2,.8,.2,1);
}
.bar.rev { background: linear-gradient(180deg, var(--pulse), #FF7BA5); }
.bar.exp { background: linear-gradient(180deg, var(--violet), #A98BFF); }
.bar-label { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* ==========================================================================
   Schedule — the ECG paper
   ========================================================================== */
.sched-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.week-label { font-family: var(--display); font-weight: 700; font-size: 16px; min-width: 210px; }

.calendar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cal-head {
  display: grid;
  grid-template-columns: 66px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.cal-head .corner { border-right: 1px solid var(--line); }
.cal-dayhead {
  padding: 10px 6px;
  text-align: center;
  border-right: 1px solid var(--line-soft);
}
.cal-dayhead:last-child { border-right: none; }
.cal-dayhead .dow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.cal-dayhead .dnum { font-family: var(--display); font-weight: 700; font-size: 19px; line-height: 1.2; }
.cal-dayhead.is-today .dnum {
  color: #fff;
  background: linear-gradient(120deg, var(--pulse), #FF6B3D);
  border-radius: 10px;
  display: inline-block;
  min-width: 32px;
  padding: 1px 6px;
}
.cal-dayhead.is-weekend { background: #FAF7FF; }

.cal-body { display: grid; grid-template-columns: 66px repeat(7, minmax(0, 1fr)); position: relative; }

.cal-gutter { border-right: 1px solid var(--line); background: var(--surface-2); }
.gutter-slot {
  height: var(--hour-h);
  position: relative;
  text-align: right;
  padding-right: 8px;
}
.gutter-slot span {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  position: relative;
  top: -7px;
}

.cal-col {
  position: relative;
  border-right: 1px solid var(--line-soft);
  /* the signature: ECG graph paper */
  background-image:
          linear-gradient(to right, rgba(255, 45, 111, .10) 1px, transparent 1px),
          linear-gradient(to bottom, rgba(255, 45, 111, .10) 1px, transparent 1px),
          linear-gradient(to right, rgba(255, 45, 111, .05) 1px, transparent 1px),
          linear-gradient(to bottom, rgba(255, 45, 111, .05) 1px, transparent 1px);
  background-size:
          calc(100% / 4) var(--hour-h),
          100% var(--hour-h),
          calc(100% / 20) calc(var(--hour-h) / 5),
          100% calc(var(--hour-h) / 5);
}
.cal-col:last-child { border-right: none; }
.cal-col.is-weekend { background-color: #FDFBFF; }
.cal-col.is-today { background-color: #FFFAFC; }

.slot-hit { position: absolute; left: 0; right: 0; cursor: cell; }
.slot-hit:hover { background: rgba(124, 77, 255, .08); }
.slot-hit::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--violet);
  font-weight: 700;
  font-size: 18px;
}
.slot-hit:hover::after { display: grid; }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--pulse); z-index: 6; pointer-events: none; }
.now-line::before {
  content: "";
  position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 0 4px rgba(255, 45, 111, .22);
}

.event {
  position: absolute;
  border-radius: 10px;
  padding: 5px 8px;
  overflow: hidden;
  cursor: pointer;
  z-index: 5;
  border-left: 4px solid;
  color: #22163F;
  box-shadow: 0 3px 10px rgba(27, 17, 64, .13);
  transition: transform .12s ease, box-shadow .16s ease;
  min-height: 22px;
}
.event:hover { transform: translateY(-1px) scale(1.012); box-shadow: 0 8px 20px rgba(27,17,64,.2); z-index: 8; }
.event .ev-time { font-family: var(--mono); font-size: 10px; opacity: .85; line-height: 1.3; }
.event .ev-name { font-weight: 800; font-size: 12.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event .ev-topic { font-size: 11px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event.is-cancelled { opacity: .5; }
.event.is-reschedule {
  opacity: .78;
  background-image: repeating-linear-gradient(
          135deg, rgba(255,255,255,.55) 0 6px, transparent 6px 12px);
}
.event.is-reschedule .ev-name::after { content: " \21BB"; }
.event.is-cancelled .ev-name { text-decoration: line-through; }
.event.is-completed::after {
  content: "✓";
  position: absolute; top: 4px; right: 6px;
  font-size: 11px; font-weight: 800; opacity: .6;
}

.agenda-day { margin-bottom: 18px; }
.agenda-day h4 { font-size: 14px; margin-bottom: 8px; }
.agenda-day .date-pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-left: 8px;
  font-weight: 500;
}

/* ==========================================================================
   Modal & toast
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 17, 64, .45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal.wide { width: min(720px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-head h3 { font-size: 18px; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-head .icon-btn { margin-left: auto; }
.modal-close-btn { padding: 0; align-items: center; justify-items: center; line-height: 0; flex: none; }
.modal-close-btn svg { display: block; margin: 0; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px 20px;
  flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.detail {
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.detail .k {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--faint);
}
.detail .v { font-weight: 700; font-size: 14px; margin-top: 3px; word-break: break-word; }

.conflict-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--amber-soft);
  border: 1px solid #FFD98A;
  font-size: 13px;
}
.conflict-box ul { margin: 8px 0 0; padding-left: 18px; }

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--violet);
  animation: slide .25s cubic-bezier(.2,.9,.3,1.2);
  font-size: 13.5px;
}
@keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--amber); }
.toast .t-title { font-weight: 800; margin-bottom: 2px; }
.toast .t-close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--faint); font-size: 16px; line-height: 1; }

.loading {
  display: grid;
  place-items: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--pulse);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Sign-in page
   ========================================================================== */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth-art {
  position: relative;
  overflow: hidden;
  padding: 46px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #F2EBFF;
  background:
          radial-gradient(120% 80% at 10% 10%, #5A2C9E 0%, transparent 55%),
          linear-gradient(160deg, #200F4C 0%, #3B1C74 50%, #7A2E7E 100%);
}
.auth-art h2 {
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.08;
  max-width: 12ch;
}
.auth-art .lede { color: #C8B6F2; max-width: 40ch; margin-top: 14px; font-size: 15px; }
.auth-hero-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  min-height: 0;
}
.auth-hero-text { position: relative; z-index: 2; }
.auth-trace {
  position: relative;
  margin: 40px -46px 0;
  width: calc(100% + 92px);
  opacity: .5;
  z-index: 0;
}
.auth-trace .ecg-scroll { animation: ecg-hero 4.6s linear infinite; }
.auth-art .brand-mark { width: 52px; height: 52px; border-radius: 15px; }
.auth-art .brand-name { font-size: 19px; }
@keyframes ecg-hero {
  from { transform: translateX(0); }
  to   { transform: translateX(-300px); }
}
.auth-stats { display: flex; gap: 28px; position: relative; }
.auth-stats .n { font-family: var(--display); font-size: 24px; font-weight: 700; }
.auth-stats .l { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #B7A4EA; }

.auth-form-wrap {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: var(--bg);
}
.auth-form { width: min(392px, 100%); }
.auth-form .brand { padding-left: 0; }
.auth-form h1 { font-size: 26px; margin-bottom: 6px; }
.auth-form .sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.auth-note {
  margin-top: 22px;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2-1, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    z-index: 90;
    transform: translateX(-102%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-lg);
  }
  .rail.open { transform: none; }
  .rail-toggle { display: grid; place-items: center; }
  .page, .topbar, .footer { padding-left: 16px; padding-right: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}

@media (max-width: 720px) {
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .field-row, .field-row-3, .detail-grid { grid-template-columns: 1fr; }
  .cal-head, .cal-body { grid-template-columns: 52px repeat(7, minmax(58px, 1fr)); }
  .calendar { overflow-x: auto; }
  .cal-head, .cal-body { min-width: 660px; }
  .event .ev-topic { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}


/* ==========================================================================
   Hours balance
   ========================================================================== */
.hours-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.hours-pill.ok    { background: var(--sinus-soft); color: #04564B; }
.hours-pill.low   { background: var(--amber-soft); color: #7A4A00; }
.hours-pill.empty { background: var(--danger-soft); color: #A0142C; }
.hours-pill small { font-weight: 600; opacity: .75; font-size: 11px; }

.meter {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 7px;
}
.meter span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sinus), var(--sky));
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.meter.low span  { background: linear-gradient(90deg, var(--amber), #FF8A3D); }
.meter.empty span { background: linear-gradient(90deg, var(--danger), var(--pulse)); }

/* Student portal: a narrower shell with no navigation to anywhere else. */
.portal-rail .rail-label { padding-top: 6px; }
.portal-note {
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  color: #D3C6F5;
  line-height: 1.45;
}