:root {
  --navy: #243982;
  --navy-2: #1b2c66;
  --navy-soft: #eef1fa;
  --red: #c9251b;
  --red-soft: #fdeeed;
  --red-2: #a91e16;
  --hero-2: #34489a;
  --accent-glow: rgba(201, 37, 27, .35);
  --focus: rgba(36, 57, 130, .25);
  --navy-line: #c7cfee;
  --bg: #f4f5f9;
  --card: #ffffff;
  --ink: #1b2133;
  --muted: #5f6880;
  --line: #e2e5ee;
  --free: #e9f6ef;
  --free-line: #a9dbbf;
  --free-ink: #11643c;
  --warn: #fff5e6;
  --warn-ink: #8a5300;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- header ---------- */
.top {
  background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.top-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 16px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--red); display: grid; place-items: center; font-size: .8rem; overflow: hidden; flex: 0 0 auto; }
.brand-mark.has-logo { background: #fff; width: auto; min-width: 34px; height: 36px; padding: 3px 5px; display: flex; align-items: center; }
.brand-mark.has-logo img { height: 30px; width: auto; max-width: 140px; object-fit: contain; display: block; }
.swatch-row { display: flex; gap: 10px; align-items: center; }
.swatch-row input[type=color] { width: 46px; height: 38px; padding: 2px; border: 1px solid #cfd4e0; border-radius: 9px; background: #fff; }
.brand-preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.logo-preview { max-height: 60px; max-width: 220px; display: block; background: #fff; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.brand small { font-weight: 500; opacity: .75; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: rgba(255, 255, 255, .82); text-decoration: none; padding: 7px 11px; border-radius: 8px; font-weight: 500; font-size: .94rem; }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.top-right .who { opacity: .85; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-top { background: rgba(255, 255, 255, .12); border: 0; color: #fff; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.btn-top:hover { background: rgba(255, 255, 255, .22); }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; opacity: .9; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .25); }
.live-dot.off::before { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .25); }
.as-banner { background: var(--warn); color: var(--warn-ink); border-bottom: 1px solid #f1d7a8; }
.as-banner .wrap { display: flex; gap: 12px; align-items: center; padding-top: 9px; padding-bottom: 9px; }

/* ---------- layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 76px; }
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .side-first { order: -1; }
}

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .92rem; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #c5cad8; background: #fafbfd; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-2); border-color: var(--red-2); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: .84rem; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd4e0; border-radius: 9px; background: #fff;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--navy); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; }
.row > .shrink { flex: 0 0 auto; }

/* ---------- pills, stats ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--navy-soft); color: var(--navy); white-space: nowrap; }
.pill-open { background: var(--free); color: var(--free-ink); }
.pill-upcoming { background: var(--warn); color: var(--warn-ink); }
.pill-closed { background: #eef0f3; color: #556; }
.pill-draft { background: #f1eefb; color: #5b3fb0; }
.pill-archived { background: #eceef2; color: #4a5263; }
.pill-PLP { background: var(--navy-soft); color: var(--navy); }
.pill-LIA { background: var(--red-soft); color: var(--red); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.bar { height: 7px; background: #e8ebf2; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }

/* ---------- banners ---------- */
.banner { border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.banner-open { background: var(--free); color: var(--free-ink); border: 1px solid var(--free-line); }
.banner-upcoming { background: var(--warn); color: var(--warn-ink); border: 1px solid #f1d7a8; }
.banner-closed { background: #eef0f3; color: #445; border: 1px solid #dde0e6; }
.countdown { display: flex; gap: 8px; margin-left: auto; }
.countdown div { background: #fff; border-radius: 9px; padding: 6px 10px; text-align: center; min-width: 56px; box-shadow: var(--shadow); }
.countdown b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.countdown span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- event hero ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--hero-2) 100%); color: #fff; border-radius: var(--radius); padding: 22px; margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: var(--accent-glow); }
.hero h1 { color: #fff; position: relative; z-index: 1; }
.hero p { margin: .3em 0; opacity: .92; max-width: 760px; position: relative; z-index: 1; }
.hero .meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; opacity: .95; margin-top: 10px; position: relative; z-index: 1; }
.hero .pill { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- children tabs, day tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab small { font-weight: 500; opacity: .75; margin-left: 4px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- teacher cards + chips ---------- */
.tcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.tcard-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.tcard-head .booked-badge { margin-left: auto; }
.daylabel { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 10px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 10px; min-width: 70px; text-align: center; font-weight: 600; font-size: .9rem; cursor: default; font-variant-numeric: tabular-nums; line-height: 1.15; }
.chip small { display: block; font-weight: 500; font-size: .7rem; margin-top: 2px; }
.chip-free { background: var(--free); border-color: var(--free-line); color: var(--free-ink); cursor: pointer; }
.chip-free:hover { background: #d6efe1; border-color: #6fc297; transform: translateY(-1px); }
.chip-mine { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip-family { background: var(--navy-soft); border-color: var(--navy-line); color: var(--navy); }
.chip-full { background: #f2f3f6; color: #9aa1b2; text-decoration: line-through; }
.chip-clash, .chip-close, .chip-locked, .chip-notopen { background: #fafbfc; color: #a7adbd; border-style: dashed; }
.chip-notopen { color: #6a7287; border-style: solid; }
.chip.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 100% { box-shadow: 0 0 0 12px transparent; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }

/* ---------- schedule list ---------- */
.sched { list-style: none; padding: 0; margin: 0; }
.sched li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.sched li:first-child { border-top: 0; }
.sched .time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 54px; color: var(--navy); }
.sched .time small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }
.sched .what { flex: 1; min-width: 0; }
.sched .what div { overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
tr.slot-free td { color: var(--muted); }
tr.slot-blocked td { background: repeating-linear-gradient(-45deg, #fafbfc, #fafbfc 8px, #f3f4f7 8px, #f3f4f7 16px); color: #9aa1b2; }
tr.slot-now td { background: #fffbe8; }
.bk { padding: 4px 0; }
.bk + .bk { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }
.att { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.att button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: .84rem; color: var(--muted); }
.att button + button { border-left: 1px solid var(--line); }
.att button.on-1 { background: var(--free-ink); color: #fff; }
.att button.on-0 { background: var(--red); color: #fff; }
.note-input { margin-top: 6px; font-size: .86rem; padding: 6px 9px !important; }
.copybox { display: flex; gap: 8px; }
.copybox input { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 420px; }
.login .card { padding: 26px; }
.login .lang { text-align: right; margin-bottom: 10px; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.demo { margin-top: 16px; }
.demo .btn { width: 100%; justify-content: space-between; margin-top: 6px; }
.notice { background: var(--warn); color: var(--warn-ink); border-radius: 9px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }
.error { background: var(--red-soft); color: #9b1c14; border-radius: 9px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }

/* ---------- modal + toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 40, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-wide { max-width: 640px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal .big { font-size: 1.15rem; font-weight: 700; margin: 6px 0; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 460px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); animation: fade .2s ease; font-weight: 500; }
.toast-ok { background: var(--free-ink); }
.toast-err { background: #9b1c14; }

/* ---------- admin bits ---------- */
.windows .row { margin-bottom: 8px; }
.teacher-checks { columns: 3 200px; margin: 8px 0; }
.teacher-checks label { display: flex; gap: 6px; padding: 3px 0; break-inside: avoid; font-size: .92rem; }
.result-box { background: #f7f8fb; border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-size: .9rem; margin-top: 12px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-title .actions { margin-left: auto; display: flex; gap: 8px; }
.log { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .top, .as-banner, .no-print, #toasts, .actions, .tabs, .toolbar, .legend { display: none !important; }
  .print-only { display: block; }
  .wrap { padding: 0; max-width: none; }
  .card, .tcard, .hero { box-shadow: none; border: 1px solid #ccc; }
  .hero { background: none; color: #000; } .hero h1 { color: #000; } .hero::after { display: none; }
  .two-col { display: block; }
  .note-input { border: 0 !important; }
  tr { page-break-inside: avoid; }
}
