/* PrusseBus — trip planner & bus layout designer
 *
 * Themes are selected with <html data-theme="classic|dark">. Every colour used by the UI
 * (including bus elements --el-* and passenger colours --pc-*) is a token defined below.
 */

/* ------------------------------------------------------------------ theme: classic (default) */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #a3afbf;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-600: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --bus-stroke: #475569;

  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-soft: 0 1px 3px rgba(15, 23, 42, .12);
  --shadow-hover: 0 14px 34px -12px rgba(15, 23, 42, .22);
  --shadow-float: 0 16px 34px -8px rgba(15, 23, 42, .45);
  --shadow-modal: 0 30px 70px rgba(0, 0, 0, .35);
  --shadow-bus: 0 18px 40px -18px rgba(15, 23, 42, .35);
  --primary-shadow: 0 2px 8px -3px color-mix(in srgb, var(--primary) 80%, transparent);
  --lift: -2px;
  --overlay: rgba(15, 23, 42, .5);

  --brand-bg: linear-gradient(135deg, #2563eb, #7c3aed);
  --brand-shadow: 0 4px 12px -4px rgba(37, 99, 235, .6);
  --accent-fill: linear-gradient(90deg, var(--primary), #7c3aed);
  --glass: #38bdf8;
  --glass-ink: #0369a1;
  --tail-light: #ef4444;
  /* Selected filter chips: a soft tint of the primary colour (also used by the dark theme). */
  --chip-active-bg: color-mix(in srgb, var(--primary) 13%, var(--surface));
  --chip-active-fg: var(--primary-600);
  --toast-bg: #1e293b;
  --toast-success: #15803d;
  --toast-error: #b91c1c;
  --seat-depth: 7px;

  /* Passenger colours: groups get hsl(<hue> --pc-s --pc-l); avatars/seats mix that into the surface. */
  --pc-s: 58%;
  --pc-l: 44%;
  --pc-none: #64748b;
  --pc-fill: 100%;
  --pc-ink-mix: 0%;
  --pc-ink-base: #ffffff;

  /* Bus elements */
  --el-seat: #2563eb;
  --el-premium: #d97706;
  --el-accessible: #0d9488;
  --el-guide: #7c3aed;
  --el-driver: #334155;
  --el-door: #16a34a;
  --el-exit: #dc2626;
  --el-stairs: #b45309;
  --el-toilet: #0284c7;
  --el-kitchen: #db2777;
  --el-table: #92400e;
  --el-luggage: #64748b;
  --el-block: #94a3b8;

  --radius: 10px;
  --cell: 46px;
  --gap: 5px;
  --bus-pad: 14px;
  color-scheme: light;
}

/* ------------------------------------------------------------------ theme: dark */

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: #1f2a3c;
  --border-strong: #334155;
  --text: #e5e9f0;
  --muted: #94a3b8;
  --faint: #5b6779;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --bus-stroke: #64748b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-hover: 0 14px 34px -12px rgba(0, 0, 0, .6);
  --shadow-float: 0 16px 34px -8px rgba(0, 0, 0, .6);
  --shadow-bus: 0 18px 40px -18px rgba(0, 0, 0, .6);
  --overlay: rgba(0, 0, 0, .55);
  --toast-bg: #334155;
  --chip-active-fg: #93c5fd;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.25; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }
kbd {
  display: inline-block; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); color: var(--muted);
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sm { font-size: 12.5px; }
.mt { margin-top: 10px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.spacer { flex: 1; }
.row-gap { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: 28px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--on-primary);
  background: var(--brand-bg); box-shadow: var(--brand-shadow);
}
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.theme-switch, .lang-switch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); }
.lang-switch button {
  height: 28px; min-width: 34px; padding: 0 8px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; transition: background .15s, color .15s;
}
.lang-switch button:hover { background: var(--border); color: var(--text); }
.lang-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }
/* Segmented sun/moon toggle. The thumb follows <html data-theme> (set before first paint), so it never jumps on load. */
.theme-switch { position: relative; }
.theme-switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-soft);
  transition: transform .3s cubic-bezier(.34, 1.4, .64, 1), background .2s, box-shadow .2s;
}
:root[data-theme="dark"] .theme-switch::before {
  transform: translateX(30px); background: #1e293b; box-shadow: inset 0 0 0 1px #334155, var(--shadow-soft);
}
.theme-switch button {
  position: relative; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: var(--faint); cursor: pointer; transition: color .2s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch svg { transition: transform .35s cubic-bezier(.34, 1.4, .64, 1); transform: scale(.85); }
/* Only the sun spins; a rotated crescent ends up lying on its back. */
.theme-switch [data-theme-option="classic"] svg { transform: rotate(-40deg) scale(.85); }
.theme-switch .icon-fill { fill: transparent; transition: fill .2s; }
.theme-switch button[aria-checked="true"] svg { transform: none; }
.theme-switch button[aria-checked="true"] .icon-fill { fill: currentColor; }
.theme-switch [data-theme-option="classic"][aria-checked="true"] { color: #f59e0b; }
.theme-switch [data-theme-option="dark"][aria-checked="true"] { color: #a5b4fc; }
@media (prefers-reduced-motion: reduce) {
  .theme-switch::before, .theme-switch svg { transition: none; }
}

/* ------------------------------------------------------------------ authentication */

body.signed-out .nav, body.signed-out .user-menu { display: none !important; }

.view-auth .view-inner { display: flex; }
.view-auth .auth-screen { flex: 1; }
.reauth-overlay .auth-screen { min-height: 100vh; }
.auth-screen {
  min-height: 100%; display: grid; place-items: center; padding: 40px 16px;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 55%), var(--bg);
}
.auth-card { width: min(420px, 100%); padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 4px; }
.auth-card h1 { font-size: 22px; letter-spacing: -.01em; margin: 6px 0 2px; }
.auth-card > p { margin-bottom: 10px; }
.auth-card .btn.block { margin-top: 6px; height: 40px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; margin-bottom: 14px; }
.auth-brand .brand-mark svg { width: 18px; height: 18px; }
.auth-error { margin: 0 0 12px; }
.auth-error[hidden] { display: none; }
.auth-foot { margin-top: 14px; text-align: center; }
.field small.hint { font-weight: 400; color: var(--muted); }

.setup-card { width: min(560px, 100%); }
.setup-kicker { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin: 0; }
.setup-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 10px 0 18px; }
.setup-steps li {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
}
.setup-steps li span {
  width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--border); color: var(--muted); font-size: 11.5px;
}
.setup-steps li.active { color: var(--primary-600); border-color: color-mix(in srgb, var(--primary) 40%, transparent); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.setup-steps li.active span { background: var(--primary); color: var(--on-primary); }
.setup-steps li.done span { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.setup-list { list-style: none; padding: 0; margin: 14px 0 16px; display: flex; flex-direction: column; gap: 10px; }
.setup-list li { display: flex; gap: 10px; align-items: flex-start; }
.setup-list svg { width: 18px; height: 18px; margin-top: 1px; color: var(--primary); }
.setup-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.setup-actions .btn svg { width: 16px; height: 16px; }
.setup-summary { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 6px 0 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.setup-summary > div { display: flex; flex-direction: column; }
.check-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); cursor: pointer; margin-bottom: 10px; }
.check-card:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.check-card input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.check-card span { display: flex; flex-direction: column; gap: 2px; }
.notice code, .security-notice code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; padding: 1px 4px; border-radius: 4px; background: color-mix(in srgb, currentColor 10%, transparent); }

.reauth-overlay { position: fixed; inset: 0; z-index: 150; background: var(--overlay); backdrop-filter: blur(3px); overflow: auto; }
.reauth-overlay .auth-screen { background: transparent; }

.security-banner { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: color-mix(in srgb, var(--warning) 8%, var(--surface)); border-bottom: 1px solid var(--border); }
.security-banner .notice { margin: 0; flex: 1; background: none; padding: 4px 0; }

/* user menu */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13px;
}
.user-menu-btn:hover { border-color: var(--border-strong); }
.user-menu-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }
.user-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 60; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-float);
}
.user-menu-pop[hidden] { display: none; }
.user-menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.user-menu-pop [role=menuitem] {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer;
}
.user-menu-pop [role=menuitem]:hover, .user-menu-pop [role=menuitem]:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.user-menu-pop [role=menuitem] svg { width: 16px; height: 16px; color: var(--muted); }
.user-menu-pop [data-menu=logout] { color: var(--danger); }
.user-menu-pop [data-menu=logout] svg { color: var(--danger); }

/* input with buttons beside it (password + generate/copy in the user dialogs) */
.input-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.input-row input { flex: 1 1 180px; }

.view { flex: 1; min-height: 0; overflow: auto; }
.view-editor { overflow: hidden; }
.view-inner { min-height: 100%; }
.view-editor .view-inner { height: 100%; }

.state-msg { padding: 80px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.state-msg.error h2 { color: var(--text); }

/* ------------------------------------------------------------------ controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--primary-shadow); }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-primary); }
.btn.danger:hover { background: var(--danger-600); border-color: var(--danger-600); }
.btn.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger-outline:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-text { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; padding: 0;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); height: 36px; width: 36px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: none; border-color: transparent; color: var(--muted); }

input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }

.search { position: relative; display: block; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px !important; }
.page-actions .search input { width: 240px; }

.hint { font-size: 12.5px; color: var(--muted); }
.hint + .hint { margin-top: 8px; }
.link.sm { font-size: 12.5px; font-weight: 550; }

/* ------------------------------------------------------------------ pages */

.page { max-width: 1240px; margin: 0 auto; padding: 30px 24px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }

.empty {
  text-align: center; padding: 64px 20px; border: 2px dashed var(--border-strong); border-radius: 18px;
  background: var(--surface); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty.slim { padding: 36px 20px; }
.empty h2 { font-size: 19px; }
.empty .btn { margin-top: 8px; }
.empty-icon {
  width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 6px;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.empty-icon svg { width: 28px; height: 28px; }

/* bus cards */
.bus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.bus-card { display: flex; flex-direction: column; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.bus-card:hover { transform: translateY(var(--lift)); box-shadow: var(--shadow-hover); }
.bus-preview {
  height: 176px; padding: 16px; display: block; border-bottom: 1px solid var(--border);
  background: radial-gradient(color-mix(in srgb, var(--border-strong) 55%, transparent) 1px, transparent 1px) 0 0 / 14px 14px, var(--surface-2);
}
.pv { width: 100%; height: 100%; display: block; }
.pv-body { fill: var(--surface); stroke: var(--bus-stroke); stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.pv-glass { fill: var(--glass); opacity: .6; }
.card-body { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 16px; }
.card-title a { color: var(--text); }
.card-body > p.muted { min-height: 2.9em; font-size: 13px; }
.meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.meta span + span:not(.pill)::before { content: '·'; margin-right: 10px; color: var(--faint); }
.pill { margin-left: auto; padding: 2px 9px; border-radius: 999px; font-weight: 650; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.pill.full { background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.card-actions { display: flex; gap: 6px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress.thin { height: 5px; border: 0; background: var(--border); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent-fill); transition: width .3s; }

/* table */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650;
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover, .table th.sorted { color: var(--text); }
.sort-arrow { font-size: 9px; margin-left: 5px; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table.compact th, .table.compact td { padding: 6px 10px; font-size: 12.5px; }
.table-foot { margin-top: 12px; }
.person { display: flex; align-items: center; gap: 11px; }
.person-text { display: flex; flex-direction: column; min-width: 0; }
.contact { font-size: 13px; }
.contact > * { display: block; }
.badge {
  display: inline-block; padding: 2px 8px; margin: 2px 5px 2px 0; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); white-space: nowrap;
}
.badge:hover { text-decoration: none; background: color-mix(in srgb, var(--primary) 18%, transparent); }
.tag { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 550; }
.tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }

.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--pc, var(--pc-none)) var(--pc-fill), var(--surface));
  color: color-mix(in srgb, var(--pc, var(--pc-none)) var(--pc-ink-mix), var(--pc-ink-base));
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ------------------------------------------------------------------ modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--overlay); backdrop-filter: blur(2px); animation: fade .15s ease-out;
}
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-modal); animation: pop .18s ease-out;
}
.modal.lg { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.confirm-msg p + p { margin-top: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.templates { border: 0; padding: 0; margin: 4px 0 0; }
.templates legend { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; padding: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tpl { position: relative; }
.tpl input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card {
  display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 10px; border: 1.5px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.tpl-card:hover { border-color: var(--border-strong); }
.tpl-pv { display: block; height: 96px; padding: 8px; margin-bottom: 6px; border-radius: 8px; background: var(--surface-2); }
.tpl-card small { font-size: 11.5px; }
.tpl input:checked + .tpl-card { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.tpl input:focus-visible + .tpl-card { outline: 2px solid var(--primary); outline-offset: 2px; }

.file-pick { margin-bottom: 14px; cursor: pointer; }
.import-preview { border-top: 1px solid var(--border); padding-top: 12px; }
.import-preview p { margin-bottom: 8px; font-size: 13px; }

/* ------------------------------------------------------------------ toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  max-width: 380px; padding: 10px 14px; border-radius: 10px; background: var(--toast-bg); color: #fff; font-weight: 500; font-size: 13.5px;
  box-shadow: var(--shadow-float); opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: var(--toast-success); }
.toast-error { background: var(--toast-error); }

/* ------------------------------------------------------------------ editor */

.editor { height: 100%; display: flex; flex-direction: column; }
.editor-bar {
  flex: none; display: flex; align-items: center; gap: 14px; padding: 9px 14px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.back-link svg { width: 16px; height: 16px; }
.editor-title { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.editor-title h1 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.dirty { color: var(--warning); font-weight: 550; }
.save-state.dirty::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg a svg { width: 15px; height: 15px; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }
.bar-actions { display: flex; align-items: center; gap: 4px; }
.bar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.bar-actions .btn { margin-left: 8px; }

.editor-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr) 300px; }
.panel { background: var(--surface); overflow: auto; display: flex; flex-direction: column; min-height: 0; }
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }
.mode-allocate .panel-left { overflow: hidden; }
.panel-section { padding: 16px; border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: 0; }
.panel-section.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-section h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.panel-head h3 { margin-bottom: 10px; }
.panel-section > .hint:first-of-type { margin-bottom: 12px; }

/* palette */
.palette-group + .palette-group { margin-top: 14px; }
.palette-group h4 { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 7px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 550; text-align: left; cursor: grab;
  touch-action: none; user-select: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item:hover { border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 6%, var(--surface)); }
.palette-item.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 11%, var(--surface)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); }
.swatch {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 7px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.swatch svg { width: 17px; height: 17px; }
.swatch.lg { width: 40px; height: 40px; border-radius: 10px; }
.swatch.lg svg { width: 22px; height: 22px; }

.trash {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 16px 16px; padding: 14px;
  border: 2px dashed var(--border-strong); border-radius: 12px; color: var(--muted); font-size: 13px; font-weight: 550;
  transition: all .15s;
}
.trash svg { width: 18px; height: 18px; }
body.drag-element .trash { border-color: color-mix(in srgb, var(--danger) 60%, transparent); color: var(--danger); background: color-mix(in srgb, var(--danger) 4%, transparent); }
.trash.drop-ok { background: color-mix(in srgb, var(--danger) 14%, transparent) !important; border-style: solid; transform: scale(1.02); }

.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; font-size: 12.5px; align-items: center; }
.shortcuts dt { margin: 0; }
.shortcuts dd { margin: 0; color: var(--muted); }

/* passenger list */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 10px 0 8px; }
.chip {
  display: inline-flex; gap: 5px; align-items: center; justify-content: center; padding: 4px 6px; white-space: nowrap; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 550;
}
.chip b { font-weight: 700; color: var(--text); }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--chip-active-bg); border-color: color-mix(in srgb, var(--chip-active-fg) 30%, transparent); color: var(--chip-active-fg); }
.chip.active b { color: var(--chip-active-fg); }
.plist { flex: 1; min-height: 160px; overflow: auto; margin: 0 -8px; padding: 2px 8px 8px; border-radius: 10px; transition: background .15s, outline-color .15s; outline: 2px dashed transparent; outline-offset: -2px; }
.plist.drop-ok { background: color-mix(in srgb, var(--danger) 6%, transparent); outline-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.pitem {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: grab;
  touch-action: none; user-select: none; transition: background .12s;
}
.pitem:hover { background: var(--surface-2); }
.pitem.seated .avatar { opacity: .55; }
.pitem.seated .pname { color: var(--muted); }
.pitem.drag-source { opacity: .4; }
.pmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-badge { padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.plist-empty { padding: 28px 10px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.plist-empty svg { width: 28px; height: 28px; opacity: .6; }
.tools .btn { justify-content: flex-start; white-space: normal; height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; text-align: left; }

/* canvas */
.canvas-wrap { position: relative; min-width: 0; min-height: 0; display: flex; }
.canvas {
  flex: 1; overflow: auto;
  background: radial-gradient(color-mix(in srgb, var(--border-strong) 65%, transparent) 1px, transparent 1px) 0 0 / 18px 18px, var(--bg);
}
.hud { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3; pointer-events: none; }
.hud-pill {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-float); font-size: 13px;
}
.hud-pill .swatch { width: 26px; height: 26px; border-radius: 50%; }
.hud-pill .btn { border-radius: 999px; }

.decks { display: flex; align-items: flex-start; justify-content: center; gap: 40px; padding: 26px 36px 90px; width: max-content; min-width: 100%; }
.deck {
  display: flex; flex-direction: column; gap: 10px;
  width: max(236px, calc(var(--cols) * var(--cell) + (var(--cols) - 1) * var(--gap) + 2 * var(--bus-pad) + 6px));
}
.deck-head { display: flex; flex-direction: column; gap: 6px; min-height: 72px; justify-content: flex-end; }
.deck-row { display: flex; align-items: center; gap: 4px; justify-content: space-between; }
.deck-name { font-weight: 700; font-size: 15px; height: 32px !important; background: transparent !important; border-color: transparent !important; padding: 0 6px !important; margin-left: -6px; }
.deck-name:hover { border-color: var(--border-strong) !important; }
.deck-name:focus { background: var(--surface) !important; border-color: var(--primary) !important; }
.deck-btns { display: flex; flex: none; }
.deck-size { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.deck-size label { display: flex; align-items: center; gap: 5px; }
.deck-size input { width: 56px !important; height: 28px !important; padding: 0 6px !important; }
.deck-count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 550; white-space: nowrap; }
.deck-title { font-size: 15px; }

.bus {
  position: relative; padding: 12px var(--bus-pad) 14px; background: var(--surface);
  border: 3px solid var(--bus-stroke); border-radius: 46px 46px 18px 18px;
  box-shadow: var(--shadow-bus);
}
.bus-front {
  height: 22px; margin: 0 8px 14px; display: grid; place-items: center; border-radius: 26px 26px 6px 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--glass) 45%, var(--surface)), color-mix(in srgb, var(--glass) 12%, var(--surface)));
  color: color-mix(in srgb, var(--glass-ink) 75%, var(--text)); font-size: 9.5px; font-weight: 800; letter-spacing: .25em;
}
.bus-rear { position: relative; height: 5px; margin: 14px 4px 0; border-top: 2px solid var(--border); }
.bus-rear::before, .bus-rear::after { content: ''; position: absolute; top: 2px; width: 22px; height: 6px; border-radius: 3px; background: var(--tail-light); opacity: .8; }
.bus-rear::before { left: 0; }
.bus-rear::after { right: 0; }
.wheel { position: absolute; width: 7px; height: 40px; border-radius: 4px; background: var(--bus-stroke); }
.wheel.l { left: -10px; }
.wheel.r { right: -10px; }
.wheel.f { top: 74px; }
.wheel.b { bottom: 46px; }

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell); }
.cell { position: relative; border-radius: 9px; transition: background .12s, outline-color .12s; outline: 2px dashed transparent; outline-offset: -2px; }
.mode-design .cell { background: color-mix(in srgb, var(--border) 55%, transparent); }
.mode-design.has-brush .cell:not(:has(.tile)) { cursor: crosshair; }
.mode-design.has-brush .cell:not(:has(.tile)):hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.cell.drop-ok:not(:has(.tile)) { background: color-mix(in srgb, var(--primary) 18%, transparent); outline-color: var(--primary); }
body.drag-palette .mode-design .cell:not(:has(.tile)), body.drag-element .mode-design .cell:not(:has(.tile)) { background: color-mix(in srgb, var(--primary) 6%, color-mix(in srgb, var(--border) 55%, transparent)); }

.tile {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 9px; user-select: none; touch-action: none;
  background: color-mix(in srgb, var(--c) 13%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--c) 55%, transparent);
  color: var(--c); font-weight: 700; font-size: 12.5px; line-height: 1;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
/* Passengers face the front (top), so the backrest is drawn at the bottom of the seat. */
.tile.is-seat { border-radius: 11px 11px 7px 7px; box-shadow: inset 0 calc(-1 * var(--seat-depth)) 0 color-mix(in srgb, var(--c) 20%, transparent); }
.tile.t-block { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--c) 18%, var(--surface)) 0 5px, var(--surface) 5px 10px); }
.tile-icon svg { width: 23px; height: 23px; display: block; }
.tile-label { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mode-design .tile { cursor: grab; }
.mode-design .tile:hover { transform: translateY(calc(var(--lift) / 2)); box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--c) 60%, transparent); }
.tile.selected { outline: 2.5px solid var(--primary); outline-offset: 2px; z-index: 1; }
.tile.drag-source { opacity: .3; }
.cell.drop-ok .tile { transform: scale(1.07); box-shadow: 0 0 0 3px var(--primary); }

.mode-allocate .tile.inert { opacity: .42; }
.mode-allocate .tile.free { cursor: pointer; background: var(--surface); border-style: dashed; }
.mode-allocate .tile.free:hover { background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.tile.occupied {
  cursor: grab;
  background: color-mix(in srgb, var(--pc) var(--pc-fill), var(--surface));
  color: color-mix(in srgb, var(--pc) var(--pc-ink-mix), var(--pc-ink-base));
  border: 1.5px solid color-mix(in srgb, var(--pc) 70%, var(--text));
  box-shadow: inset 0 calc(-1 * var(--seat-depth)) 0 color-mix(in srgb, var(--pc) 30%, rgba(0, 0, 0, .25));
}
.tile.occupied:hover { transform: translateY(calc(var(--lift) / 2)); }
.seat-no { position: absolute; top: 3px; left: 5px; font-size: 9px; font-weight: 700; opacity: .85; }
.tile-initials { font-size: 14px; letter-spacing: .02em; margin-top: -2px; }
body.drag-passenger .mode-allocate .tile.free { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface)); animation: breathe 1.3s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent), inset 0 calc(-1 * var(--seat-depth)) 0 color-mix(in srgb, var(--c) 20%, transparent); } }

.add-deck {
  align-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  width: 140px; height: 220px; margin-top: 82px; border: 2px dashed var(--border-strong); border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--muted); font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.add-deck svg { width: 26px; height: 26px; }
.add-deck:hover { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }

/* drag ghost */
.drag-ghost {
  position: fixed !important; left: 0 !important; top: 0 !important; right: auto !important; bottom: auto !important;
  z-index: 1000; margin: 0; pointer-events: none; opacity: .94; will-change: transform;
  box-shadow: var(--shadow-float);
}
.drag-ghost.tile, .drag-ghost.palette-item { transform-origin: center; }
.ghost-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13px;
}
.ghost-chip .avatar { width: 30px; height: 30px; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.is-dragging { user-select: none; -webkit-user-select: none; }

/* inspector */
.sel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.person-card { display: flex; gap: 12px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.person-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.person-info a { overflow: hidden; text-overflow: ellipsis; }
.person-info .notes { margin-top: 4px; white-space: pre-line; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-grid div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.stat-grid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-grid span { font-size: 11.5px; color: var(--muted); }
.type-counts { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.type-counts li { display: flex; align-items: center; gap: 8px; }
.type-counts b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

.print-area { display: none; }
.stat-grid.one { grid-template-columns: 1fr; }

/* ------------------------------------------------------------------ seating editor */

.title-sub { color: var(--muted); font-weight: 550; }
.bus-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); max-width: 46vw; overflow-x: auto; scrollbar-width: thin; }
.bus-tabs:empty { display: none; }
.bus-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 7px; white-space: nowrap;
  color: var(--muted); font-weight: 600; font-size: 13px; transition: background .12s, color .12s, box-shadow .12s;
}
.bus-tab svg { width: 15px; height: 15px; }
.bus-tab:hover { color: var(--text); text-decoration: none; }
.bus-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }
.bus-tab-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.bus-tab-count { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--border); color: var(--muted); font-variant-numeric: tabular-nums; }
.bus-tab-count.full { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
body.drag-passenger .bus-tab:not(.active) { outline: 2px dashed color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: -2px; }
.bus-tab.drop-ok { background: color-mix(in srgb, var(--primary) 16%, var(--surface)) !important; color: var(--primary); outline: 2px solid var(--primary) !important; }
.seat-badge.other { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-style: dashed; }
.canvas-empty { margin: 60px auto; max-width: 440px; }
.trip-mini { display: flex; flex-direction: column; gap: 4px; }
.trip-mini span { display: inline-flex; align-items: center; gap: 6px; }
.trip-mini svg, .trip-row-body .muted svg, .trip-head-body > .muted svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.trip-mini span svg { margin-right: 0; }
.kv { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.kv li { display: flex; justify-content: space-between; gap: 8px; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; }

.notice { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 10px 0 0; border-radius: 9px; font-size: 12.5px; }
.notice svg { width: 16px; height: 16px; flex: none; }
.notice.warn { background: color-mix(in srgb, var(--warning) 11%, transparent); color: color-mix(in srgb, var(--warning) 75%, var(--text)); }
.notice.info { background: color-mix(in srgb, var(--primary) 9%, transparent); color: color-mix(in srgb, var(--primary) 75%, var(--text)); }
.notice span { flex: 1; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 650; cursor: pointer; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ trips */

.chips.inline { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.chips.inline .chip { padding: 5px 12px; font-size: 12.5px; }
.chips.wrap { margin: 10px 0; }

.trip-list { display: flex; flex-direction: column; gap: 12px; }
.trip-row { display: flex; align-items: stretch; overflow: hidden; transition: box-shadow .15s, transform .15s; }
.trip-row:hover { box-shadow: var(--shadow-hover); transform: translateY(calc(var(--lift) / 2)); }
.trip-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 18px; padding: 14px 18px; color: inherit; }
.trip-row-main:hover { text-decoration: none; }
.trip-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.trip-row-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trip-row-title h2 { font-size: 16.5px; }
.trip-row-body .desc { max-width: 520px; }
.trip-row-stats { display: flex; align-items: center; gap: 22px; }
.trip-row-stats > div { display: flex; flex-direction: column; align-items: center; min-width: 58px; }
.trip-row-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.trip-row-stats span { font-size: 11.5px; color: var(--muted); }
.trip-row-stats .warn b { color: var(--warning); }
.trip-row-stats .seated { align-items: stretch; width: 120px; gap: 6px; }
.trip-row-stats .seated span { color: var(--text); font-size: 12.5px; }
.trip-row-actions { display: flex; align-items: center; gap: 4px; padding: 0 14px; border-left: 1px solid var(--border); background: var(--surface-2); }
.trip-row-actions .btn { margin-right: 4px; }

.date-tile {
  flex: none; width: 62px; display: flex; flex-direction: column; align-items: center; padding: 6px 0 7px; border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); line-height: 1.1;
}
.dt-month { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.dt-day { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.dt-year { font-size: 10.5px; color: var(--muted); }
.date-tile.status-ongoing { background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.date-tile.status-ongoing .dt-month { color: var(--success); }
.date-tile.status-past { background: var(--surface-2); border-color: var(--border); }
.date-tile.status-past .dt-month { color: var(--muted); }
.date-tile.status-past .dt-day { color: var(--muted); }

.status-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.status-pill.status-upcoming { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); }
.status-pill.status-ongoing { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.status-pill.status-past { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.trip-page .back-link { margin: -6px 0 12px -10px; }
.trip-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.trip-head .date-tile { width: 72px; }
.trip-head .dt-day { font-size: 28px; }
.trip-head-body { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 5px; }
.trip-head-body h1 { font-size: 26px; letter-spacing: -.02em; }
.trip-desc { max-width: 720px; white-space: pre-line; margin-top: 4px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-card b { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-card b small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.stat-card > small { font-size: 12px; color: var(--muted); }
.stat-card.warn { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.stat-card.warn > small, .stat-card.warn b { color: var(--warning); }
.stat-card .progress { margin-top: 6px; }

.trip-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.trip-section { overflow: hidden; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.section-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.section-head h2 svg { width: 18px; height: 18px; color: var(--muted); }
.count { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.section-actions { display: flex; align-items: center; gap: 8px; }
.search.sm input { height: 30px !important; width: 170px; font-size: 13px; }
.section-empty { padding: 34px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.trip-section > div > .notice { margin: 12px 16px 0; }

.bulk-bar { display: none; align-items: center; gap: 10px; padding: 8px 16px; background: color-mix(in srgb, var(--primary) 7%, transparent); border-bottom: 1px solid var(--border); font-size: 13px; }
.bulk-bar.show { display: flex; }
.bulk-bar > span { margin-right: auto; }
.table .check { width: 36px; padding-right: 0; }
.table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.table tr.checked td { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.roster td { padding-top: 8px; padding-bottom: 8px; }
.clash { display: inline-flex; color: var(--warning); vertical-align: -2px; cursor: help; }
.clash svg { width: 15px; height: 15px; }

.trip-buses { list-style: none; margin: 0; padding: 6px 0; }
.trip-bus { display: flex; gap: 14px; padding: 12px 16px; }
.trip-bus + .trip-bus { border-top: 1px solid var(--border); }
.trip-bus-pv {
  flex: none; width: 104px; height: 104px; padding: 8px; border-radius: 10px; border: 1px solid var(--border);
  background: radial-gradient(color-mix(in srgb, var(--border-strong) 55%, transparent) 1px, transparent 1px) 0 0 / 10px 10px, var(--surface-2);
}
.trip-bus-pv:hover { border-color: var(--primary); }
.trip-bus-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.trip-bus-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trip-bus-title b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-bus-body .notice { margin: 2px 0 0; padding: 6px 8px; font-size: 12px; }
.trip-bus-actions { display: flex; align-items: center; gap: 2px; margin-top: auto; padding-top: 4px; }

.badge.unseated { background: color-mix(in srgb, var(--warning) 12%, transparent); color: color-mix(in srgb, var(--warning) 80%, var(--text)); }
.badge-sub { font-weight: 500; opacity: .8; }

/* passenger picker */
.picker-tools { margin-bottom: 4px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.check-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; cursor: pointer; }
.check-label input, .pick input { width: 16px; height: 16px; accent-color: var(--primary); }
.picker-list { max-height: 46vh; overflow: auto; padding: 4px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; cursor: pointer; min-width: 0; }
.pick:hover { background: var(--surface-2); }
.pick.on { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.clash-note { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--warning); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.clash-note svg { width: 13px; height: 13px; }
.pad { padding: 20px; grid-column: 1 / -1; }
.date-hint { margin: -6px 0 12px; min-height: 1em; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .trip-grid { grid-template-columns: 1fr; }
  .trip-row-stats > div:not(.seated) { display: none; }
}

@media (max-width: 1180px) {
  .editor-main { grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .panel-right { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; max-height: 34vh; border-left: 0; border-top: 1px solid var(--border); }
  .panel-right .panel-section { flex: 1 1 260px; border-bottom: 0; border-right: 1px solid var(--border); }
}

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .brand span:last-child { display: none; }
  .view-editor { overflow: auto; }
  .editor { height: auto; }
  .editor-main { display: flex; flex-direction: column; }
  .panel { overflow: visible; }
  .mode-allocate .panel-left { overflow: visible; }
  .plist { max-height: 300px; }
  .panel-right { flex-direction: column; max-height: none; }
  .canvas-wrap { min-height: 70vh; }
  .seg a span, .back-link span { display: none; }
  .user-menu-name { display: none; }
  .setup-steps li { font-size: 0; justify-content: center; }
  .setup-steps li span { font-size: 11.5px; }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .trip-row { flex-direction: column; }
  .trip-row-stats { display: none; }
  .trip-row-actions { border-left: 0; border-top: 1px solid var(--border); padding: 8px 12px; }
  .picker-list { grid-template-columns: 1fr; }
  .bus-tabs { max-width: 100%; order: 5; flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .page-actions .search input { width: 100%; }
  .page-actions .search { flex: 1 1 100%; }
}

/* ------------------------------------------------------------------ print */

@media print {
  @page { margin: 12mm; }
  body { background: #fff; display: block; height: auto; }
  .topbar, .editor-bar, .panel, .add-deck, .deck-btns, .deck-size, .hud, .toasts { display: none !important; }
  .view, .view-editor, .view-inner, .editor, .editor-main, .canvas-wrap, .canvas { display: block !important; height: auto !important; overflow: visible !important; }
  .canvas { background: none; }
  .decks { width: auto; padding: 0; justify-content: flex-start; flex-wrap: wrap; }
  .bus { box-shadow: none; }
  .tile, .tile.occupied, .bus-front { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-area { display: block; break-before: page; }
  .print-area h1 { font-size: 20px; margin-bottom: 4px; }
  .print-area > p { margin-bottom: 6px; }
  .print-area .table { margin-top: 12px; font-size: 11px; }
  .print-area .table th, .print-area .table td { padding: 4px 8px; }
}
