:root {
  --bg: #F6F5F1;
  --card: #FFFFFF;
  --ink: #16211F;
  --ink-2: #4A5754;
  --ink-3: #6B7774;
  --line: #E4E2DA;
  --track: #ECEAE3;
  --primary: #0F5F55;
  --primary-hover: #0B4D45;
  --primary-soft: #E3F0EC;
  --accent: #E8743B;
  --ok: #15803D;
  --ok-soft: #E6F4EA;
  --warn: #B45309;
  --warn-soft: #FDF0DC;
  --full: #B42318;
  --full-soft: #FBE9E7;
  --radius: 16px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

.icon { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { display: inline-flex; }

.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 80px; }

/* ---------- Header ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text strong { font-size: 17px; }
.brand-text span { font-size: 13px; color: var(--ink-3); }
.support-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 14px; text-decoration: none; }
.support-pill:hover { background: #d4e8e1; }

/* ---------- Page ---------- */
.page { padding-top: 40px; padding-bottom: 64px; }
.intro { display: flex; flex-direction: column; gap: 8px; margin-bottom: 32px; }
.intro h1 { font-size: 34px; line-height: 1.2; letter-spacing: -0.5px; }
.intro p { color: var(--ink-2); font-size: 16px; line-height: 1.5; max-width: 640px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 32px; align-items: start; }

/* ---------- Filters ---------- */
.schedule-col { min-width: 0; }
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-weight: 600; font-size: 14px; }
.chip:hover { border-color: #cfccc1; }
.chip[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.toggle input:checked + .switch { background: var(--primary); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Schedule list ---------- */
.schedule-list { display: flex; flex-direction: column; gap: 16px; }
.week-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--ink-3); margin-top: 8px; }
.week-label:first-child { margin-top: 0; }

.card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 180px 28px;
  grid-template-areas: "date info badge radio" "date info cap radio";
  column-gap: 20px; row-gap: 8px; align-items: center;
  width: 100%; padding: 20px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.card:not(:disabled):hover { border-color: #bfd9d1; box-shadow: 0 4px 14px rgba(22,33,31,.06); }
.card:focus-visible { outline: 3px solid rgba(15,95,85,.35); outline-offset: 2px; }
.card[aria-checked="true"] { border: 2px solid var(--primary); padding: 19px; }
.card:disabled { cursor: not-allowed; background: #FAFAF8; opacity: .85; }

.date-block { grid-area: date; align-self: center; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.date-block .wd, .date-block .mo { font-size: 12px; }
.date-block .wd { font-weight: 600; }
.date-block .d { font-size: 24px; font-weight: 700; line-height: 1.1; }
.card[aria-checked="true"] .date-block { background: var(--primary); color: #fff; }
.date-m { grid-area: dm; display: none; font-size: 13px; font-weight: 700; color: var(--primary); }

.info { grid-area: info; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.course { font-size: 18px; font-weight: 700; }
.card:disabled .course { color: var(--ink-3); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 14px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta .icon { color: var(--ink-3); font-size: 15px; }

.badge { grid-area: badge; justify-self: end; align-self: end; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.full { background: var(--full-soft); color: var(--full); }

.cap { grid-area: cap; align-self: start; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.bar { width: 100%; height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; }
.bar i.ok { background: var(--ok); } .bar i.warn { background: var(--warn); } .bar i.full { background: var(--full); }
.cap-text { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.cap-text.full { color: var(--full); }

.radio { grid-area: radio; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; }
.card[aria-checked="true"] .radio { background: var(--primary); border-color: var(--primary); }
.card:disabled .radio { background: var(--track); border-color: transparent; color: var(--ink-3); font-size: 14px; }

.skeleton { height: 108px; border-radius: var(--radius); background: linear-gradient(90deg, #eeece6 25%, #f6f5f1 50%, #eeece6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty, .load-error { padding: 32px; text-align: center; color: var(--ink-2); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.load-error button { margin-top: 12px; }

/* ---------- Form panel ---------- */
.form-panel {
  position: sticky; top: 24px;
  display: flex; flex-direction: column; gap: 20px;
  padding: 28px; border-radius: 20px; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(22,33,31,.06);
}
.form-panel h2 { font-size: 22px; }
.back-btn { display: none; align-items: center; gap: 8px; padding: 0; border: 0; background: none; font-weight: 600; color: var(--ink-2); }

.summary { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: var(--primary-soft); }
.summary-head { display: flex; justify-content: space-between; align-items: center; }
.caption { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--primary); text-transform: uppercase; }
.link { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 600; font-size: 13px; text-decoration: underline; }
.summary-course { font-size: 17px; font-weight: 700; }
.summary-when { font-size: 14px; color: var(--ink-2); }
.summary-seats { font-size: 13px; font-weight: 600; }
.summary-seats.ok { color: var(--ok); } .summary-seats.warn { color: var(--warn); } .summary-seats.full { color: var(--full); }
.summary-empty { font-size: 14px; color: var(--ink-2); }
.summary.need { outline: 2px solid var(--full); }

form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 600; }
.req { color: var(--accent); }
.input { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink-3); font-size: 18px; transition: border-color .15s, box-shadow .15s; }
.input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--ink); font-size: 16px; }
.input input::placeholder { color: #9AA4A1; }
.err { display: none; align-items: center; gap: 6px; font-size: 13px; color: var(--full); }
.field.invalid .input { border-color: var(--full); box-shadow: 0 0 0 1px var(--full); color: var(--full); }
.field.invalid .err { display: flex; }

.turnstile { min-height: 65px; }
.turnstile:empty { min-height: 0; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--full-soft); color: var(--full); font-size: 14px; font-weight: 500; }
.alert.info { background: var(--warn-soft); color: var(--warn); }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; transition: background .15s; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-primary.small { width: auto; height: 48px; font-size: 15px; }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.btn-secondary:hover { border-color: #cfccc1; }
.btn-dark { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 44px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; }
.btn-dark:disabled { opacity: .7; cursor: progress; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.privacy { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; }
.privacy .icon { color: var(--ok); font-size: 15px; }

/* ---------- Result views ---------- */
.result { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; align-items: stretch; padding-top: 8px; }
.result-top { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.result-badge { width: 88px; height: 88px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.result-badge span { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px; }
.result-badge.ok { background: var(--ok-soft); } .result-badge.ok span { background: var(--ok); }
.result-badge.full { background: var(--full-soft); } .result-badge.full span { background: var(--full); }
.result-badge.wait { background: var(--warn-soft); } .result-badge.wait span { background: var(--warn); }
.result h1 { font-size: 26px; line-height: 1.25; }
.result-top p { color: var(--ink-2); line-height: 1.5; }

.ticket { border-radius: 16px; background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.ticket-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--primary); color: #fff; }
.ticket-head .caption { color: rgba(255,255,255,.75); }
.ticket-head strong { letter-spacing: 1px; }
.ticket-body { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.ticket-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.ticket-row span { color: var(--ink-3); }
.ticket-row b { text-align: right; font-weight: 600; }

.note { display: flex; gap: 10px; padding: 14px; border-radius: 12px; background: var(--warn-soft); color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.note .icon { color: var(--warn); font-size: 18px; margin-top: 2px; }

.alt-caption { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--ink-3); }
.alt-list { display: flex; flex-direction: column; gap: 12px; }
.alt { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.alt-text { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.alt-date { font-size: 13px; font-weight: 700; color: var(--primary); }
.alt-course { font-weight: 600; }
.alt-seats { font-size: 12px; font-weight: 600; color: var(--ok); }
.alt-seats.warn { color: var(--warn); }
.alt button { padding: 9px 16px; border-radius: 10px; border: 0; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.alt button:hover { background: #d4e8e1; }

.waitlist { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; border: 1.5px dashed var(--line); }
.waitlist-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.waitlist p { font-size: 13px; color: var(--ink-2); }

/* ---------- Mobile bottom bar ---------- */
.mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(22,33,31,.08); }
.mbar-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mbar-info .caption { color: var(--ink-3); text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; }
.mbar-info strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .container { padding: 0 32px; }
  .layout { grid-template-columns: minmax(0, 1fr) 380px; }
}

@media (max-width: 900px) {
  .container { padding: 0 20px; }
  .header-inner { padding-top: 14px; padding-bottom: 14px; }
  .logo { width: 32px; height: 32px; border-radius: 8px; font-size: 18px; }
  .brand-text strong { font-size: 16px; }
  .brand-text span { display: none; }
  .support-pill { padding: 8px 12px; font-size: 13px; }
  .page { padding-top: 20px; padding-bottom: 120px; }
  .intro { margin-bottom: 16px; }
  .intro h1 { font-size: 24px; }
  .intro p { font-size: 14px; }
  .layout { grid-template-columns: minmax(0, 1fr); }

  /* Bước 1: chỉ hiện danh sách; Bước 2: chỉ hiện form */
  .form-panel { display: none; position: static; padding: 0; border: 0; box-shadow: none; background: none; }
  body.step-form .form-panel { display: flex; }
  body.step-form .schedule-col, body.step-form .intro { display: none; }
  .back-btn { display: inline-flex; }
  .form-panel h2 { font-size: 20px; }
}

@media (max-width: 640px) {
  .support-pill #support-text { display: none; }
  .support-pill { padding: 9px; }
  .filter-bar { margin-bottom: 4px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; padding: 7px 14px; font-size: 13px; }
  .schedule-list { gap: 12px; }
  .card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "dm badge" "info info" "cap cap";
    padding: 16px; row-gap: 8px; border-radius: 14px;
  }
  .card[aria-checked="true"] { padding: 15px; }
  .date-block, .radio { display: none; }
  .date-m { display: block; }
  .badge { align-self: center; padding: 3px 9px; font-size: 11px; }
  .course { font-size: 16px; }
  .meta { font-size: 13px; gap: 4px 12px; }
  .meta .icon { font-size: 14px; }
  .cap { flex-direction: row; align-items: center; gap: 10px; }
  .cap-text { font-size: 12px; }
  .result h1 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
