:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e2e5eb;
  --grid: #9aa3b2;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --town: #c81e1e;
  --hotel: #0f7a5a;
  --aisle: #fff59d;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; display: flex; flex-direction: column; }
button, select { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; color: var(--ink); }
button:hover { border-color: #c5cad4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: #b45309; border-color: #f3d2a8; }
button.big { padding: 10px 22px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; }
.brand strong { font-size: 16px; }
.brand .muted { font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab { border: none; background: none; padding: 8px 14px; border-radius: 6px; color: var(--muted); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.controls { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.narration { position: fixed; width: 320px; z-index: 9; background: #fff; color: var(--ink); border: 3px solid #dc2626; padding: 12px 14px; font-size: 15px; line-height: 1.45; border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .18); animation: fadein .35s ease; transition: left .35s ease, top .35s ease; }
.narration b { color: #dc2626; }
.narration::before { content: ""; position: absolute; width: 14px; height: 14px; background: #fff; border: 3px solid #dc2626; transform: rotate(45deg); }
.narration[data-side="right"]::before { left: -10px; top: var(--arrow, 18px); border-top: none; border-right: none; }
.narration[data-side="left"]::before { right: -10px; top: var(--arrow, 18px); border-bottom: none; border-left: none; }
.narration[data-side="below"]::before { top: -10px; left: 24px; border-bottom: none; border-right: none; }
.statusbar { display: flex; flex-wrap: wrap; gap: 22px; padding: 7px 18px; background: #fbfbfc; border-bottom: 1px solid var(--line); font-size: 13px; }
@keyframes fadein { from { opacity: .3; } to { opacity: 1; } }

/* reservations view: slow (inbox | detail | one coach) and wide (inbox | both coaches) */
.view { flex: 1; min-height: 0; }
.resa { display: grid; gap: 12px; padding: 12px; overflow: hidden; }
.resa.slow { grid-template-columns: 200px 380px 1fr; }
.resa.wide { grid-template-columns: 200px 1fr; }
.resa.wide .detail { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; min-height: 0; }

.inbox ul { list-style: none; margin: 0; padding: 0; }
.inbox li { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; margin-bottom: 3px; animation: slidein .3s ease; }
.inbox li:hover { background: #f6f7f9; }
.inbox li.active { background: var(--accent-soft); border-color: #b9e0da; }
.inbox li.cancelled { opacity: .5; }
.inbox .from { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.inbox .empty { color: var(--muted); font-size: 13px; }
.badge { padding: 0 6px; border-radius: 10px; font-size: 10.5px; }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.grey { background: #eceef2; color: var(--muted); }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* detail (booking card) */
.detail { display: flex; flex-direction: column; gap: 10px; }
.detail > *, #drawer-body > * { flex-shrink: 0; }
.placeholder { line-height: 1.5; padding: 20px 10px; }
.mail { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mail-head { background: #f8f9fb; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mail-body { margin: 0; padding: 10px 12px; white-space: pre-wrap; font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-height: 240px; overflow: auto; }
mark.hl { background: transparent; border-radius: 3px; padding: 0 1px; transition: background .35s; color: inherit; }
.mail:not(.staged) mark.hl, mark.hl.on { background: var(--hlc); }
.f-pax { --hlc: #fde68a; }
.f-pickup { --hlc: #fecaca; }
.f-hotel { --hlc: #bbf7d0; }
.f-duration { --hlc: #e9d5ff; }
.f-cls { --hlc: #bfdbfe; }
.f-pref { --hlc: #fed7aa; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; transition: opacity .45s, transform .45s; }
.card.hide { opacity: 0; transform: translateY(6px); pointer-events: none; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 13px; }
.field { display: grid; grid-template-columns: 105px 1fr; gap: 8px; padding: 4px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.field .lbl { color: var(--muted); position: relative; padding-left: 14px; }
.field .lbl::before { content: ""; position: absolute; left: 0; top: 4px; width: 9px; height: 9px; border-radius: 2px; background: var(--hlc); }
.places { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.pl { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.pl .lbl { color: var(--muted); }
.note { padding: 4px 8px; border-radius: 5px; font-size: 12.5px; background: #f1f3f6; }
.note.info { background: var(--info-soft); color: var(--info); }
.note.grey { color: var(--muted); }
.msg { font-size: 13px; line-height: 1.45; background: #fcfcfd; border-left: 3px solid var(--accent); padding: 2px 10px; }
.msg p { margin: 6px 0; }
.msg p.info { color: var(--info); }
.msg ul { margin: 3px 0 0; padding-left: 18px; }

/* drawer (wide mode) */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; background: #fff; box-shadow: -10px 0 30px rgba(0, 0, 0, .15); padding: 16px; overflow: auto; z-index: 8; display: flex; flex-direction: column; animation: drawerin .25s ease; }
#drawer-body { display: flex; flex-direction: column; gap: 10px; }
.drawer-close { align-self: flex-end; margin-bottom: 6px; }
@keyframes drawerin { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* plans: their Excel grid */
.plans { display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.plans-head { display: flex; justify-content: space-between; align-items: center; }
.leg-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.leg-switch button { border: none; border-radius: 0; padding: 6px 14px; color: var(--muted); }
.leg-switch button.active { background: var(--accent); color: #fff; }
.plans-body { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; flex: 1; min-height: 0; overflow: auto; }
.coachplan { display: flex; flex-direction: column; gap: 6px; width: min-content; }
.planhead { width: 100%; }
.planhead { border-collapse: collapse; font-size: 11px; }
.planhead td { border: 1px solid var(--grid); padding: 2px 8px; }
.planhead td span { display: block; font-size: 9.5px; color: var(--muted); font-style: italic; }
.planhead td b { font-size: 12.5px; }
.planhead td.veh { background: #f9d9e6; }
.planhead td.paxbox b { color: var(--town); }
.sheets { display: flex; gap: 12px; align-items: flex-start; }
.sheet-title { font-size: 11px; margin-bottom: 2px; }
.sheet-title b { background: #3a3f4a; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10.5px; }
.sheet-title span { color: var(--muted); }
table.grid { border-collapse: collapse; table-layout: fixed; width: 368px; }
table.grid th:not(.rang):not(.aisle) { width: 84px; }
table.grid th { font-size: 9.5px; font-weight: 600; color: var(--muted); background: repeating-linear-gradient(45deg, #f1f3f6, #f1f3f6 3px, #e8ebf0 3px, #e8ebf0 6px); border: 1px solid var(--grid); padding: 1px 2px; }
table.grid td { border: 1px solid var(--grid); }
table.grid .rang { width: 22px; text-align: center; font-size: 10px; font-weight: 700; background: repeating-linear-gradient(45deg, #f1f3f6, #f1f3f6 3px, #e8ebf0 3px, #e8ebf0 6px); }
table.grid .aisle { width: 10px; background: var(--aisle); border-top: none; border-bottom: none; }
table.grid td.markcell { background: #e5e7eb; color: var(--muted); font-size: 9.5px; font-weight: 600; text-align: center; height: 24px; }
table.grid tr.markrow td.markcell { height: 20px; }
td.pc { width: 84px; height: 37px; position: relative; padding: 2px 3px; vertical-align: top; overflow: hidden; font-size: 8.5px; line-height: 1.2; background: #fff; }
td.pc span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.pc .pn { position: absolute; right: 2px; bottom: 1px; font-size: 7.5px; color: #a3aab8; }
td.pc .pt { color: var(--town); font-weight: 700; }
td.pc .pname { font-weight: 700; font-size: 9.5px; }
td.pc .ph { color: var(--hotel); font-weight: 700; }
td.pc .xtag { color: var(--info); font-weight: 700; }
td.pc:not(.occ):not(.crew) .pn { position: static; text-align: center; font-size: 9px; padding-top: 11px; }
td.pc.crew { background: #d1d5db; color: var(--muted); }
td.pc.occ { cursor: pointer; }
td.pc.occ:hover { background: #f6f7f9; }
td.pc.sel { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
td.pc.pop { animation: pop .7s ease; }
@keyframes pop { 0% { background: #fde68a; } 100% { background: #fff; } }

/* red frame around what the narration talks about */
.focus { outline: 3px solid #dc2626 !important; outline-offset: 3px; border-radius: 6px; }
td.focus { outline-offset: -3px; border-radius: 0; }

/* intro */
.intro { position: fixed; inset: 0; background: rgba(20, 26, 38, .45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.intro-card { background: #fff; border-radius: 12px; max-width: 600px; padding: 28px 30px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); line-height: 1.5; }
.intro-card h1 { font-size: 24px; margin: 4px 0 14px; line-height: 1.25; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; margin: 0; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; max-width: 640px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 12; }

/* documents view */
.docs { display: grid; grid-template-columns: 260px 1fr; gap: 12px; padding: 12px; overflow: hidden; }
.doc-nav { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; }
.doc-nav ul { list-style: none; padding: 0; margin: 10px 0; }
.doc-nav li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.doc-nav li:hover { background: #f6f7f9; }
.doc-nav li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.coach-switch { display: flex; gap: 4px; }
.coach-switch button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.doc-page { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 32px; overflow: auto; }
.doc-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 14px; max-width: 860px; }
.doc-head h1 { font-size: 19px; margin: 0 0 3px; }
.doc-head .small { text-align: right; }
.doc-page h2 { margin-top: 18px; }
.doc-page > table, .doc-page .block, .doc-page .ex-grid, .doc-page .total, .doc-page .mail-draft, .doc-page > p { max-width: 860px; }
.doc-page table:not(.grid):not(.planhead) { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 8px; }
.doc-page table:not(.grid):not(.planhead) th, .doc-page table:not(.grid):not(.planhead) td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
.doc-page table:not(.grid):not(.planhead) th { background: #f6f7f9; font-weight: 600; }
.doc-page td.r, .doc-page th.r { text-align: right !important; }
.doc-page tfoot td { font-weight: 700; }
.doc-page .town { color: var(--town); font-weight: 700; }
.doc-page .hotel { color: var(--hotel); font-weight: 700; }
.doc-plan { margin-bottom: 8px; }
.kv td:nth-child(odd) { color: var(--muted); width: 18%; }
.kv td.fill { color: #9aa1b0; font-style: italic; }
.block { margin-bottom: 10px; }
.block-head { display: grid; grid-template-columns: 1fr 2fr 70px; gap: 10px; background: #f6f7f9; padding: 5px 8px; border: 1px solid var(--line); border-bottom: none; font-size: 12.5px; max-width: 860px; }
.block-head.transfer { display: block; background: var(--info-soft); color: var(--info); border: 1px solid #bfd3fb; margin: 12px 0 6px; font-weight: 600; }
.block-head .r { text-align: right; }
.hl-change { background: var(--info-soft); }
.total { font-weight: 700; text-align: right; margin-top: 6px; font-size: 14px; }
.ex-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.ex { border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; }
.ex h3 { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ex .big { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.ex.give { background: #fff7ed; }
.ex.recv { background: #eff6ff; }
.mail-draft { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.mail-draft hr { border: none; border-top: 1px solid var(--line); }

@media (max-width: 1380px) {
  .resa.slow { grid-template-columns: 190px 340px 1fr; }
  td.pc, table.grid th:not(.rang):not(.aisle) { width: 76px; }
  table.grid { width: 336px; }
}

@media print {
  .topbar, .statusbar, .narration, .doc-nav, #view-resa, .intro, .toast, .drawer { display: none !important; }
  body { background: #fff; display: block; }
  .docs { display: block; padding: 0; }
  .doc-page { border: none; padding: 0; overflow: visible; }
}
