/* Timetable & Relief Cloud - demonstration build, Family Chat Cloud Pte Ltd. Sample data only. */
:root {
  --brand: #1c2d6b; --brand-dark: #121e4a; --brand-soft: #eef1f9; --accent: #e8b800; --accent-ink: #5a4500; --accent2: #c0392b;
  --ink: #172033; --muted: #5d6b82; --line: #dde3ec; --bg: #f4f6fa; --card: #fff;
  --ok: #157f3b; --ok-bg: #e5f5eb; --warn: #9a6200; --warn-bg: #fff4d6; --bad: #b42318; --bad-bg: #fdeceb; --info: #1d5fb8; --info-bg: #e7f0fc;
  --r: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --demo-h: 30px; --hdr-h: 60px; --nav-w: 236px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 10px; }
h4 { font-size: 14px; margin: 14px 0 8px; }
p { margin: 0 0 10px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .bad-t { color: var(--bad); font-weight: 600; }
.nowrap { white-space: nowrap; }
.dim { opacity: .55; }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: 4px 0; }
.steps { margin: 0 0 12px; padding-left: 20px; } .steps li { margin-bottom: 6px; }
[hidden] { display: none !important; }

/* Demo bar and header */
.demo-bar { position: sticky; top: 0; z-index: 60; height: var(--demo-h); display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 12px; background: repeating-linear-gradient(135deg, #fff6d0 0 12px, #ffefb0 12px 24px); color: #4a3800; font-size: 12px; border-bottom: 1px solid #e8d48a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdr { position: sticky; top: var(--demo-h); z-index: 50; height: var(--hdr-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.hdr-navy #hdr { background: var(--brand); color: #fff; border-bottom: 3px solid var(--accent); }
.hdr-light #hdr { border-bottom: 3px solid var(--brand); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand span { display: flex; flex-direction: column; min-width: 0; } .brand b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { opacity: .8; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; line-height: 0; position: relative; font-size: 22px; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.nav-toggle { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(127,127,127,.14); font-size: 12px; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.bell .count { position: absolute; top: 0; right: 0; background: var(--accent2); color: #fff; font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 8px; }
.hdr-light .bell .count { background: var(--bad); }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid rgba(127,127,127,.3); color: inherit; border-radius: 999px; padding: 3px 12px 3px 3px; cursor: pointer; text-align: left; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.u-meta { display: flex; flex-direction: column; } .u-meta small { opacity: .75; font-size: 11px; }

/* Layout and nav */
.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - var(--demo-h) - var(--hdr-h)); }
#nav { background: #fff; border-right: 1px solid var(--line); padding: 12px 10px; position: sticky; top: calc(var(--demo-h) + var(--hdr-h)); height: calc(100vh - var(--demo-h) - var(--hdr-h)); overflow-y: auto; }
.nav-sec { margin-bottom: 12px; }
.nav-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 10px; }
#nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
#nav a:hover { background: var(--brand-soft); }
#nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.nb { background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.nb.warn { background: var(--bad); color: #fff; }
.nav-foot { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); padding: 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.nav-scrim { display: none; }
#main { padding: 20px 24px 60px; min-width: 0; outline: none; }

/* Page furniture */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); max-width: 820px; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.empty, .empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; } .grid2 { margin-bottom: 16px; }
.grid2.wide-l { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.row { display: flex; align-items: center; } .row.gap { gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-y { max-height: 340px; overflow-y: auto; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0; }
.note-box { background: var(--info-bg); border-left: 4px solid var(--info); padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--info-bg); border-left: 4px solid var(--info); }
.alert.warn { background: var(--warn-bg); border-color: #e0a100; }
.alert.bad { background: var(--bad-bg); border-color: var(--bad); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok); }
.print-title { display: none; }
.date-h { margin: 0; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border: 1px solid #c9d1de; background: #fff; color: var(--ink); border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f3f5f9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: var(--warn-bg); border-color: #e0a100; color: #6b4500; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.block { display: flex; width: 100%; margin-bottom: 12px; }
.btn.has { border-color: var(--ok); color: var(--ok); }
.btn.file { position: relative; overflow: hidden; } .btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; padding: 7px 9px; border: 1px solid #c9d1de; border-radius: 8px; background: #fff; max-width: 100%; }
input[type=checkbox], input[type=radio] { padding: 0; width: 16px; height: 16px; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
select[multiple] { min-height: 120px; }
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.form.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .span2, .span2 { grid-column: 1 / -1; }
.form input, .form select, .form textarea { width: 100%; }
.form label.check input { width: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.period-range { align-items: flex-end; }
.period-range label { min-width: 100px; }
.w50 { width: 50%; } .w30 { width: 30%; }
.seg { display: inline-flex; border: 1px solid #c9d1de; border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; font: inherit; cursor: pointer; border-right: 1px solid #e4e8ef; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.dd { position: relative; display: inline-block; }

/* Stats, badges, bars */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; border-top: 4px solid var(--brand); box-shadow: var(--shadow); min-width: 0; }
.stat.ok { border-top-color: var(--ok); } .stat.warn { border-top-color: #e0a100; } .stat.bad { border-top-color: var(--bad); }
.stat-v { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; } .stat-l { color: var(--muted); font-size: 12px; } .stat-n { font-size: 12px; margin-top: 4px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eceff4; color: #3b475c; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.bar { display: inline-block; width: 100%; min-width: 60px; height: 8px; background: #eceff4; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bar.ok i { background: var(--ok); } .bar.warn i { background: #e0a100; } .bar.bad i { background: var(--bad); }
.progress { height: 10px; background: #e6eaf1; border-radius: 5px; overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .25s; }
.gen-prog p { margin: 4px 0; font-size: 13px; }
.spark { white-space: nowrap; } .spark i { display: inline-block; width: 6px; margin-right: 2px; background: var(--brand); vertical-align: bottom; border-radius: 1px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.1); }

/* Tables */
table { border-collapse: collapse; }
.data { width: 100%; font-size: 13px; }
.data th, .data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data thead th { background: #f7f8fb; font-size: 12px; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
.data.compact th, .data.compact td { padding: 5px 8px; }
.data.hover tbody tr:hover { background: #f7f9fd; }
.data tr.cur { background: var(--brand-soft); }
.data td.win { background: var(--ok-bg); font-weight: 700; }
.data .empty { padding: 16px; }
.mini { font-size: 12px; width: 100%; } .mini th, .mini td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.relief-t tr.st-uncovered { background: var(--bad-bg); } .relief-t tr.st-merged { background: var(--info-bg); } .relief-t tr.st-assigned td:first-child { border-left: 3px solid var(--ok); }
dl.dd { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; } dl.dd dt { color: var(--muted); } dl.dd dd { margin: 0; font-weight: 600; }

/* Timetable grid */
.tt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.tt-layout > .tt-wrap:only-child { grid-column: 1 / -1; }
.tt-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.tt { width: 100%; table-layout: fixed; font-size: 12px; min-width: 620px; }
.tt.wide { min-width: 1100px; }
.tt th, .tt td { border: 1px solid #e3e7ee; padding: 3px; vertical-align: top; }
.tt thead th { background: var(--brand); color: #fff; padding: 6px 4px; font-size: 12px; }
.tt .pcol { width: 76px; background: #f7f8fb; color: var(--ink); text-align: left; font-weight: 400; }
.tt thead .pcol { background: var(--brand-dark); color: #fff; }
.tt .pcol b { display: block; } .tt .pcol small { color: var(--muted); font-size: 10px; }
.tt td { height: 48px; }
.tt.compact td { height: 36px; } .tt.compact { min-width: 0; font-size: 11px; }
.tt tr.brk td, .tt tr.brk th { height: auto; background: repeating-linear-gradient(45deg, #f4f6fa 0 6px, #eceff4 6px 12px); color: var(--muted); font-size: 11px; text-align: center; padding: 2px; }
.chip-l { background: color-mix(in srgb, var(--c) 28%, #fff); border-left: 4px solid var(--c); border-radius: 5px; padding: 3px 5px; margin-bottom: 2px; cursor: pointer; overflow: hidden; }
.chip-l b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-l small { display: block; font-size: 10.5px; color: #3b475c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-l.blk:not(.first) { opacity: .8; border-left-style: dashed; }
.chip-l.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.pin { color: var(--accent2); font-size: 9px; }
.tt td.tg-ok { background: #e7f7ec; cursor: pointer; } .tt td.tg-ok:hover { background: #c9edd5; }
.tt td.tg-warn { background: #fff5dc; cursor: pointer; } .tt td.tg-bad { background: #fde8e6; } .tt td.tg-cur { background: #fff8c4; }
.lesson-panel { position: sticky; top: calc(var(--demo-h) + var(--hdr-h) + 12px); }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin: 10px 0; }
.cmp th { text-align: left; }
.cmp-grids .tt { min-width: 0; }

/* Relief grid, venue grid, preference grid, heatmap */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid #cfd6e2; background: #fff; vertical-align: -2px; margin-right: 4px; }
.lg.t, .tgrid td.t { background: #e4e9f3; } .lg.rf, .tgrid td.rf { background: #cfe6ff; color: #0b3f7a; font-weight: 700; }
.lg.abs, .tgrid td.abs { background: #fde2df; color: var(--bad); } .lg.rel, .tgrid td.rel { background: #e3f6e8; color: var(--ok); }
.lg.lesson, .tgrid td.lesson { background: #e4e9f3; } .lg.booking, .tgrid td.booking { background: #ffe9b3; color: #6b4500; } .lg.freed, .tgrid td.freed { background: #e3f6e8; color: var(--ok); }
.lg.un, .pref-grid td.un { background: #f7c4bf; } .lg.av, .pref-grid td.av { background: #ffe7a6; } .lg.rb, .pref-grid td.rb { box-shadow: inset 0 0 0 3px #7b61ff; } .lg.rb { background: #e6e0ff; }
.tgrid { width: 100%; font-size: 11px; background: #fff; }
.tgrid th, .tgrid td { border: 1px solid #e3e7ee; padding: 4px 5px; white-space: nowrap; text-align: left; }
.tgrid thead th { background: #f7f8fb; position: sticky; top: 0; }
.tgrid tbody th { background: #fbfcfe; font-weight: 600; min-width: 140px; position: sticky; left: 0; z-index: 1; }
.tgrid td { min-width: 64px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.venue-grid td.free { cursor: pointer; } .venue-grid td.free:hover, .venue-grid td.freed:hover { background: var(--brand-soft); }
.venue-grid td.freed { cursor: pointer; }
.pref-grid { border-collapse: collapse; user-select: none; -webkit-user-select: none; touch-action: none; }
.pref-grid th, .pref-grid td { border: 1px solid #d7dde8; padding: 4px 6px; font-size: 11px; }
.pref-grid td { width: 44px; height: 26px; cursor: pointer; background: #fff; }
.heat-t td.heat { background: color-mix(in srgb, var(--brand) calc(var(--v) * 85%), #fff); min-width: 26px; }

/* Leave, events, handover, email */
.class-pick { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.class-pick > div { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.handover { display: grid; gap: 12px; }
.ho-venue { display: flex; flex-direction: column; background: var(--brand-soft); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 14px; }
.ho-venue b { font-size: 18px; color: var(--brand); }
.msgs { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; margin-bottom: 8px; }
.msg { background: #f1f3f7; border-radius: 10px; padding: 7px 10px; max-width: 85%; align-self: flex-start; }
.msg.me { background: var(--brand-soft); align-self: flex-end; }
.files { list-style: none; padding: 0; margin: 0 0 8px; } .files li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.x { background: none; border: 0; color: var(--bad); cursor: pointer; font-size: 16px; }
.email { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.email-h { background: #f7f8fb; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12px; display: grid; gap: 2px; }
.email-b { padding: 14px; font-size: 13px; overflow-x: auto; }
.email-b table { border-collapse: collapse; width: 100%; } .email-b th, .email-b td { border: 1px solid #dfe4ec; padding: 4px 6px; text-align: left; font-size: 12px; }

/* Notifications and day list */
.notes { list-style: none; padding: 0; margin: 0 0 12px; }
.notes li { border-bottom: 1px solid var(--line); }
.notes li a { display: grid; gap: 1px; padding: 9px 4px; text-decoration: none; color: var(--ink); }
.notes li a:hover { background: #f7f9fd; }
.notes li span { color: #3b475c; font-size: 13px; } .notes li small { color: var(--muted); }
.notes li.unread a { border-left: 3px solid var(--accent2); padding-left: 8px; background: #fffdf5; }
.day-list { list-style: none; padding: 0; margin: 0 0 12px; }
.day-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dl-p { display: flex; flex-direction: column; width: 84px; } .dl-p small, .dl-b small { color: var(--muted); }
.dl-b { display: flex; flex-direction: column; flex: 1; min-width: 120px; }
.day-list li.k-relief { background: var(--info-bg); border-left: 3px solid var(--info); }
.day-list li.k-released { opacity: .7; } .day-list li.k-leave { background: var(--warn-bg); }

/* Login */
body.embedded #hdr, body.embedded #nav, body.embedded .nav-scrim { display: none; }
body.embedded .layout { display: block; }
.login { min-height: calc(100vh - var(--demo-h)); display: grid; place-items: center; padding: 20px 0; background: linear-gradient(160deg, var(--brand-soft), #fff); margin: -20px -24px -60px; }
.login-card { width: min(640px, 100% - 32px); background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(16,24,40,.14); border-top: 6px solid var(--brand); }
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; } .login-brand h1 { margin: 0; } .login-brand p { margin: 0; color: var(--muted); }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 14px; }
.role-card { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.role-card:hover { border-color: var(--brand); background: var(--brand-soft); }
.role-card span { color: var(--muted); font-size: 12px; }
.login-card > label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin-bottom: 12px; }

/* Phone previews */
.phones { display: flex; flex-wrap: wrap; gap: 32px; justify-content: center; }
.phones figure { margin: 0; text-align: center; max-width: 360px; }
.phones figcaption { font-size: 13px; color: var(--muted); margin-top: 10px; }
.phone { width: 360px; max-width: calc(100vw - 48px); height: 720px; border: 12px solid #111827; border-radius: 42px; overflow: hidden; background: #fff; box-shadow: 0 24px 60px rgba(16,24,40,.28); position: relative; }
.phone::before { content: ""; position: absolute; top: 6px; left: 50%; width: 90px; height: 20px; margin-left: -45px; background: #111827; border-radius: 12px; z-index: 2; }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }

/* In-app (mobile) mode */
body.app-mode .demo-bar, body.app-mode #hdr, body.app-mode #nav, body.app-mode .nav-scrim { display: none; }
body.app-mode .layout { display: block; }
body.app-mode #main { padding: 0; }
.app-shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 560px; margin: 0 auto; background: #f4f6fa; position: relative; }
.app-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 30px 14px 10px; background: var(--brand); color: #fff; }
.app-top b { font-size: 17px; }
.app-user { margin-left: auto; font-size: 12px; opacity: .85; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bell { background: var(--accent2); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; text-decoration: none; }
.app-demo { background: #fff4d0; color: #4a3800; font-size: 11px; text-align: center; padding: 2px; }
.app-body { flex: 1; padding: 12px 12px 84px; }
.app-tabs { position: sticky; bottom: 0; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.app-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px; font-size: 11px; color: var(--muted); text-decoration: none; }
.app-tabs a span { font-size: 18px; line-height: 1.1; }
.app-tabs a.on { color: var(--brand); font-weight: 700; }
.app-exit { position: fixed; right: 12px; bottom: 76px; background: #111827; color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 12px; text-decoration: none; }
.app-hero { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; display: flex; flex-direction: column; }
.app-hero b { font-size: 24px; } .app-hero small, .app-hero span { opacity: .9; }
.app-alert { background: var(--info-bg); border-left: 4px solid var(--info); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.app-card { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; color: var(--ink); text-decoration: none; }
.app-card > div:first-child { display: flex; flex-direction: column; } .app-card small { color: var(--muted); }
.app-card .venue { font-size: 16px; font-weight: 700; color: var(--brand); }
.app-days { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 4px; }
.app-days button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; }
.app-days button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.app-section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.app-section h4 { margin-top: 0; }
.app-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; text-align: center; }
.app-stats span { background: #f4f6fa; border-radius: 8px; padding: 6px 2px; font-size: 11px; display: flex; flex-direction: column; } .app-stats b { font-size: 18px; }
.app-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.app-row small { color: var(--muted); text-align: right; }
.app-shell .handover .card, .app-shell .card { padding: 12px; }
.app-shell .modal-box { max-width: 100%; }

/* Links, audit */
.link-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.link-groups .card { margin-bottom: 0; }
.links { list-style: none; padding: 0; margin: 0; }
.links li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.links li small { grid-column: 1; }
.links li .btn { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

/* Modal and toasts */
#modal { display: none; }
#modal.open { display: block; position: fixed; inset: 0; z-index: 100; }
.modal-back { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal-box { position: relative; margin: 6vh auto 0; width: min(560px, calc(100% - 24px)); max-height: 88vh; display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-box.wide { width: min(940px, calc(100% - 24px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal-foot .danger { margin-right: auto; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.toast { background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 13px; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--ok); } .toast.warn { background: #8a5a00; } .toast.bad { background: var(--bad); } .toast.info { background: #1e3a6b; } .toast.note { background: #fff; color: var(--ink); border-left: 4px solid var(--accent2); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Boot */
#boot { position: fixed; inset: var(--demo-h) 0 0 0; z-index: 90; background: var(--brand-soft); display: grid; place-items: center; }
.boot-card { width: min(460px, calc(100% - 32px)); background: #fff; border-radius: 16px; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(16,24,40,.14); }

/* Responsive */
@media (max-width: 1100px) {
  .tt-layout { grid-template-columns: 1fr; }
  .lesson-panel { position: static; }
}
@media (max-width: 900px) {
  :root { --hdr-h: 56px; }
  .layout { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  #nav { position: fixed; top: calc(var(--demo-h) + var(--hdr-h)); left: 0; bottom: 0; height: auto; width: 270px; z-index: 70; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
  body.nav-open #nav { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15,23,42,.35); }
  .grid2, .grid2.wide-l, .form.cols2 { grid-template-columns: 1fr; }
  .u-meta, .date-chip { display: none; }
  .user-btn { padding: 3px; }
}
@media (max-width: 600px) {
  #main { padding: 14px 16px 60px; }
  .demo-bar span { display: none; }
  .brand small, .presence { display: none; }
  .brand b { font-size: 14px; max-width: 42vw; }
  .page-head h1 { font-size: 19px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { margin: -14px -16px -60px; }
  .w50, .w30 { width: auto; }
  .modal-box { margin-top: 2vh; max-height: 94vh; }
}

/* Print */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .demo-bar { position: static; background: none; border: 0; color: #555; height: auto; font-size: 9px; }
  #hdr, #nav, .nav-scrim, .toolbar, .page-actions, .tabs, .noprint, #toasts, #modal, .btn, .seg, .hint, .lesson-panel, .app-tabs, .app-exit { display: none !important; }
  .layout { display: block; } #main { padding: 0; }
  .print-title { display: block; margin-bottom: 8px; font-size: 13px; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .tt-wrap, .scroll-x { overflow: visible; border: 0; }
  .tt, .tt.wide, .tgrid { min-width: 0; width: 100%; font-size: 9px; }
  .tt td { height: 34px; }
  .tt thead th { background: #eee !important; color: #000; }
  .chip-l, .tgrid td, .heat-t td.heat, .lg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .data thead th { position: static; }
  a { color: inherit; text-decoration: none; }
}
