:root {
  --hust: #b4161b;
  --hust-dark: #8c1015;
  --bg: #f4f6fa;
  --card: #fff;
  --text: #1d2433;
  --muted: #6b7385;
  --line: #e3e7ef;
  --free: #e9f7ef;
  --free-b: #3fb36b;
  --sel: #1f6feb;
  --booked: #e5484d;
  --mine: #f59e0b;
  --past: #eceef2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
body.has-checkout { padding-bottom: 150px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f7f8fb; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 14px 18px; font-size: 16px; width: 100%; }
.btn.primary { background: var(--hust); border-color: var(--hust); color: #fff; }
.btn.primary:hover { background: var(--hust-dark); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.danger { background: var(--booked); border-color: var(--booked); color: #fff; }
.btn.danger-ghost { color: var(--booked); border-color: #f5c2c4; }
.btn.ghost { background: transparent; }
.icon { border: 0; background: none; font-size: 22px; cursor: pointer; padding: 0 8px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #b4161b 0%, #6d0b0f 100%); }
.login-card { background: #fff; border-radius: 18px; padding: 36px 30px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 20px; margin: 16px 0 6px; }
.login-buttons { display: grid; gap: 10px; margin-top: 22px; }
.logo { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--hust);
  color: #fff; font-weight: 800; letter-spacing: .5px; }
.logo.sm { width: 42px; height: 42px; border-radius: 11px; font-size: 13px; }
.alert { background: #fdecec; color: #a3191e; padding: 10px 12px; border-radius: 10px; margin-top: 14px; font-size: 14px; }

/* ---------- layout ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .title { font-weight: 700; }
.brand .sub { font-size: 13px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.layout { display: grid; grid-template-columns: 270px 1fr; gap: 20px; padding: 20px; max-width: 1280px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.tip { line-height: 1.5; }

/* ---------- mini month ---------- */
.month-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.month-head select { flex: 1; padding: 6px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mini .mh { font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.mini .md { border: 0; background: none; padding: 7px 0; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; }
.mini .md:hover { background: #f1f3f7; }
.mini .md.other { color: #b8bdc8; }
.mini .md.sun { color: #c8ccd4; }
.mini .md.inweek { background: #fdecec; }
.mini .md.today { background: var(--hust); color: #fff; font-weight: 700; }

/* ---------- legend ---------- */
.legend { display: grid; gap: 8px; font-size: 14px; }
.legend > div { display: flex; align-items: center; gap: 10px; }
.seat.demo { width: 26px; height: 26px; cursor: default; font-size: 12px; }

/* ---------- week nav ---------- */
.week-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.week-label { display: flex; align-items: center; gap: 10px; font-size: 17px; }

/* ---------- plane ---------- */
.plane { background: #fff; border: 1px solid var(--line); border-radius: 40px 40px 18px 18px; padding: 10px 18px 18px;
  box-shadow: 0 4px 20px rgba(20,30,60,.05); }
.nose { text-align: center; font-weight: 700; color: var(--hust); padding: 8px 0 12px; letter-spacing: .3px; }
.prow { display: grid; grid-template-columns: 78px 1fr 34px 1fr; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); }
.prow.head { border-top: 0; padding-bottom: 2px; }
.prow.today { background: linear-gradient(90deg, #fff4f4, transparent); border-radius: 10px; }
.plabel { display: flex; flex-direction: column; font-size: 14px; padding-left: 6px; }
.plabel span { color: var(--muted); font-size: 12px; }
.half { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.prow.head .half { display: block; }
.hh { font-weight: 700; font-size: 13px; text-align: center; margin-bottom: 4px; }
.hh span { color: var(--muted); font-weight: 500; }
.cols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.mlabel { display: none; }
.aisle { align-self: stretch; display: grid; place-items: center; }
.aisle span { writing-mode: vertical-rl; font-size: 9px; color: #c3c8d2; letter-spacing: 2px; text-transform: uppercase; }
.prow.head .aisle span { display: none; }

.seat {
  position: relative; aspect-ratio: 1 / 1.05; min-height: 40px; border-radius: 10px 10px 6px 6px;
  border: 2px solid var(--free-b); background: var(--free); cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0;
  transition: transform .08s, background .12s; color: #1c6b3e;
}
.seat::after { /* tay vịn ghế */
  content: ""; position: absolute; bottom: -2px; left: 18%; right: 18%; height: 4px; border-radius: 3px; background: currentColor; opacity: .25;
}
.seat .i { font-size: 13px; line-height: 1; min-height: 13px; }
.seat .t { font-size: 10px; font-weight: 600; opacity: .85; }
.seat.free:hover { transform: translateY(-2px); background: #d4f2e0; }
.seat.selected { background: var(--sel); border-color: var(--sel); color: #fff; transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(31,111,235,.35); }
.seat.booked { background: var(--booked); border-color: #c4373b; color: #fff; cursor: not-allowed; }
.seat.booked:hover { filter: brightness(1.05); }
.seat.mine { background: var(--booked); border-color: var(--mine); border-width: 3px; color: #fff; }
.seat.mine .i { color: #ffd76a; }
.seat.past { background: var(--past); border-color: #dcdfe5; color: #a6acb8; cursor: default; }
.seat.past::after { display: none; }
.seat.demo.free { background: var(--free); }

/* ---------- checkout bar ---------- */
.checkout { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(20,30,60,.12); z-index: 10; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.checkout-inner { max-width: 1280px; margin: 0 auto; padding: 14px 20px; display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 14px; align-items: center; }
.summary .chip { display: inline-block; background: #eaf1fe; color: #174ea6; border-radius: 999px; padding: 3px 10px; margin: 4px 4px 0 0; }
#purpose { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; width: 100%; }
.actions { display: flex; gap: 8px; }

/* ---------- dialog / toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,20,35,.45); }
dialog h3 { margin: 0 0 12px; }
dialog dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px; margin: 0; font-size: 14px; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.toast { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff;
  padding: 11px 18px; border-radius: 10px; z-index: 50; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.ok { background: #1f8a4c; }
.toast.err { background: var(--booked); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { order: 2; }
}
@media (max-width: 640px) {
  .layout { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .user span { display: none; }
  .plane { padding: 8px 10px 12px; border-radius: 28px 28px 14px 14px; }
  .prow.head { display: none; }
  .prow { grid-template-columns: 1fr; gap: 6px; padding: 10px 0; }
  .plabel { flex-direction: row; gap: 8px; align-items: baseline; }
  .aisle { display: none; }
  .half { grid-template-columns: 44px repeat(6, 1fr); gap: 5px; }
  .mlabel { display: flex; align-items: center; font-size: 11px; color: var(--muted); font-weight: 600; }
  .seat { min-height: 38px; }
  .week-nav .btn.ghost { padding: 8px 8px; font-size: 13px; }
  .week-label { font-size: 14px; flex-direction: column; gap: 4px; text-align: center; }
  .checkout-inner { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .actions .btn { flex: 1; }
  body.has-checkout { padding-bottom: 230px; }
}
.layout > * { min-width: 0; }
.half, .cols { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.seat { min-width: 0; }
@media (max-width: 640px) {
  .half { grid-template-columns: 38px repeat(6, minmax(0, 1fr)); gap: 4px; }
  .seat { aspect-ratio: auto; height: 46px; min-height: 0; }
  .seat .t { font-size: 9.5px; }
  .brand .title { font-size: 14px; }
  .brand .sub { display: none; }
  .nose { font-size: 13px; }
}

/* ---------- thông tin người đặt ---------- */
.pinfo { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px 84px; }
.binfo { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; text-align: left; cursor: pointer;
  background: #fdecec; border: 1px solid #f5c2c4; border-left: 4px solid var(--booked); border-radius: 8px;
  padding: 5px 10px; font: inherit; font-size: 12.5px; color: var(--text); max-width: 100%; }
.binfo:hover { background: #fbdcdd; }
.binfo.mine { border-left-color: var(--mine); background: #fff6e6; border-color: #fde2b0; }
.binfo .bt { font-weight: 700; color: #a3191e; }
.binfo.mine .bt { color: #a15c00; }
.binfo .bn { font-weight: 600; }
.binfo .be { color: var(--muted); }
.binfo .bp { font-style: italic; }
.binfo .bp::before { content: "· "; font-style: normal; color: var(--muted); }
.seat.booked .t, .seat.mine .t { font-size: 9.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
@media (max-width: 640px) {
  .pinfo { padding-left: 0; }
  .binfo { width: 100%; }
}
.note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff6e6; color: #7a4a00; font-size: 13.5px; line-height: 1.45; }
.note.warn { background: #f1f3f7; color: var(--muted); }

/* ---------- lịch sử ---------- */
dialog.wide { max-width: 1100px; width: calc(100% - 32px); }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.hist-head h3 { margin: 0; }
.hist-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.hist-filters input, .hist-filters select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.hist-body { max-height: 65vh; overflow: auto; }
.htable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.htable th { position: sticky; top: 0; background: #f7f8fb; text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.htable td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.tag.book { background: #e9f7ef; color: #1c6b3e; }
.tag.cancel { background: #fdecec; color: #a3191e; }
.login-card .small { margin-top: 12px; }
#w-sync:disabled { opacity: .6; }

.google-btn { background: #fff; border: 1px solid #dadce0; color: #3c4043; gap: 10px; }
.google-btn:hover { background: #f8f9fa; }
.howto { text-align: left; margin-top: 18px; font-size: 14px; background: #f7f8fb; border-radius: 10px; padding: 10px 14px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--hust); }
.howto ol { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }
.alert { text-align: left; }
