/*
  Bus Aachooki Partner design system: a calm, premium layer on Bootstrap 5.

  Colour use: this file sets the structure and the original Prompt 04 palette. partner-theme.css, loaded last, turns it into the colourful
  light theme the owner asked for: soft colour washes, gradient accents and a different pastel for each card, never a dark background.
  See docs/partner-web.md for the component list.
*/

@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Palette */
  --brand-white: #FFFFFF;
  --brand-surface-2: #F7F9FC;
  --brand-navy: #071B35;
  --brand-blue: #0866F5;
  --brand-blue-dark: #0655CC;
  --brand-blue-light: #EAF2FF;
  --brand-orange: #FF8A00;
  --brand-border: #E8EDF3;
  --brand-secondary-text: #718096;
  --brand-success: #198754;
  --brand-warning: #E6A23C;
  --brand-error: #DC3545;

  /* Roles */
  --page: var(--brand-surface-2);
  --surface: var(--brand-white);
  --surface-sunken: #F1F4F9;
  --line: var(--brand-border);
  --line-strong: #D6DEE8;
  --input-border: #7E8EA6;          /* 3.4:1 against white, the minimum for a form control's edge */
  --text: var(--brand-navy);
  --text-body: #1F2A3C;
  /* #718096 is 4.0:1 on white: fine for large text, placeholders and icons, too faint for small text. Small secondary text uses --text-muted. */
  --text-secondary: var(--brand-secondary-text);
  --text-muted: #4A5568;            /* 7.5:1 on white */
  --link: var(--brand-blue);
  --tint: var(--brand-blue-light);
  --tint-text: #0A4FC0;

  --success: var(--brand-success);
  --success-bg: #E9F6EF;
  --warning: var(--brand-warning);
  --warning-bg: #FDF5E9;
  --warning-text: #7A4A00;
  --danger: var(--brand-error);
  --danger-bg: #FDEDEE;
  --danger-text: #B02A37;

  /* Shape and depth */
  --radius-sm: 0.5rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --shadow-xs: 0 1px 2px rgba(7, 27, 53, 0.04);
  --shadow-sm: 0 1px 2px rgba(7, 27, 53, 0.04), 0 2px 8px rgba(7, 27, 53, 0.04);
  --shadow-md: 0 2px 4px rgba(7, 27, 53, 0.04), 0 12px 32px rgba(7, 27, 53, 0.08);
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* Layout. The header height puts the eyes exactly their offset from the top: 12 + 22 + 12 on phones, 16 + 28 + 16 from 768px. */
  --topbar-height: calc(var(--ba-eye-size) + 2 * var(--ba-eye-offset));
  --sidebar-width: 16rem;
  --content-max: 76rem;

  /* Safe areas for notches and rounded corners (the layout sets viewport-fit=cover). Zero where a device has none. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --topbar-offset: calc(var(--topbar-height) + var(--safe-top));

  /* Bootstrap */
  --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.6;
  --bs-body-bg: var(--page);
  --bs-body-color: var(--text-body);
  --bs-border-color: var(--line);
  --bs-link-color: var(--link);
  --bs-link-color-rgb: 8, 102, 245;
  --bs-link-hover-color: var(--brand-blue-dark);
  --bs-link-hover-color-rgb: 6, 85, 204;
  --bs-primary: var(--brand-blue);
  --bs-primary-rgb: 8, 102, 245;
  --bs-secondary-color: var(--text-muted);
  --bs-emphasis-color: var(--brand-navy);
}

/* ---------- Base and typography ---------- */

html, body { min-height: 100%; }
body {
  background: var(--page);
  color: var(--text-body);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, .h1, .h2, .h3, .h4 { color: var(--text); font-weight: 650; letter-spacing: -0.018em; line-height: 1.25; }
h1, .h1 { font-size: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem); }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.0625rem; }
p { margin-bottom: 0.875rem; }
strong, b { font-weight: 600; color: var(--text); }
small, .small { font-size: 0.8125rem; }
a { text-underline-offset: 0.18em; }
::selection { background: var(--tint); color: var(--text); }

/* Orange is too faint to show focus on a light page. */
:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
#main-content:focus { outline: none; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 1100;
  background: var(--brand-navy); color: #FFFFFF; padding: 0.5rem 0.875rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: calc(0.75rem + var(--safe-top)); }

.eyebrow { font-size: 0.75rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-blue); margin-bottom: 0.5rem; }
.text-muted-soft { color: var(--text-muted); }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* Smooth page transitions: a short cross-fade between pages where the browser supports it, and a gentle fade-in of the content. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: var(--ease); }
.app-main, .auth-main { animation: page-in 220ms var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .app-main, .auth-main { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* ---------- Buttons ---------- */

.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 1rem;
  --bs-btn-font-size: 0.9375rem;
  --bs-btn-border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), color 0.15s var(--ease);
}
.btn-sm { --bs-btn-padding-y: 0.3rem; --bs-btn-padding-x: 0.75rem; --bs-btn-font-size: 0.8125rem; }
.btn-lg { --bs-btn-padding-y: 0.7rem; --bs-btn-padding-x: 1.35rem; --bs-btn-font-size: 1rem; }
.btn:active { transform: translateY(0.5px); }
.btn-primary {
  --bs-btn-bg: var(--brand-blue); --bs-btn-border-color: var(--brand-blue);
  --bs-btn-hover-bg: var(--brand-blue-dark); --bs-btn-hover-border-color: var(--brand-blue-dark);
  --bs-btn-active-bg: var(--brand-blue-dark); --bs-btn-active-border-color: var(--brand-blue-dark);
  --bs-btn-disabled-bg: var(--brand-blue); --bs-btn-disabled-border-color: var(--brand-blue);
  box-shadow: 0 1px 2px rgba(8, 102, 245, 0.2);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-blue); --bs-btn-border-color: var(--line-strong); --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--tint); --bs-btn-hover-color: var(--brand-blue-dark); --bs-btn-hover-border-color: var(--brand-blue);
  --bs-btn-active-bg: var(--tint); --bs-btn-active-color: var(--brand-blue-dark); --bs-btn-active-border-color: var(--brand-blue);
}
.btn-outline-secondary, .btn-secondary {
  --bs-btn-color: var(--text); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong);
  --bs-btn-hover-bg: var(--surface-sunken); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--line-strong);
  --bs-btn-active-bg: var(--surface-sunken); --bs-btn-active-color: var(--text); --bs-btn-active-border-color: var(--line-strong);
}
.btn-ghost {
  --bs-btn-color: var(--text-muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
  --bs-btn-hover-bg: var(--surface-sunken); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: transparent;
}
.btn-danger {
  --bs-btn-bg: var(--brand-error); --bs-btn-border-color: var(--brand-error);
  --bs-btn-hover-bg: #BB2D3B; --bs-btn-hover-border-color: #BB2D3B;
}
/* The one key action on a screen. White on orange fails contrast, so the text is navy (7.3:1). */
.btn-accent {
  --bs-btn-color: var(--brand-navy); --bs-btn-bg: var(--brand-orange); --bs-btn-border-color: var(--brand-orange);
  --bs-btn-hover-color: var(--brand-navy); --bs-btn-hover-bg: #F28200; --bs-btn-hover-border-color: #F28200;
  --bs-btn-active-color: var(--brand-navy); --bs-btn-active-bg: #E67C00; --bs-btn-active-border-color: #E67C00;
  --bs-btn-disabled-color: var(--brand-navy); --bs-btn-disabled-bg: var(--brand-orange); --bs-btn-disabled-border-color: var(--brand-orange);
}
.btn-link { text-decoration: none; font-weight: 600; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.icon-button:hover { background: var(--surface-sunken); }
.menu-bars, .menu-bars::before, .menu-bars::after { display: block; width: 1.1rem; height: 2px; border-radius: 2px; background: var(--text); }
.menu-bars { position: relative; }
.menu-bars::before, .menu-bars::after { content: ""; position: absolute; left: 0; }
.menu-bars::before { top: -6px; }
.menu-bars::after { top: 6px; }

/* ---------- Forms, search and dropdowns ---------- */

.form-label { font-weight: 600; font-size: 0.875rem; color: var(--text); margin-bottom: 0.35rem; }
.form-control, .form-select {
  background-color: var(--surface); border-color: var(--input-border); border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem; font-size: 0.9375rem; color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-control::placeholder { color: var(--text-secondary); }
.form-control:hover, .form-select:hover { border-color: #66758D; }
.form-control:focus, .form-select:focus { background-color: var(--surface); border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(8, 102, 245, 0.15); }
.form-select { background-position: right 0.8rem center; padding-right: 2.25rem; }
.form-text { color: var(--text-muted); font-size: 0.8125rem; }
.form-check-input { border-color: var(--input-border); }
.form-check-input:checked { background-color: var(--brand-blue); border-color: var(--brand-blue); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(8, 102, 245, 0.15); border-color: var(--brand-blue); }
.input-validation-error { border-color: var(--danger) !important; }
.input-validation-error:focus { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important; }
.field-error { display: block; color: var(--danger-text); font-size: 0.8125rem; margin-top: 0.3rem; }
.form-error { color: var(--danger-text); }
.form-error ul { margin: 0 0 1rem; padding: 0.75rem 1rem 0.75rem 2rem; background: var(--danger-bg); border-radius: var(--radius-sm); }
.validation-summary-valid { display: none; }

.form-section { border: 0; padding: 0; margin: 0 0 1.75rem; }
.form-section legend {
  font-size: 0.9375rem; font-weight: 650; color: var(--text);
  padding-bottom: 0.75rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); width: 100%;
}
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.form-actions__note { margin: 0; color: var(--text-muted); font-size: 0.8125rem; flex: 1 1 16rem; }

/* Search: an input with a leading icon. */
.search-field { position: relative; min-width: 0; }
.search-field .icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 1.1rem; height: 1.1rem; color: var(--text-secondary); pointer-events: none; }
.search-field .form-control { padding-left: 2.35rem; }

.dropdown-menu {
  --bs-dropdown-link-active-bg: var(--tint); --bs-dropdown-link-active-color: var(--tint-text);
  --bs-dropdown-font-size: 0.9rem;
  border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 0.35rem;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 0.45rem 0.75rem; color: var(--text); }
.dropdown-item:hover { background: var(--surface-sunken); }
.dropdown-header { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* Filter panel: search and filters in one quiet row above a list. */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem;
  padding: 0.875rem; margin-bottom: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-bar > .search-field, .filter-bar > .filter-bar__search { flex: 1 1 16rem; min-width: 0; }
.filter-bar > .filter-bar__field { flex: 0 1 11rem; }
.filter-bar .form-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.filter-bar__actions { display: flex; gap: 0.5rem; margin-left: auto; }

/* ---------- Cards and panels ---------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-xs); margin-bottom: 1.5rem; }
@media (min-width: 768px) { .panel { padding: 2rem; } }
.panel--accent { border-left: 3px solid var(--brand-orange); }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.panel__title { font-size: 1rem; font-weight: 650; margin: 0; }

.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.stat {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon label" "value value" "note note";
  align-items: center; column-gap: 0.6rem; row-gap: 0.1rem;
  padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  color: inherit; text-decoration: none; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); color: inherit; transform: translateY(-1px); }
.stat__icon { grid-area: icon; display: inline-flex; color: var(--brand-blue); }
.stat__label { grid-area: label; font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); }
.stat__value { grid-area: value; font-size: 1.875rem; font-weight: 650; color: var(--text); letter-spacing: -0.02em; margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
.stat__value--missing { color: var(--text-secondary); }
.stat__note { grid-area: note; font-size: 0.8125rem; color: var(--text-muted); }

.module-grid { display: grid; gap: 0.875rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.module-card {
  display: flex; align-items: flex-start; gap: 0.875rem; padding: 1.1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
a.module-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); color: inherit; transform: translateY(-1px); }
.module-card--form { align-items: center; }
.module-card__icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); background: var(--tint); color: var(--brand-blue);
}
.module-card__body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 auto; min-width: 0; }
.module-card__title { font-weight: 650; color: var(--text); }
.module-card__text { font-size: 0.875rem; color: var(--text-muted); }

/* Key facts about one record, such as a bus's details. */
.detail-list { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: 0.75rem 1.5rem; margin: 0; }
.detail-list dt { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); }
.detail-list dd { margin: 0; color: var(--text); }
@media (max-width: 575.98px) { .detail-list { grid-template-columns: 1fr; gap: 0.15rem; } .detail-list dd { margin-bottom: 0.65rem; } }

.tag {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.6rem; white-space: nowrap;
}
.reference { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.04em; }

/* ---------- Status indicators ---------- */

.status {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  font-size: 0.8125rem; font-weight: 600; line-height: 1.2;
  padding: 0.25rem 0.6rem 0.25rem 0.5rem; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted);
}
.status::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; flex: none; }
.status--success { background: var(--success-bg); color: #146C43; }
.status--warning { background: var(--warning-bg); color: var(--warning-text); }
.status--warning::before { background: var(--warning); }
.status--danger { background: var(--danger-bg); color: var(--danger-text); }
.status--info { background: var(--tint); color: var(--tint-text); }
.status--neutral { background: var(--surface-sunken); color: var(--text-muted); }
/* Safety indicators are the one place orange stands out. */
.status--safety { background: #FFF3E5; color: #8A4B00; }
.status--safety::before { background: var(--brand-orange); }
.status--live::before { animation: status-pulse 1.8s ease-in-out infinite; }
@keyframes status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status--live::before { animation: none; } }

/* ---------- Tables ---------- */

.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; margin-bottom: 1rem; }
.table-card .table-responsive { margin: 0; }
.data-table { --bs-table-bg: transparent; --bs-table-hover-bg: #F9FBFE; margin: 0; font-size: 0.9rem; }
.data-table > :not(caption) > * > * { padding: 0.8rem 1rem; border-bottom-color: var(--line); vertical-align: middle; }
.data-table thead th {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  background: var(--brand-surface-2); white-space: nowrap;
}
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table .is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .row-title { font-weight: 600; color: var(--text); }
.data-table .row-sub { display: block; font-size: 0.8125rem; color: var(--text-muted); }
.data-table a.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.data-table a.row-link:hover { color: var(--brand-blue); }
.table-card__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1rem; border-top: 1px solid var(--line); background: var(--surface); font-size: 0.8125rem; color: var(--text-muted); }

/* ---------- Pagination ---------- */

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.8125rem; color: var(--text-muted); }
.pager__buttons { display: flex; gap: 0.5rem; }
.pager .btn[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }

/* ---------- Notices, toasts and dialogs ---------- */

.notice { border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.9rem; border: 1px solid transparent; }
.notice--info { background: var(--tint); color: var(--tint-text); border-color: #D3E4FF; }
.notice--warning { background: var(--warning-bg); color: var(--warning-text); border-color: #F6DDB4; }
.notice--danger { background: var(--danger-bg); color: var(--danger-text); border-color: #F5C6CB; }

.toast-stack {
  position: fixed; z-index: 1090; right: max(1rem, var(--safe-right)); bottom: max(1rem, var(--safe-bottom));
  display: flex; flex-direction: column; gap: 0.5rem; width: min(24rem, calc(100vw - 2rem)); pointer-events: none;
}
.toast-note {
  display: flex; align-items: flex-start; gap: 0.65rem; pointer-events: auto;
  padding: 0.85rem 0.85rem 0.85rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); color: var(--text); font-size: 0.9rem;
  animation: toast-in 220ms var(--ease) both;
}
.toast-note.is-leaving { animation: toast-out 180ms var(--ease) both; }
.toast-note__dot { width: 0.5rem; height: 0.5rem; margin-top: 0.45rem; border-radius: 50%; background: var(--brand-blue); flex: none; }
.toast-note__text { flex: 1 1 auto; }
.toast-note .btn-close { flex: none; font-size: 0.7rem; margin-top: 0.2rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast-note, .toast-note.is-leaving { animation: none; } }

.modal { --bs-modal-border-radius: var(--radius-lg); --bs-modal-border-color: var(--line); --bs-modal-header-border-color: transparent; --bs-modal-footer-border-color: transparent; }
.modal-content { box-shadow: var(--shadow-md); }
.modal-header { padding: 1.25rem 1.5rem 0.25rem; }
.modal-title { font-size: 1.0625rem; }
.modal-body { padding: 0.5rem 1.5rem 1rem; color: var(--text-muted); }
.modal-footer { padding: 0.5rem 1.5rem 1.25rem; gap: 0.5rem; }
.modal-backdrop { --bs-backdrop-bg: #0B1B33; --bs-backdrop-opacity: 0.32; }

/* ---------- Loading indicators ---------- */

/* A thin bar at the top while a page or form is loading. */
.page-progress {
  position: fixed; top: 0; left: 0; z-index: 1100; height: 2px; width: 0; background: var(--brand-blue); opacity: 0;
  transition: width 1.2s var(--ease), opacity 0.2s ease;
}
.page-progress.is-active { width: 70%; opacity: 1; }

.skeleton {
  display: block; height: 0.875rem; border-radius: 0.35rem; margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #EEF2F7 0%, #F6F8FB 50%, #EEF2F7 100%); background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}
.skeleton--title { height: 1.25rem; width: 40%; }
.skeleton--short { width: 60%; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .page-progress { transition: none; } }

.spinner-border { --bs-spinner-border-width: 0.15em; }

/* ---------- Empty and error states ---------- */

.empty-state {
  max-width: 34rem; margin: 2rem auto; padding: 2.5rem 1.5rem; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.empty-state h1, .empty-state h2 { font-size: 1.25rem; }
.empty-state p { color: var(--text-muted); }
.empty-state--inline { margin: 0; max-width: none; box-shadow: none; border-style: dashed; padding: 2rem 1.25rem; }
.empty-state--left { text-align: left; margin-left: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
.empty-state--left p { margin: 0; }
.empty-state__icon {
  display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; margin-bottom: 1rem;
  border-radius: 50%; background: var(--tint); color: var(--brand-blue);
}
.empty-state--left .empty-state__icon { margin-bottom: 0; }
.empty-state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }

/* ---------- Header ---------- */

.topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 0.75rem;
  height: var(--topbar-offset);
  padding: var(--safe-top) calc(var(--ba-eye-offset) + var(--safe-right)) 0 calc(var(--ba-eye-offset) + var(--safe-left));
  background: rgba(255, 255, 255, 0.94); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(10px);
}
.topbar__end { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.topbar__link { color: var(--text); font-weight: 600; padding-inline: 0.5rem; }
.topbar__link:hover { color: var(--brand-blue); }

.partner-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--line);
  padding: 0.15rem 0.55rem; border-radius: 999px;
}
.partner-chip::before { content: ""; width: 0.35rem; height: 0.35rem; border-radius: 50%; background: var(--brand-orange); }

.agency-switch {
  display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15;
  padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  max-width: 16rem; text-align: left; color: var(--text);
}
.agency-switch.dropdown-toggle { padding-right: 1.75rem; position: relative; }
.agency-switch.dropdown-toggle::after { position: absolute; right: 0.7rem; top: 50%; margin-top: -0.15rem; }
.agency-switch:hover { border-color: var(--line-strong); }
.agency-switch__label { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 650; }
.agency-switch__name { font-weight: 600; font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 767.98px) { .agency-switch { display: none; } }

.topbar-bell { position: relative; text-decoration: none; }
.topbar-bell .icon { width: 1.15rem; height: 1.15rem; }
.topbar-badge {
  position: absolute; top: -0.35rem; right: -0.35rem; min-width: 1.15rem; height: 1.15rem; padding: 0 0.3rem;
  border-radius: 999px; background: var(--brand-orange); color: var(--brand-navy);
  font-size: 0.6875rem; font-weight: 700; line-height: 1.15rem; text-align: center;
}

.avatar {
  position: relative; width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--tint); color: var(--tint-text); font-weight: 650; font-size: 0.8125rem;
}
.avatar:hover { border-color: var(--brand-blue); }
.avatar__dot { position: absolute; top: -1px; right: -1px; width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--brand-orange); border: 2px solid #FFFFFF; }
.account-menu { min-width: 14rem; }
.account-menu__head { display: flex; flex-direction: column; padding: 0.5rem 0.75rem 0.4rem; }
.account-menu__head strong { font-size: 0.9rem; }
.account-menu__head span { font-size: 0.8125rem; color: var(--text-muted); }

/* ---------- Frame and sidebar ---------- */

.app-frame { display: flex; min-height: calc(100vh - var(--topbar-offset)); }
.app-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-main {
  flex: 1 0 auto; width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 1.5rem max(1rem, var(--safe-right)) 3rem max(1rem, var(--safe-left));
}
@media (min-width: 992px) { .app-main { padding: 2.25rem 2.5rem 4rem; } }

/* Every page's content sits in one bordered panel on the light page background, a small gap from the top bar, sidebar and screen edges. */
.app-main {
  width: calc(100% - 1.5rem);
  margin: 0.75rem auto 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
@media (min-width: 992px) { .app-main { width: calc(100% - 3rem); margin-top: 1.5rem; } }
.app-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem;
  padding: 1.25rem max(1rem, var(--safe-right)) calc(1.25rem + var(--safe-bottom)) max(1rem, var(--safe-left));
  border-top: 1px solid var(--line); font-size: 0.8125rem; color: var(--text-muted);
}
@media (min-width: 992px) { .app-footer { padding-left: 2.5rem; padding-right: 2.5rem; } }

.sidebar { --bs-offcanvas-width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--line); }
.sidebar.offcanvas-lg { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); padding-left: var(--safe-left); }
@media (min-width: 992px) {
  .sidebar.offcanvas-lg { padding: 0; }
  .sidebar { position: sticky; top: var(--topbar-offset); align-self: flex-start; width: var(--sidebar-width); height: calc(100vh - var(--topbar-offset)); overflow-y: auto; flex: none; }
}
.sidebar__agency { font-weight: 650; color: var(--text); }
.sidebar__body { padding: 1rem 0.75rem 2rem; width: 100%; }
.sidebar__group { margin: 1.25rem 0.75rem 0.4rem; font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.sidebar__group:first-child { margin-top: 0.25rem; }
.sidebar__list { list-style: none; margin: 0; padding: 0; }
.sidebar__link {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 550; font-size: 0.875rem;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar__link .icon { width: 1.1rem; height: 1.1rem; }
.sidebar__link:hover { background: var(--surface-sunken); color: var(--text); }
.sidebar__link.is-current { background: var(--tint); color: var(--tint-text); }
.sidebar__link.is-current .icon { color: var(--brand-blue); }
.sidebar__soon { margin-left: auto; font-size: 0.625rem; font-weight: 600; color: var(--text-muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; }

/* ---------- Page structure ---------- */

.page-head { margin-bottom: 1.75rem; }
.page-head--row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-head h1 { margin-bottom: 0.35rem; }
.page-head__lead { color: var(--text-muted); margin: 0; max-width: 42rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.narrow { max-width: 46rem; margin: 0 auto; }
.section { margin-top: 2.25rem; }
.section__title { font-size: 1rem; font-weight: 650; margin-bottom: 1rem; }

.invite-list { list-style: none; padding: 0; margin: 0; }
.invite { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.invite:first-child { border-top: 0; padding-top: 0; }
.invite__meta { display: block; font-size: 0.8125rem; color: var(--text-muted); }
.invite__actions { display: flex; gap: 0.5rem; }

/* ---------- Partner home ---------- */

.hero { display: grid; gap: 2rem; align-items: center; grid-template-columns: minmax(0, 1fr); padding: 2rem 0 2.5rem; }
@media (min-width: 992px) { .hero { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); padding: 3.5rem 0 3rem; } }
.hero__title { font-size: clamp(2rem, 1.4rem + 2.2vw, 3rem); line-height: 1.08; letter-spacing: -0.035em; margin-bottom: 1rem; }
.hero__lead { font-size: 1.0625rem; color: var(--text-muted); max-width: 36rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.75rem 0 1rem; }
.hero__note { font-size: 0.8125rem; color: var(--text-muted); }
.hero__panel { padding: 1.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.hero__panel-title { font-size: 0.75rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1rem; }
.hero__steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; }
.hero__steps li { counter-increment: step; position: relative; padding-left: 2.6rem; color: var(--text-muted); font-size: 0.9rem; }
.hero__steps li strong { display: block; color: var(--text); font-size: 0.9375rem; }
.hero__steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0.05rem;
  display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong); font-size: 0.75rem; font-weight: 650; color: var(--text);
}
.hero__steps li:first-child::before { background: var(--tint); border-color: var(--tint); color: var(--tint-text); }

.feature-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.feature { padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.feature .icon { width: 1.5rem; height: 1.5rem; color: var(--brand-blue); margin-bottom: 0.9rem; }
.feature h2 { font-size: 1rem; margin-bottom: 0.4rem; }
.feature p { margin: 0; font-size: 0.875rem; color: var(--text-muted); }

/* ---------- Registration steps ---------- */

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; padding: 0; margin: 0 0 1.5rem; }
.steps__item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-muted); }
.steps__item span {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 1px solid var(--line-strong); font-size: 0.75rem; font-weight: 650; background: var(--surface);
}
.steps__item.is-current { color: var(--text); font-weight: 600; }
.steps__item.is-current span { background: var(--tint); border-color: var(--tint); color: var(--tint-text); }

/* ---------- Sign-in pages (the layout's "auth" mode) ---------- */

.page-auth { background: var(--page); }
.page-auth .app-footer { border-top: 0; }
.auth-main {
  flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem max(1rem, var(--safe-right)) 3rem max(1rem, var(--safe-left));
}
.auth-main > .notice { width: 100%; max-width: 26rem; }
.auth-card {
  width: 100%; max-width: 27rem;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 576px) { .auth-card { padding: 2.25rem 2.25rem 2rem; } }
.auth-card__title { font-size: 1.625rem; margin-bottom: 0.5rem; }
.auth-card__lead { color: var(--text-muted); margin-bottom: 1.75rem; }
.auth-card__foot { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--text-muted); }
.auth-card__foot p { margin-bottom: 0.4rem; }

/* ---------- Design reference page (Development only) ---------- */

.swatches { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
.swatch { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); font-size: 0.8125rem; }
.swatch__chip { height: 3rem; border-bottom: 1px solid var(--line); }
.swatch__label { padding: 0.5rem 0.65rem; }
.swatch__label code { display: block; color: var(--text-muted); font-size: 0.75rem; }
.swatch--white .swatch__chip { background: #FFFFFF; }
.swatch--surface .swatch__chip { background: #F7F9FC; }
.swatch--navy .swatch__chip { background: #071B35; }
.swatch--blue .swatch__chip { background: #0866F5; }
.swatch--light-blue .swatch__chip { background: #EAF2FF; }
.swatch--orange .swatch__chip { background: #FF8A00; }
.swatch--border .swatch__chip { background: #E8EDF3; }
.swatch--secondary .swatch__chip { background: #718096; }
.swatch--success .swatch__chip { background: #198754; }
.swatch--warning .swatch__chip { background: #E6A23C; }
.swatch--error .swatch__chip { background: #DC3545; }
.design-sample { display: inline-block; font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--warning-text); background: var(--warning-bg); border-radius: 999px; padding: 0.1rem 0.55rem; }
.map-placeholder {
  display: flex; align-items: center; justify-content: center; min-height: 16rem; padding: 1.5rem; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--brand-surface-2); color: var(--text-muted);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.5rem; border-left: 1px solid var(--line); margin-left: 0.4rem; font-size: 0.875rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -0.36rem; top: 0.35rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.timeline time { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* Dashboard: one simple chart (buses by status) and a warning tone for status notes. Colours stay restrained: blue, a soft amber, grey. */
.stat__note--warning { color: var(--warning-text); }
.fleet-bar { display: block; width: 100%; height: 0.75rem; border-radius: 999px; overflow: hidden; background: var(--surface-sunken); }
.fleet-bar__active { fill: var(--brand-blue); }
.fleet-bar__maintenance { fill: var(--brand-orange); opacity: 0.7; }
.fleet-bar__retired { fill: #B8C2D3; }
.fleet-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; padding: 0; margin: 0.75rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.fleet-legend__swatch { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 2px; margin-right: 0.375rem; vertical-align: baseline; }
.fleet-legend__swatch--active { background: var(--brand-blue); }
.fleet-legend__swatch--maintenance { background: var(--brand-orange); opacity: 0.7; }
.fleet-legend__swatch--retired { background: #B8C2D3; }
