/* style.css — UBC RideLink design system (from Naman's design spec and CodePen prototype).
 *
 * Most rules style plain HTML elements (h1, form, input, button, ul > li), so every page
 * picks up the design without extra classes. The classes further down (.match-card,
 * .badge-low, .status-banner, ...) are copied from the prototype for the parts that need
 * a specific layout.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Colour tokens */
  --color-primary: #0C2340;        /* UBC Navy: header, main buttons, headings */
  --color-primary-hover: #16365D;
  --color-action: #059669;         /* Match Emerald: confirmed / active / success */
  --color-action-hover: #047857;
  --color-action-bg: #D1FAE5;
  --color-constraint: #D97706;     /* Alert Amber: detour slider, warnings */
  --color-constraint-bg: #FEF3C7;
  --color-surface: #FFFFFF;        /* cards, inputs */
  --color-bg: #F8FAFC;             /* page background */
  --color-border: #E2E8F0;
  --color-text-main: #0F172A;
  --color-text-muted: #64748B;
  --color-error: #DC2626;

  --font-family-base: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background-color: var(--color-bg);
  overflow-x: hidden; /* the header bar below is full width */
}

/* One centred, phone-width column on every screen size. */
body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  padding: 0 18px 40px;
  font-family: var(--font-family-base);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  /* Tabular figures: times, minutes and prices line up and don't jitter. */
  font-variant-numeric: tabular-nums;
}

/* ---------- Typography ---------- */

/* Every page starts with <h1>UBC RideLink</h1>: shown as the navy app bar. */
body > h1:first-of-type {
  /* Stretches past the centred column to the edges of the window. */
  margin: 0 calc(50% - 50vw) 20px;
  padding: 14px calc(50vw - 50%);
  background-color: var(--color-primary);
  color: var(--color-surface);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Page titles ("My Rides", "Rideshare Complete!") use the spec's H1 size. */
h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-primary);
}

h3 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-primary);
}

p {
  margin: 0 0 16px;
}

/* The line right under a page title. */
h2 + p {
  font-size: 14px;
  color: var(--color-text-muted);
}

a {
  color: var(--color-primary);
}

strong {
  font-weight: 700;
}

.caption {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ---------- Cards ---------- */

.card,
form {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
  margin: 0 0 16px;
}

/* ---------- Forms ---------- */

form {
  display: flex;
  flex-direction: column;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-main);
}

form > label:first-child {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
select {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  background-color: var(--color-surface);
}

/* Pages mark a bad field with a red border (style.borderColor = 'red'). */
input[style*="red"],
select[style*="red"] {
  border-width: 2px;
  background-color: #FEF2F2;
}

/* ---------- Detour slider (Alert Amber, 44px thumb) ---------- */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  margin: 18px 0 10px;
  background: var(--color-border);
  border-radius: 4px;
  outline: none;
  accent-color: var(--color-constraint);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-constraint);
  border: 4px solid var(--color-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-constraint);
  border: 4px solid var(--color-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--color-constraint);
}

/* The live "10 min max" under the slider, shown as an amber pill. */
.detour-readout {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 10px;
  margin-right: 4px;
  font-size: 14px;
  font-weight: 700;
  color: #92400E;
  background-color: var(--color-constraint-bg);
  border: 1px solid var(--color-constraint);
  border-radius: 999px;
}

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

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-surface);
  background-color: var(--color-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

button:hover,
.btn:hover {
  background-color: var(--color-primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Main button of a form, and the dashboard / "Back" links: full width. */
form button[type="submit"],
.btn {
  width: 100%;
  margin: 16px 0 0;
}

body > .btn {
  display: flex; /* a block, so it lines up with the cards above it */
  margin: 0 0 10px;
}

/* Secondary buttons: Resend code, Log out. */
#resend,
#logout,
.btn-secondary {
  width: 100%;
  color: var(--color-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

#resend:hover,
#logout:hover,
.btn-secondary:hover {
  background-color: var(--color-bg);
}

/* Green "confirm" buttons. */
.btn-action,
#end-trip {
  width: 100%;
  color: var(--color-surface);
  background-color: var(--color-action);
}

.btn-action:hover,
#end-trip:hover {
  background-color: var(--color-action-hover);
}

/* ---------- Messages ---------- */

/* #error holds both errors and empty states, so it shows as an amber notice card. */
#error:not(:empty) {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: #92400E;
  background-color: var(--color-constraint-bg);
  border: 1px solid var(--color-constraint);
  border-radius: 10px;
}

#info:not(:empty) {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #065F46;
  background-color: var(--color-action-bg);
  border-radius: 8px;
}

/* ---------- Lists as cards (matches, my rides, my requests) ---------- */

ul {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

ul > li {
  margin-bottom: 10px;
  padding: 14px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

ul > li > p {
  margin: 0 0 8px;
  font-weight: 600;
}

/* Small buttons inside a card (Accept, Decline, Start Trip). */
li button {
  min-height: 40px;
  padding: 8px 14px;
  margin: 6px 8px 0 0;
  font-size: 13px;
  background-color: var(--color-action);
}

li button:hover {
  background-color: var(--color-action-hover);
}

/* The second button in a row (Decline) is the quiet one. */
li button + button {
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

li button + button:hover {
  background-color: var(--color-bg);
}

/* Requests inside a ride card (My Rides): rows, not cards. */
li ul {
  margin: 8px 0 0;
}

li li {
  margin: 0;
  padding: 10px 0 0;
  border: none;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
}

/* ---------- Match cards (matches.js) ---------- */

li.match-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.match-info {
  flex: 1;
}

.match-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.match-name {
  font-size: 16px;
  font-weight: 700;
}

.badge-detour {
  white-space: nowrap;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 99px;
}

.badge-low {
  color: #065F46;
  background-color: var(--color-action-bg);
}

.badge-high {
  color: #92400E;
  background-color: var(--color-constraint-bg);
}

.match-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.match-price {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-primary);
}

.match-right button {
  margin: 0;
}

/* ---------- Active trip and ride complete ---------- */

.status-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #065F46;
  background-color: var(--color-action-bg);
  border-radius: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-action);
}

.payment-card {
  padding: 22px 16px;
  text-align: center;
}

.fare-callout {
  margin: 6px 0 12px;
  font-size: 40px;
  font-weight: 700;
  color: var(--color-primary);
}

/* The dashboard's "trip in progress" link. */
#active-trip:not([hidden]) {
  padding: 10px 14px;
  font-weight: 700;
  background-color: var(--color-action-bg);
  border-radius: 8px;
}

#active-trip a {
  color: #065F46;
}

/* ---------- Login page ---------- */

.hero h2 {
  margin-bottom: 8px;
}

.hero p {
  color: var(--color-text-muted);
}

.form-note {
  margin: 12px 0 0;
  text-align: center;
}

/* Testing mode box (only shows when TEST_LOGIN is on). */
.test-login {
  border: 2px dashed var(--color-constraint);
}

.test-login[hidden] {
  display: none;
}

.test-login p {
  margin-bottom: 8px;
}

.test-login button {
  width: 100%;
  margin-top: 8px;
}

/* ---------- Dashboard tiles ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 14px;
  text-decoration: none;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tile:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 14px rgba(12, 35, 64, 0.08);
}

.tile-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
}

/* ---------- Matches page: list + map ---------- */

.matches-layout {
  display: flex;
  flex-direction: column;
}

.map {
  order: -1; /* on a phone, the map sits above the list */
  height: 260px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 0;
}

.map[hidden] {
  display: none;
}

/* The "P" parkade pins. */
.map-parking {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-base);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-surface);
  background-color: var(--color-primary);
  border: 2px solid var(--color-surface);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.leaflet-tooltip {
  font-family: var(--font-family-base);
  font-weight: 600;
}

/* ---------- Rows with buttons (My Rides, My Requests) ---------- */

/* Text on the left, buttons on the right, all on one line when there's room. */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.row-actions button {
  margin: 0;
}

.btn-quiet,
li .btn-quiet {
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

.btn-quiet:hover,
li .btn-quiet:hover {
  background-color: var(--color-bg);
}

.status-pill {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
}

.status-pending {
  color: #92400E;
  background-color: var(--color-constraint-bg);
}

.status-accepted {
  color: #065F46;
  background-color: var(--color-action-bg);
}

.status-declined {
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
}

/* "Driver leaves from / Pickup" addresses, shown after a request is accepted. */
.address {
  margin: 10px 0 0;
  font-weight: 600;
}

.address .caption {
  display: block;
}

.address-card:empty {
  display: none;
}

.address-card .address:first-child {
  margin-top: 0;
}

/* ---------- Area box helpers ---------- */

.btn-locate {
  align-self: flex-start;
  min-height: 36px;
  margin: -2px 0 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--color-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

.btn-locate:hover {
  background-color: var(--color-bg);
}

/* ---------- Small maps and the "My location" button ---------- */

.mini-map {
  height: 220px;
  margin-top: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 0;
}

.trip-map {
  order: 0;
  height: 320px;
  margin: 0 0 16px;
}

.map-locate {
  min-height: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--color-primary);
  background-color: var(--color-surface);
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.map-locate:hover {
  background-color: var(--color-bg);
}

/* ---------- Fare and chat ---------- */

/* "pays you $1.27" / "you pay $1.27" next to a request. */
.fare-tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-primary);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.chat {
  margin-top: 10px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.chat-empty {
  margin: 0;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  padding: 7px 11px;
  font-size: 14px;
  line-height: 1.35;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

.chat-mine {
  align-self: flex-end;
  color: var(--color-surface);
  background-color: var(--color-primary);
  border-bottom-right-radius: 4px;
}

.chat-theirs {
  align-self: flex-start;
  color: var(--color-text-main);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.chat-meta {
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.75;
}

/* The message box: a row, not a card like other forms. */
form.chat-form {
  flex-direction: row;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  background: none;
  border: none;
}

.chat-form input[type="text"] {
  flex: 1;
  min-width: 0;
  margin: 0;
}

form.chat-form button[type="submit"],
li .chat-form button {
  width: auto;
  min-height: 44px;
  margin: 0;
  background-color: var(--color-primary);
}

.chat-status:empty {
  display: none;
}

.chat-status {
  margin: 6px 0 0;
  color: var(--color-error);
}

/* The "Navigate in Google Maps" button on the trip page. */
.nav-btn {
  display: flex;
  margin: 0 0 16px;
  text-align: center;
}

.nav-btn[hidden] {
  display: none;
}

/* ---------- Computers and tablets ---------- */

@media (min-width: 900px) {
  body {
    max-width: 1040px;
    padding: 0 32px 56px;
  }

  body > h1:first-of-type {
    margin-bottom: 36px;
    padding-top: 18px;
    padding-bottom: 18px;
    font-size: 18px;
  }

  h2 {
    font-size: 28px;
  }

  /* Forms and single-column pages: a readable width in the middle. */
  body > form,
  body > h2,
  body > h2 + p,
  body > p,
  body > ul,
  body > div:not(.matches-layout):not(.auth-layout):not(.tile-grid):not(.test-login),
  body > .btn {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }

  /* The dashboard and matches pages use the full width instead. */
  body:has(.tile-grid) > *,
  body:has(.matches-layout) > * {
    max-width: none;
  }

  body > form {
    padding: 24px;
  }

  /* Login: intro on the left, form on the right. */
  .auth-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 56px;
    align-items: center;
    min-height: 60vh;
  }

  .hero h2 {
    font-size: 40px;
    line-height: 1.15;
  }

  .hero p {
    font-size: 17px;
    max-width: 440px;
  }

  .auth-layout form {
    padding: 24px;
    margin: 0;
  }

  /* Dashboard: four cards in a row. */
  .tile-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: none;
  }

  .tile {
    min-height: 120px;
    padding: 20px;
  }

  body > p:has(#logout) {
    max-width: 240px;
    margin-left: 0;
  }

  /* Testing mode box: lines up under the login form. */
  body > .test-login {
    max-width: 400px;
    margin-left: auto;
    margin-right: 0;
  }

  /* Matches: list on the left, map on the right. */
  .matches-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .map {
    order: 0;
    position: sticky;
    top: 24px;
    height: 560px;
    margin: 0;
  }
}

/* =====================================================================
 * Polish: top bar, notifications, toasts, dashboard, empty states.
 * ===================================================================== */

/* ---------- Top bar (nav.js turns the <h1> into this) ---------- */

body > h1.topbar {
  position: sticky;
  top: 0;
  z-index: 1100; /* above the maps (Leaflet uses up to 1000) */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
  box-shadow: 0 2px 12px rgba(12, 35, 64, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--color-surface);
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark svg {
  display: block;
  width: 30px;
  height: 30px;
}

.brand:hover {
  opacity: 0.9;
}

.topbar-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

button.bell {
  position: relative;
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  color: var(--color-surface);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
}

button.bell:hover {
  background: rgba(255, 255, 255, 0.2);
}

.bell svg,
.notif-icon svg,
.tile-icon svg,
.empty-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: var(--color-error);
  border: 2px solid var(--color-primary);
  border-radius: 999px;
}

.bell-badge[hidden] {
  display: none;
}

/* ---------- Notification list ---------- */

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1200;
  width: min(360px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  animation: pop-in 0.15s ease-out;
}

.notif-panel[hidden] {
  display: none;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 15px;
  border-bottom: 1px solid var(--color-border);
}

button.notif-clear {
  width: auto;
  min-height: 0;
  padding: 4px 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-action);
  background: none;
}

button.notif-clear:hover {
  background: var(--color-action-bg);
}

ul.notif-list {
  margin: 0;
}

ul.notif-list > li {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  box-shadow: none;
}

ul.notif-list > li:last-child {
  border-bottom: none;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-text-main);
  text-decoration: none;
}

a.notif-item:hover {
  background: var(--color-bg);
}

.notif-item.unread {
  background: #F0FDF4;
}

.notif-item.unread .notif-body > span:first-child {
  font-weight: 700;
}

.notif-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--color-primary);
  background: var(--color-bg);
  border-radius: 50%;
}

.notif-icon svg {
  width: 16px;
  height: 16px;
}

.notif-accepted,
.notif-match {
  color: var(--color-action);
  background: var(--color-action-bg);
}

.notif-request {
  color: #92400E;
  background: var(--color-constraint-bg);
}

.notif-declined {
  color: var(--color-error);
  background: #FEE2E2;
}

.notif-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notif-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.notif-empty {
  padding: 18px 14px !important;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: auto;
}

.toast-show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #065F46;
}

.toast-error {
  background: #B91C1C;
}

.toast-info {
  background: var(--color-primary);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- General polish ---------- */

.card,
form,
ul > li,
.tile {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
}

body > h2,
body > h2 + p,
.dash-hero,
.matches-layout,
body > form,
body > ul,
.tile-grid {
  animation: fade-up 0.3s ease-out both;
}

button:active:not(:disabled),
.btn:active {
  transform: scale(0.98);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(5, 150, 105, 0.45);
  outline-offset: 2px;
}

.btn-small,
li .btn-small {
  min-height: 32px;
  padding: 4px 10px;
  margin: 0;
  font-size: 12px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-surface);
  background: var(--color-primary);
  border-radius: 50%;
}

/* Grey "loading" shapes that shimmer. */
.skeleton {
  background: linear-gradient(90deg, #EEF2F7 25%, #F8FAFC 50%, #EEF2F7 75%) !important;
  background-size: 200% 100% !important;
  border-color: transparent !important;
  box-shadow: none !important;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-card {
  height: 86px;
}

.skeleton-row {
  height: 58px;
  border-radius: 10px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- Empty states ("nothing here yet") ---------- */

.empty-state,
ul > li.empty-state {
  padding: 28px 20px;
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed #CBD5E1;
  border-radius: 12px;
}

.empty-state h3 {
  margin: 8px 0 6px;
}

.empty-state p {
  max-width: 420px;
  margin: 0 auto 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  color: var(--color-action);
  background: var(--color-action-bg);
  border-radius: 50%;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.empty-actions .btn,
.empty-actions button,
li .empty-actions button {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 10px 18px;
  font-size: 14px;
}

/* ---------- Search results ---------- */

.search-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-weight: 600;
  color: var(--color-text-main) !important;
}

.search-summary a {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-action);
}

.match-right .caption {
  margin-top: -6px;
  font-size: 11px;
}

.match-right button.btn-done,
button.btn-done:disabled {
  opacity: 1;
  color: #065F46;
  background: var(--color-action-bg);
}

.btn-alert {
  margin-top: 0 !important;
  margin-bottom: 10px !important;
}

/* ---------- Dashboard ---------- */

.dash-hero {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-action);
}

.dash-hero h2 {
  font-size: 28px;
}

.dash-hero p:last-child {
  margin-bottom: 0;
  font-size: 15px;
  color: var(--color-text-muted);
}

.section-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.dash-section {
  margin-bottom: 18px;
}

ul.next-list > li {
  padding: 0;
  margin-bottom: 8px;
  overflow: hidden;
}

ul.next-list > li.next-empty {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
}

.next-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--color-text-main);
  text-decoration: none;
}

.next-item:hover {
  background: var(--color-bg);
}

.next-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
}

.next-green .next-dot {
  background: var(--color-action);
  box-shadow: 0 0 0 4px var(--color-action-bg);
}

.next-amber .next-dot {
  background: var(--color-constraint);
  box-shadow: 0 0 0 4px var(--color-constraint-bg);
}

.next-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.next-action {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-action);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-row[hidden] {
  display: none;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-primary);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tile {
  position: relative;
}

.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  color: var(--color-primary);
  background: var(--color-bg);
  border-radius: 10px;
}

.tile-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.tile-primary .tile-title {
  color: var(--color-surface);
}

.tile-primary .caption {
  color: rgba(255, 255, 255, 0.75);
}

.tile-primary .tile-icon {
  color: var(--color-surface);
  background: rgba(255, 255, 255, 0.12);
}

.tile-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  color: #fff;
  background: var(--color-error);
  border-radius: 999px;
}

.tile-badge[hidden] {
  display: none;
}

.alerts-card h3 {
  margin-bottom: 2px;
}

ul.alert-list {
  margin: 10px 0 0;
}

ul.alert-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}

/* ---------- Chat: keep scrolling inside the chat from moving the page ---------- */

.chat-list {
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

@media (max-width: 420px) {
  .topbar-user {
    display: none;
  }

  .stat-value {
    font-size: 20px;
  }
}

@media (min-width: 900px) {
  body > h1.topbar {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .toast-stack {
    left: auto;
    right: 24px;
    bottom: 24px;
    transform: none;
  }

  .dashboard-page .dash-hero h2 {
    font-size: 34px;
  }

  /* The dashboard uses the full width (beats the 600px rule for single-column pages). */
  body.dashboard-page > div.stat-row {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body > .empty-state {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
}
