:root {
  color-scheme: light;
  --navy: #0b1f3a;
  --navy-2: #12335c;
  --blue: #1868d5;
  --blue-soft: #eaf2ff;
  --gold: #f2b84b;
  --ink: #132033;
  --muted: #667085;
  --line: #dfe5ec;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --success: #167c53;
  --success-soft: #eaf7f1;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #a15c00;
  --warning-soft: #fff7e6;
  --shadow: 0 10px 28px rgba(20, 36, 58, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--surface-2); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--surface-2); }
button, input, select { font: inherit; }
button, select, input { min-height: 42px; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; padding: 26px 18px 20px;
  background: linear-gradient(180deg, var(--navy) 0%, #07172d 100%); color: white;
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 900; letter-spacing: -1px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.2px; }
.brand-subtitle { font-size: 12px; color: #aebed2; margin-top: 2px; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item { border: 0; background: transparent; color: #cbd6e4; padding: 10px 12px; border-radius: 11px; display: flex; align-items: center; gap: 12px; text-align: left; font-weight: 650; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.is-active { background: rgba(255,255,255,.12); color: white; }
.nav-icon { width: 22px; text-align: center; color: #8eb8ef; font-size: 18px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; }
.season-card { padding: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); border-radius: 14px; display: grid; gap: 3px; }
.season-card .eyebrow { color: #9fb0c5; }
.season-card .muted { color: #aebed2; font-size: 12px; }

.main-panel { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: center; padding: 26px 34px 18px; background: rgba(246,248,251,.92); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(223,229,236,.72); }
.topbar h1 { margin: 0; font-size: clamp(24px, 2.5vw, 34px); letter-spacing: -.8px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.mobile-brand { display: none; font-size: 12px; font-weight: 800; color: var(--blue); margin-bottom: 4px; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.role-control, .student-control { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
select, input[type="search"] { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 10px; padding: 8px 11px; font-size: 14px; outline: none; }
select:focus, input:focus { border-color: #8bb9f2; box-shadow: 0 0 0 3px rgba(24,104,213,.12); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--navy); color: white; display: grid; place-items: center; font-weight: 800; }

.content { padding: 12px 34px 36px; width: 100%; max-width: 1500px; margin: 0 auto; }
.app-footer { margin-top: auto; padding: 14px 34px 28px; color: #8a94a3; display: flex; justify-content: space-between; gap: 16px; font-size: 12px; }

.grid { display: grid; gap: 16px; }
.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)); }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 18px; margin-top: 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 7px rgba(20,36,58,.03); }
.card-pad { padding: 18px; }
.card-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.kpi { padding: 18px; min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.kpi::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: var(--blue-soft); right: -18px; top: -20px; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.kpi-value { font-size: 30px; font-weight: 850; letter-spacing: -1px; }
.kpi-note { font-size: 12px; color: var(--muted); }
.kpi.alert::after { background: var(--danger-soft); }
.kpi.alert .kpi-value { color: var(--danger); }

.section-spacer { margin-top: 18px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--muted); }
.muted { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; background: #eef2f6; color: #465568; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.blue { background: var(--blue-soft); color: #1559ad; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--warning-soft); color: var(--warning); }
.event-chip { display: inline-flex; border: 1px solid #d9e4f1; background: #f8fbff; color: #254665; border-radius: 999px; padding: 5px 9px; font-size: 12px; margin: 3px 4px 3px 0; }

.timeline { display: grid; }
.timeline-row { display: grid; grid-template-columns: 86px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid #edf0f4; }
.timeline-row:first-child { border-top: 0; padding-top: 2px; }
.date-tile { text-align: center; border-radius: 12px; background: var(--surface-2); padding: 8px 6px; }
.date-tile strong { display: block; font-size: 20px; }
.date-tile span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.timeline-main strong { display: block; font-size: 14px; }
.timeline-main p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.conflict-list { display: grid; gap: 9px; }
.conflict-item { border: 1px solid #f0cbc7; background: #fffafa; padding: 11px 12px; border-radius: 12px; }
.conflict-item strong { font-size: 13px; }
.conflict-item p { margin: 4px 0 0; font-size: 12px; color: #7f3c35; line-height: 1.4; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search { width: min(330px, 72vw); }
.segmented { display: inline-flex; padding: 3px; background: #e9edf2; border-radius: 11px; }
.segmented button { min-height: 36px; border: 0; background: transparent; border-radius: 8px; padding: 6px 11px; color: #5a6878; font-weight: 700; font-size: 13px; }
.segmented button.is-active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(20,36,58,.12); }
.primary-button, .ghost-button, .danger-button { border-radius: 10px; padding: 9px 13px; font-weight: 750; font-size: 13px; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: white; }
.primary-button:hover { background: #125cbf; }
.ghost-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.ghost-button:hover { background: #f8fafc; }
.danger-button { border: 1px solid #efc2bc; background: #fff5f3; color: var(--danger); }
.full { width: 100%; }

.schedule-day { margin-bottom: 16px; overflow: hidden; }
.schedule-day-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 17px; background: #fbfcfe; border-bottom: 1px solid var(--line); }
.schedule-day-head strong { font-size: 15px; }
.schedule-day-head span { color: var(--muted); font-size: 12px; }
.session-list { padding: 5px 16px 10px; }
.session { display: grid; grid-template-columns: 105px 1fr 145px 74px; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid #edf0f4; }
.session:first-child { border-top: 0; }
.session-time { color: var(--muted); font-size: 12px; font-weight: 700; }
.session-event { font-weight: 750; font-size: 13px; }
.session-room { color: var(--muted); font-size: 12px; }

.student-layout { display: grid; grid-template-columns: minmax(270px, .85fr) minmax(0, 1.4fr); gap: 16px; }
.student-list { max-height: 680px; overflow: auto; }
.student-row { width: 100%; min-height: 58px; border: 0; border-top: 1px solid #edf0f4; background: white; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; text-align: left; }
.student-row:first-child { border-top: 0; }
.student-row:hover, .student-row.is-active { background: #f6f9fd; }
.student-name { font-weight: 750; }
.student-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.detail-hero { padding: 20px; background: linear-gradient(135deg, #0d2a4e, #174675); color: white; border-radius: 15px; margin-bottom: 16px; }
.detail-hero h2 { margin: 0; font-size: 24px; }
.detail-hero p { margin: 4px 0 0; color: #c7d5e7; font-size: 13px; }

.event-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.event-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 166px; }
.event-card h3 { font-size: 15px; margin: 0; }
.event-card-top { display: flex; justify-content: space-between; gap: 12px; }
.avatar-stack { display: flex; align-items: center; }
.mini-avatar { width: 29px; height: 29px; border: 2px solid white; border-radius: 50%; background: #dce8f6; color: #234566; display: grid; place-items: center; font-size: 10px; font-weight: 850; margin-left: -6px; }
.mini-avatar:first-child { margin-left: 0; }

.tournament-card { padding: 18px; }
.tournament-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.tournament-title h3 { margin: 0; font-size: 17px; }
.tournament-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 8px; }
.availability-box { margin-top: 16px; padding-top: 15px; border-top: 1px solid #edf0f4; }
.availability-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.availability-actions button { min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: white; padding: 6px 11px; color: #4a596a; font-size: 12px; font-weight: 750; }
.availability-actions button.is-active[data-status="yes"] { background: var(--success-soft); border-color: #b8e3d2; color: var(--success); }
.availability-actions button.is-active[data-status="maybe"] { background: var(--warning-soft); border-color: #f2d9a9; color: var(--warning); }
.availability-actions button.is-active[data-status="no"] { background: var(--danger-soft); border-color: #efc3be; color: var(--danger); }

.my-hero { padding: 24px; background: linear-gradient(135deg, #0a2241 0%, #164d7e 70%, #1d6298 100%); color: white; border-radius: 18px; box-shadow: var(--shadow); }
.my-hero .eyebrow { color: #a9c8e7; }
.my-hero h2 { margin: 5px 0 4px; font-size: 28px; }
.my-hero p { color: #cbd9e8; margin: 0; }
.my-event-chips { margin-top: 15px; }
.my-event-chips .event-chip { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: white; }
.next-session { border-left: 4px solid var(--blue); padding: 14px 15px; }

.resource-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.resource-link { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); }
.resource-link strong { display: block; font-size: 13px; }
.resource-link span { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-link:hover { text-decoration: none; border-color: #adc8e8; }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); color: #234f83; font-size: 13px; line-height: 1.5; }
.notice.warning { background: var(--warning-soft); color: #7c4b0a; }

.bottom-nav { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #132033; color: white; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body { padding-bottom: 72px; }
  .app-shell { display: block; min-height: auto; }
  .sidebar { display: none; }
  .topbar { padding: 16px 16px 13px; align-items: flex-start; }
  .topbar h1 { font-size: 24px; }
  .topbar p { display: none; }
  .mobile-brand { display: block; }
  .topbar-actions { gap: 7px; }
  .role-control > span, .student-control > span { display: none; }
  .avatar { display: none; }
  select { max-width: 132px; min-height: 40px; }
  .content { padding: 10px 14px 24px; }
  .app-footer { padding: 12px 16px 18px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .student-layout { grid-template-columns: 1fr; }
  .student-list { max-height: 310px; }
  .event-grid { grid-template-columns: 1fr; }
  .resource-list { grid-template-columns: 1fr; }
  .session { grid-template-columns: 88px 1fr; }
  .session-room, .session .badge { grid-column: 2; }
  .timeline-row { grid-template-columns: 70px 1fr; }
  .timeline-row > .badge { grid-column: 2; width: max-content; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); z-index: 50; }
  .bottom-item { border: 0; min-width: 0; min-height: 50px; border-radius: 10px; background: transparent; color: #7a8796; display: grid; place-items: center; align-content: center; gap: 2px; }
  .bottom-item span { font-size: 18px; line-height: 1; }
  .bottom-item small { font-size: 9px; font-weight: 700; }
  .bottom-item.is-active { color: var(--blue); background: var(--blue-soft); }
  .toast { left: 14px; right: 14px; bottom: 84px; text-align: center; }
}

@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { min-height: 112px; padding: 14px; }
  .kpi-value { font-size: 26px; }
  .card-pad { padding: 14px; }
  .topbar { gap: 8px; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .topbar-actions select { width: 124px; }
  .my-hero { padding: 19px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e7edf5;
    --muted: #9aabba;
    --line: #2a3a4d;
    --surface: #101c2b;
    --surface-2: #091522;
    --blue-soft: #102b49;
    --success-soft: #102e24;
    --danger-soft: #351a1b;
    --warning-soft: #322510;
  }
  html, body { background: var(--surface-2); }
  .topbar { background: rgba(9,21,34,.92); }
  select, input[type="search"], .ghost-button, .availability-actions button, .resource-link, .student-row { background: var(--surface); color: var(--ink); }
  .schedule-day-head { background: #0d1928; }
  .segmented { background: #172536; }
  .segmented button.is-active { background: #26364a; color: white; }
  .date-tile { background: #152334; }
  .conflict-item { background: #251819; }
  .event-chip { background: #10283f; border-color: #264765; color: #b8d3ee; }
  .bottom-nav { background: rgba(16,28,43,.96); }
}
