:root {
  /* Base / Background */
  --clr-black: #000000;
  --clr-darkest: #261B0E;
  --clr-dark: #493F31;
  --clr-mid: #614420;

  /* Brand / Accent */
  --clr-gold: #85663D;
  --clr-gold-light: #A8844E;
  --clr-cream: #E8D5B0;

  /* Text */
  --clr-white: #FFFFFF;
  --clr-text: #D4BF9A;
  --clr-muted: #8A7860;

  /* Status */
  --clr-error: #E05555;
  --clr-success: #4CAD72;
  --clr-warning: #E0A534;
  --clr-info: #4A90D9;

  /* Derived surfaces -- blends of the tokens above, needed for input fields
     and status backgrounds on a dark theme. Not given directly, but built
     only from the palette colors so the system stays consistent. */
  --clr-field: #302618;         /* input/select idle surface (darkest + dark) */
  --clr-field-focus: #372D1F;   /* input/select focus surface (darkest + dark) */
  --clr-success-bg: #2E3B24;    /* success + darkest */
  --clr-error-bg: #4F281E;      /* error + darkest */
  --clr-warning-bg: #4F3916;    /* warning + darkest */
  --clr-info-bg: #2E353A;       /* info + darkest */

  /* Semantic roles used throughout component CSS below -- only these get
     referenced outside :root, so the palette stays the single source of
     truth for every color in the system. */
  --color-primary: var(--clr-gold);
  --color-primary-dark: var(--clr-gold-light); /* hover brightens, not darkens, on a dark theme */
  --color-secondary: var(--clr-gold-light);
  --color-dark: var(--clr-darkest);
  --color-bg: var(--clr-black);
  --color-card-bg: var(--clr-darkest);
  --color-text: var(--clr-text);
  --color-text-muted: var(--clr-muted);
  --color-border: var(--clr-dark);

  --color-success: var(--clr-success);
  --color-success-bg: var(--clr-success-bg);
  --color-error: var(--clr-error);
  --color-error-bg: var(--clr-error-bg);
  --color-warning: var(--clr-warning);
  --color-warning-bg: var(--clr-warning-bg);
  --color-info: var(--clr-info);
  --color-info-bg: var(--clr-info-bg);

  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.5rem; }

/* Headings and emphasized values read as "primary text" -> white, per the
   palette spec; everything else defaults to the cream body text color. */
h1, h2, h3,
strong,
.auth-heading,
.auth-brand__name,
.app-nav__brand,
.route-card__title,
.stat-card__value,
.profile-grid dd,
.data-table th {
  color: var(--clr-white);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--color-primary);
  color: var(--clr-white);
  transition: background 0.15s ease;
}
.btn:hover { background: var(--color-primary-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn--ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn--ghost:hover { background: var(--color-border); }
.btn--success { background: var(--color-success); }
.btn--success:hover { background: #3d8a5b; } /* shade of clr-success */
.btn--danger { background: var(--color-error); }
.btn--danger:hover { background: #b34444; } /* shade of clr-error */

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field--full { grid-column: 1 / -1; }
.field__label { font-weight: 600; font-size: 0.9rem; }
.field__label small { font-weight: 400; color: var(--color-text-muted); display: block; }
/* Grid rows stretch every .field to the height of its tallest sibling (e.g.
   a label with a wrapping hint vs. one without) -- pin the actual control to
   the bottom of that extra space so inputs across a row line up, instead of
   the shorter field's input floating above its neighbor's. */
.field > input, .field > select, .field > textarea, .field > .field__password-wrap {
  margin-top: auto;
}

.field-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem 1rem; }
@media (min-width: 640px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}

.form-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-section legend {
  font-weight: 700;
  padding: 0 0.4rem;
  font-size: 1rem;
}

.checkbox-group { display: flex; flex-wrap: wrap; gap: 1rem; }

.route-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
@media (min-width: 640px) {
  .route-row { grid-template-columns: 1fr 1fr 2fr auto; align-items: center; }
}

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], select, textarea {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  font-family: inherit;
  background: var(--clr-field);
  color: var(--clr-white);
  transition: border-color 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  background: var(--clr-field-focus);
  border-color: var(--color-primary);
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.field__password-wrap { position: relative; display: flex; }
.field__password-wrap input { padding-right: 2.5rem; }
.password-toggle {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin: 1rem 0;
}
.checkbox-field input { width: auto; margin-top: 0.2rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: var(--color-error-bg); color: var(--color-error); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--color-border);
}
.badge--pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--approved { background: var(--color-success-bg); color: var(--color-success); }
.badge--rejected { background: var(--color-error-bg); color: var(--color-error); }
.badge--suspended { background: var(--color-border); color: var(--color-text); }
.badge--role { background: var(--clr-mid); color: var(--clr-white); }
.badge--draft { background: var(--color-border); color: var(--color-text); }
.badge--published { background: var(--color-success-bg); color: var(--color-success); }
.badge--archived { background: var(--clr-mid); color: var(--clr-white); }
.badge--participant { background: var(--clr-mid); color: var(--clr-white); }
.badge--obr { background: var(--color-info-bg); color: var(--color-info); }
.badge--unpaid { background: var(--color-error-bg); color: var(--color-error); }
.badge--partial { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--paid { background: var(--color-success-bg); color: var(--color-success); }
.badge--upcoming { background: var(--color-info-bg); color: var(--color-info); }
.badge--ongoing { background: var(--color-warning-bg); color: var(--color-warning); }

/* Route choice cards -- used both on the event registration form (clickable
   radio) and as a read-only listing of an event's defined routes. */
.route-choice { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }

@media (min-width: 640px) {
  .route-choice { grid-template-columns: repeat(3, 1fr); }
}

.route-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.route-card:hover { transform: translateY(-2px); }
.route-card input { position: absolute; top: 0.75rem; right: 0.75rem; }
.route-card:has(input:checked) { border-color: var(--color-primary); background: var(--color-warning-bg); }
.route-card__title { font-weight: 700; }
.route-card__distance { color: var(--color-primary); font-weight: 600; font-size: 0.9rem; }
.route-card__desc { font-size: 0.8rem; color: var(--color-text-muted); }
.route-card--readonly { cursor: default; }
.route-card--readonly:hover { transform: none; }

.error-stack {
  background: var(--clr-darkest);
  color: var(--clr-cream);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.75rem;
}

/* --- Sidebar + topbar (dashboards) ---
   Mobile: sidebar is an off-canvas overlay toggled from the topbar, with a
   backdrop to dismiss it. Desktop (>=1024px): sidebar is persistent and
   sticky alongside the content column. */
.app-layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 280px;
  max-width: 85vw;
  background: var(--color-dark);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.sidebar.is-open { transform: translateX(0); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
  display: none;
}
.sidebar-backdrop.is-open { display: block; }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.sidebar__logo { width: 3rem; height: 3rem; object-fit: contain; flex-shrink: 0; }
.sidebar__title { font-weight: 700; font-size: 1.1rem; color: var(--clr-white); line-height: 1.25; }

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}
.sidebar__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: var(--clr-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar__avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar__user-info { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.sidebar__email {
  font-size: 0.85rem;
  color: var(--clr-cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

.sidebar__menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem;
}
.sidebar__section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0.85rem 0.75rem 0.3rem;
}
.sidebar__section-label:first-child { padding-top: 0.25rem; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--clr-cream);
  font-weight: 500;
  font-size: 0.95rem;
}
.sidebar__link:hover { background: var(--color-border); color: var(--clr-white); text-decoration: none; }
.sidebar__link.is-active { background: var(--color-primary); color: var(--clr-white); }

.sidebar__logout { padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); margin: 0; }

.sidebar__link--event { gap: 0.5rem; padding-top: 0.5rem; padding-bottom: 0.5rem; font-size: 0.88rem; }
.sidebar__event-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sidebar__event-dot {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
}
.sidebar__event-dot--upcoming { background: #60a5fa; }
.sidebar__event-dot--ongoing  { background: #4ade80; }

.app-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--color-dark);
  border-bottom: 1px solid var(--color-border);
  padding: 0.85rem 1rem;
}
.topbar__toggle {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 0.4rem;
}
.topbar__toggle span { width: 22px; height: 2px; background: var(--clr-white); display: block; }
.topbar__title { margin: 0; font-size: 1.1rem; }

.topbar__announcements-link {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar__announcements-link:hover { background: var(--color-border); }
/* Phones: keep just the emoji to save space next to the page title --
   the full word comes back once there's room (tablet/desktop). */
.topbar__announcements-label { display: none; }
@media (min-width: 640px) {
  .topbar__announcements-label { display: inline; }
}

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.notif-widget { position: relative; }
.topbar__icon-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.4rem;
  cursor: pointer;
  border-radius: 8px;
}
.topbar__icon-btn:hover { background: var(--color-border); }
.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--color-error);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 320px;
  max-width: 90vw;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 30;
  overflow: hidden;
}
.notif-dropdown__header {
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.notif-list { list-style: none; margin: 0; padding: 0.25rem 0; max-height: 360px; overflow-y: auto; }
.notif-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-border); }
.notif-item.is-unread { background: rgba(212, 160, 60, 0.08); }
.notif-item.is-unread:hover { background: rgba(212, 160, 60, 0.16); }
.notif-item__icon { margin-right: 0.35rem; }
.notif-item__message {
  /* Long announcement text shouldn't blow out the dropdown's fixed width --
     crop to one line with an ellipsis; the full text is still readable by
     clicking through (announcement modal, or the linked page). */
  display: inline-block;
  max-width: calc(100% - 1.6rem);
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-item__time { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.15rem; }
.notif-empty { padding: 1rem; color: var(--color-text-muted); text-align: center; }


@media (min-width: 1024px) {
  .app-layout { display: flex; }
  .sidebar {
    position: sticky;
    top: 0;
    transform: none;
    flex-shrink: 0;
    width: 280px;
    max-width: none;
  }
  .sidebar-backdrop { display: none !important; }
  .app-content { flex: 1; min-width: 0; }
  .topbar__toggle { display: none; }
  .topbar { padding: 0.85rem 1.75rem; }
}

/* --- Dashboard layout --- */
.dashboard { width: 100%; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }

@media (min-width: 1024px) {
  .dashboard { padding: 1.75rem 2.25rem; }
}

.dashboard__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.dashboard__heading { margin: 0; font-size: 1.4rem; }

.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.card__header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card__header-row h2 { margin: 0; }

.is-hidden { display: none !important; }

.profile-form__actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

.status-banner {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--color-warning-bg);
  color: var(--color-warning);
  width: 100%;
}
@media (min-width: 640px) {
  .status-banner { width: auto; white-space: nowrap; margin-left: auto; }
}
.status-banner--approved { background: var(--color-success-bg); color: var(--color-success); }
.status-banner--rejected { background: var(--color-error-bg); color: var(--color-error); }
.status-banner--suspended { background: var(--color-border); color: var(--color-text); }

.profile-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 0; }
.profile-grid dt { font-size: 0.8rem; color: var(--color-text-muted); margin: 0; }
.profile-grid dd { margin: 0; font-weight: 600; }

.profile-actions { margin: 1rem 0 0; }

.is-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.avatar-uploader { display: flex; align-items: flex-start; gap: 1.25rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.avatar-uploader > form { margin: 0; }

.avatar-uploader__photo { position: relative; }

.avatar-uploader__preview {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: var(--clr-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.6rem;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: none;
  padding: 0;
}
.avatar-uploader__preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-uploader__preview:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }

.avatar-uploader__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.52);
  color: var(--clr-white);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.avatar-uploader__preview:hover .avatar-uploader__overlay,
.avatar-uploader__preview:focus-visible .avatar-uploader__overlay { opacity: 1; }

.avatar-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  z-index: 50;
  min-width: 180px;
  list-style: none;
  margin: 0;
  padding: 0.3rem 0;
}
.avatar-menu__item {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.avatar-menu__item:hover { background: var(--color-border); color: var(--clr-white); }
.avatar-menu__item--danger { color: var(--color-error); }
.avatar-menu__item--danger:hover { background: var(--color-error-bg); color: var(--color-error); }
.avatar-menu__separator { height: 1px; background: var(--color-border); margin: 0.25rem 0; }

.avatar-uploader__aside { display: flex; flex-direction: column; gap: 0.5rem; }
.avatar-uploader__aside form { margin: 0; }

.avatar-confirm__preview { width: 5rem; height: 5rem; border-radius: 50%; object-fit: cover; display: block; margin: 0.75rem auto 1rem; }
.modal__actions { display: flex; justify-content: center; gap: 0.75rem; margin-top: 1.25rem; }

.form-hint { font-size: 0.85rem; color: var(--color-text-muted); margin: 0.25rem 0 1rem; }

@media (min-width: 640px) {
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.stat-card { background: var(--color-card-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.stat-card__value { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-card__label { font-size: 0.8rem; color: var(--color-text-muted); }
.stat-card--pending .stat-card__value { color: var(--color-warning); }
.stat-card--approved .stat-card__value { color: var(--color-success); }
.stat-card--rejected .stat-card__value { color: var(--color-error); }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.route-breakdown { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.route-breakdown li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); }

.announcement-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.announcement-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; max-height: 320px; overflow-y: auto; }
.announcement-list li { border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; }
.announcement-list p { margin: 0.2rem 0 0; }
.announcement-time { font-size: 0.75rem; color: var(--color-text-muted); }
.announcement-empty { color: var(--color-text-muted); }

/* Modal preview list -- clickable rows, message cropped to a couple of
   lines so a long announcement doesn't dominate the list; the full text
   only appears once a specific one is opened in the detail pane. */
.announcement-list--preview { max-height: 60vh; }
.announcement-list--preview li {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
}
.announcement-list--preview li:hover { background: var(--color-border); }
.announcement-list--preview p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Sliding list <-> detail panes inside the announcements modal, same
   viewport/track/translateX technique as the event poster gallery. */
.announcement-modal__viewport { overflow: hidden; }
.announcement-modal__track { display: flex; transition: transform 0.3s ease; }
.announcement-modal__pane { flex: 0 0 100%; min-width: 0; }

/* Inline images an admin pasted into the announcement -- capped so a
   full-resolution screenshot/photo never overflows the editor or modal. */
.announcement-editor img,
#announcementDetailMessage img {
  max-width: 100%;
  max-height: 320px;
  display: block;
  border-radius: 8px;
  margin: 0.4rem 0;
}

.announcement-editor {
  min-height: 90px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  overflow-y: auto;
}
.announcement-editor:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.announcement-editor:empty::before { content: attr(data-placeholder); color: var(--color-text-muted); }

.event-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.event-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.event-card__link { display: block; padding: 0.85rem 1rem; color: var(--color-text); text-decoration: none; transition: background 0.15s ease; }
.event-card__link:hover { background: var(--color-border); }
.event-card__cover { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; margin: -0.85rem -1rem 0.65rem; display: block; width: calc(100% + 2rem); }
.event-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.event-card p {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.event-card__meta { display: inline-block; margin-right: 0.6rem; font-size: 0.78rem; color: var(--color-text-muted); }
.event-card__rates { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0.4rem 0 0.5rem; }
.event-card__rate { font-size: 1.15rem; font-weight: 700; color: var(--color-success); }
.event-card__rate-label { font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-right: 0.3rem; }
.event-card__pending-note { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--color-warning); }
.event-empty { color: var(--color-text-muted); text-align: center; padding: 1.5rem 0; list-style: none; grid-column: 1 / -1; }

.event-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 1rem; }

.markdown-content { line-height: 1.6; }
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4 { margin: 1.2em 0 0.5em; }
.markdown-content h1:first-child, .markdown-content h2:first-child, .markdown-content h3:first-child, .markdown-content h4:first-child { margin-top: 0; }
.markdown-content p { margin: 0 0 1em; }
.markdown-content ul, .markdown-content ol { margin: 0 0 1em; padding-left: 1.5em; }
.markdown-content a { color: var(--color-primary); }
.markdown-content blockquote { border-left: 3px solid var(--color-border); margin: 0 0 1em; padding-left: 1em; color: var(--color-text-muted); }
.markdown-content code { background: var(--clr-field); padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.9em; }
.markdown-content pre { background: var(--clr-field); padding: 0.75em 1em; border-radius: var(--radius); overflow-x: auto; }

.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.poster-thumb { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
.poster-thumb img { width: 100%; height: 110px; object-fit: cover; display: block; }
.poster-thumb form { position: absolute; bottom: 0.4rem; right: 0.4rem; margin: 0; }

.gallery { position: relative; }
.gallery__viewport { overflow: hidden; border-radius: var(--radius); }
.gallery__track { display: flex; transition: transform 0.3s ease; }
.gallery__slide { flex: 0 0 100%; background: var(--color-dark); }
/* object-fit: contain (not cover) -- posters are uploaded in mixed
   orientations (landscape event photos, portrait flyers), and cropping a
   tall portrait image to a short fixed height was hiding most of it,
   sometimes landing entirely on a dark/empty area and looking blank. */
.gallery__slide img { width: 100%; height: 420px; object-fit: contain; display: block; }
.gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: var(--clr-white);
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery__nav--prev { left: 0.75rem; }
.gallery__nav--next { right: 0.75rem; }
.gallery__dots { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.75rem; }
.gallery__dot { width: 9px; height: 9px; border-radius: 50%; border: none; background: var(--color-border); cursor: pointer; padding: 0; }
.gallery__dot.is-active { background: var(--color-primary); }

/* --- Modal dialogs (e.g. withdraw-from-event confirm-with-reason) --- */
.modal {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card-bg);
  color: var(--color-text);
  padding: 1.5rem;
  max-width: 500px;
  width: calc(100% - 2rem);
  position: fixed;
  inset: 0;
  margin: auto;
}
.modal--wide { max-width: 560px; }
.modal--xl { max-width: 760px; }
.modal::backdrop { background: rgba(0, 0, 0, 0.6); }
.modal h3 { margin-top: 0; }
.modal textarea { min-height: 100px; margin: 0.5rem 0 1rem; }

/* --- Event workspace tabs (Registered Riders / Payment / Kit / Quests) --- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1.25rem; }
.tab-button {
  background: none;
  border: none;
  padding: 0.65rem 1rem;
  color: var(--color-text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
}
.tab-button:hover { color: var(--color-text); }
.tab-button.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.payment-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.payment-form select, .payment-form input[type="number"], .payment-form input[type="text"] { width: auto; min-width: 120px; }

.tab-search-bar { margin-bottom: 0.75rem; }
.tab-search-input { width: 100%; max-width: 320px; padding: 0.45rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); font-size: 0.9rem; }
.tab-search-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent); }

.quest-add-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.quest-add-form input[type="text"] { width: auto; flex: 1; min-width: 180px; }

/* Quest management cards */
.quest-cards { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.quest-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.875rem 1rem; }
.quest-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.quest-card__meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; min-width: 0; }
.quest-card__title { font-weight: 600; color: var(--color-text); }
.quest-card__actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.quest-card__desc { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--color-text-muted); }

/* Quest rider accordion */
.quest-riders { display: flex; flex-direction: column; gap: 0.5rem; }
.quest-rider { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; }
.quest-rider__summary { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; cursor: pointer; list-style: none; user-select: none; flex-wrap: wrap; }
.quest-rider__summary::-webkit-details-marker { display: none; }
.quest-rider__summary::before { content: '▶'; font-size: 0.7rem; color: var(--color-text-muted); transition: transform 0.15s; flex-shrink: 0; }
details[open] > .quest-rider__summary::before { transform: rotate(90deg); }
.quest-rider__name { font-weight: 600; color: var(--color-text); }
.quest-rider__alias { font-size: 0.85rem; color: var(--color-text-muted); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.1rem 0.4rem; }
.quest-rider__progress { margin-left: auto; font-size: 0.82rem; color: var(--color-text-muted); white-space: nowrap; }
.quest-rider__body { border-top: 1px solid var(--color-border); padding: 0.75rem 1rem; }
.quest-rider__table { margin: 0; }
.quest-rider__quest-title { font-weight: 500; }

/* Participant quest tab */
.quest-progress-summary { margin: 0 0 1rem; font-size: 0.95rem; color: var(--color-text-muted); }
.my-quests { display: flex; flex-direction: column; gap: 0.75rem; }
.my-quest-card { display: flex; align-items: flex-start; gap: 0.75rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.9rem 1rem; }
.my-quest-card--done { border-color: var(--color-success); }
.my-quest-card__indicator { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 0.35rem; background: var(--color-border); }
.my-quest-card--done .my-quest-card__indicator { background: var(--color-success); }
.my-quest-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.my-quest-card__top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.my-quest-card__title { font-weight: 600; color: var(--color-text); }
.my-quest-card__desc { font-size: 0.85rem; color: var(--color-text-muted); }
.my-quest-card__badge { flex-shrink: 0; }

/* Quest photo submission — participant */
.my-quest-photos { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.my-quest-photo-thumb { display: block; width: 60px; height: 60px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--color-border); }
.my-quest-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.my-quest-upload-form { display: inline-flex; margin-top: 0.25rem; }
.my-quest-upload-btn { position: relative; cursor: pointer; }
.my-quest-file-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* Quest proof photos — admin tracker */
.quest-proof-thumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.quest-proof-thumb { display: block; width: 48px; height: 48px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--color-border); }
.quest-proof-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.data-table th form { display: inline-block; margin: 0 0 0 0.4rem; vertical-align: middle; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.checklist__item { display: flex; align-items: center; gap: 0.5rem; }
.checklist__icon { width: 1.1rem; text-align: center; }
.checklist__icon--done { color: var(--color-success); }
.checklist__icon--pending { color: var(--color-text-muted); }

.qr-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  margin: 0.75rem 0 1.25rem;
  text-align: center;
  background: var(--color-card-bg);
}
.qr-display__image { width: 220px; height: 220px; object-fit: contain; border-radius: 8px; background: #fff; padding: 0.5rem; }
.qr-display p { margin: 0; color: var(--color-text-muted); }

.receipt-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: -0.25rem 0 1rem;
  background: var(--color-card-bg);
}
.receipt-preview__image { max-width: 100%; max-height: 280px; object-fit: contain; border-radius: 8px; background: #fff; padding: 0.4rem; }
.receipt-preview__file { font-size: 0.95rem; color: var(--color-text); }

.receipt-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1.25rem; }
.receipt-gallery__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background 0.15s ease;
}
.receipt-gallery__item:hover { background: var(--color-border); }
.receipt-gallery__thumb { width: 100%; height: 100px; object-fit: cover; border-radius: 8px; background: #fff; }
.receipt-gallery__file {
  width: 100%;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 2rem;
  border-radius: 8px;
  background: var(--clr-field);
}
.receipt-gallery__file span { font-size: 0.7rem; color: var(--color-text-muted); }
.receipt-gallery__date { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; }
.receipt-gallery__ref { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; word-break: break-word; }

.receipt-links { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; }

.filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.filter-form label { display: flex; flex-direction: column; font-size: 0.85rem; gap: 0.25rem; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination__info { font-size: 0.85rem; color: var(--color-text-muted); }
.pagination .is-disabled { opacity: 0.4; pointer-events: none; }

.inline-form { margin: 0; }

/* --- Tables: stacked cards on mobile, real table on wider screens --- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; }

@media (max-width: 767px) {
  .data-table thead { display: none; }
  .data-table tr {
    display: block;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.35rem 0;
    border: none;
    text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  .actions-wrap { display: flex; flex-direction: column; gap: 0.4rem; align-items: stretch; }
  .actions-wrap form { width: 100%; margin: 0; }
  .actions-wrap .btn { width: 100%; text-align: center; box-sizing: border-box; display: block; }
}

@media (min-width: 768px) {
  .data-table { min-width: 700px; }
  .data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
  .data-table td:first-child { white-space: normal; min-width: 120px; }
  .data-table select { padding: 0.35rem 0.5rem; font-size: 0.85rem; width: auto; border-radius: 6px; }
  .actions-wrap { display: flex; gap: 0.5rem; align-items: center; flex-wrap: nowrap; }
  .actions-wrap form { margin: 0; display: flex; align-items: center; }
}

/* --- Live Tracking --- */
.tracking-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.tracking-stat {
  border-radius: 10px;
  padding: 0.75rem 1rem;
  text-align: center;
  border: 1px solid var(--color-border);
  background: var(--clr-darkest);
}
.tracking-stat__value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.tracking-stat__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.tracking-stat--online .tracking-stat__value   { color: var(--clr-success); }
.tracking-stat--on-route .tracking-stat__value { color: var(--clr-info); }
.tracking-stat--off-route .tracking-stat__value { color: var(--clr-error); }
.tracking-stat--offline .tracking-stat__value  { color: var(--clr-muted); }

@media (max-width: 600px) {
  .tracking-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Fullscreen wrapper */
.tracking-fullscreen { display: flex; flex-direction: column; }
.tracking-fullscreen--active,
.tracking-fullscreen:fullscreen,
.tracking-fullscreen:-webkit-full-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--color-bg);
  overflow-y: auto;
  padding: 1rem 1.25rem;
  box-sizing: border-box;
}
.tracking-fullscreen:fullscreen .tracking-map,
.tracking-fullscreen:-webkit-full-screen .tracking-map,
.tracking-fullscreen--active .tracking-map { height: calc(100vh - 220px); }

.tracking-toolbar__spacer { flex: 1 1 auto; }

.tracking-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
/* sidebar left, map right */
.tracking-layout__sidebar {
  width: 480px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tracking-layout__map { flex: 1 1 0; min-width: 0; }

@media (max-width: 900px) {
  .tracking-layout { flex-direction: column; }
  .tracking-layout__sidebar { width: 100%; }
}

.tracking-map {
  width: 100%;
  height: 480px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
  background: var(--clr-darkest);
}

.tracking-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.tracking-route-info { color: var(--color-text-muted); font-size: 0.9rem; }
.tracking-route-info strong { color: var(--color-text); }
.tracking-route-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tracking-editor-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tracking-editor-btns .form-hint { margin: 0; }

.tracking-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.tracking-legend__item { color: var(--color-text-muted); }
.tracking-legend__item--on { color: var(--clr-success); }
.tracking-legend__item--off { color: var(--clr-error); }
.tracking-legend__item--stale { color: var(--clr-muted); }
.tracking-legend__item--route { color: var(--clr-info); }

.tracking-section-title { margin: 1.25rem 0 0.5rem; }

/* Riders panel */
.tracking-riders-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.tracking-riders-search {
  flex: 1 1 120px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--clr-dark);
  color: var(--color-text);
  font-size: 0.85rem;
}
.tracking-riders-sort {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--clr-dark);
  color: var(--color-text);
  font-size: 0.85rem;
}
.tracking-riders-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 450px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.tracking-fullscreen:fullscreen .tracking-riders-wrap,
.tracking-fullscreen:-webkit-full-screen .tracking-riders-wrap,
.tracking-fullscreen--active .tracking-riders-wrap { max-height: calc(100vh - 280px); }

.tracking-riders-table { min-width: 100%; }
.tracking-riders-table th,
.tracking-riders-table td { white-space: nowrap; padding: 0.45rem 0.6rem; font-size: 0.83rem; }
.tracking-riders-table td:nth-child(1),
.tracking-riders-table th:nth-child(1) { white-space: normal; min-width: 100px; }
.tracking-riders-table td:nth-child(2),
.tracking-riders-table th:nth-child(2) { white-space: normal; min-width: 80px; }

/* Participant GPS tracking card */
.tracking-status-card {
  background: var(--clr-dark);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.tracking-status-indicator {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.tracking-status-indicator::before { content: '⚫ '; }
.tracking-status-indicator--active { color: var(--clr-success); }
.tracking-status-indicator--active::before { content: '🟢 '; }

.tracking-status-dl { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.tracking-status-dl dt { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.15rem; }
.tracking-status-dl dd { font-size: 0.95rem; color: var(--color-text); margin: 0; }

.tracking-gps-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* --- Rider profile dl --- */
.profile-dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0; }
.profile-dl dt { font-size: 0.8rem; color: var(--color-text-muted); font-weight: 600; align-self: center; white-space: nowrap; }
.profile-dl dd { margin: 0; align-self: center; }

/* --- Participant navigation map --- */
.nav-tracking-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.nav-tracking-status { flex: 1 1 200px; }

/* Map wrapper */
.nav-map-wrap {
  position: relative;
  z-index: 1;
  margin-top: 0.5rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.nav-map {
  width: 100%;
  height: 65vh;
  min-height: 380px;
  background: var(--clr-darkest);
}

/* HUD overlay — top left */
.nav-hud {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 1000;
  display: flex;
  gap: 0.4rem;
  pointer-events: none;
}
.nav-hud__item {
  background: rgba(0,0,0,0.65);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.nav-hud__value {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.nav-hud__label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Compass — top right */
.nav-compass {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 1000;
  width: 44px;
  height: 44px;
  pointer-events: none;
}
.nav-compass__rose { width: 100%; height: 100%; }

/* Re-center button */
.nav-recenter-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  background: rgba(0,0,0,0.7) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.2) !important;
}

/* Position marker — arrow */
.nav-pos-icon { background: none; border: none; }
.nav-pos-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #4CAD72;
  border: 3px solid #fff;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
  margin: 7px;
}
.nav-pos-arrow {
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 28px solid #4CAD72;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.6));
  margin: 2px;
  transform-origin: 10px 20px;
}

/* Turn-by-turn instruction banner */
.nav-instruction {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: rgba(15, 15, 20, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  pointer-events: none;
  transition: background 0.3s;
}
.nav-instruction.nav-instruction--arrive { background: rgba(30, 100, 50, 0.95); }
.nav-instruction__arrow { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
.nav-instruction__arrow svg { display: block; }
.nav-instruction__body { flex: 1; min-width: 0; }
.nav-instruction__action { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.nav-instruction__dist { font-size: 0.82rem; opacity: 0.75; margin-top: 0.1rem; }
.nav-voice-btn {
  pointer-events: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer; color: #fff;
  transition: background 0.2s;
}
.nav-voice-btn:hover { background: rgba(255,255,255,0.22); }
.nav-voice-btn.is-muted { opacity: 0.45; }

/* -------------------------------------------------------------------------
   Emergency Call
   ------------------------------------------------------------------------- */
.sidebar__link--emergency { color: var(--color-error) !important; }
.sidebar__link--emergency:hover,
.sidebar__link--emergency.is-active { background: var(--color-error-bg) !important; color: var(--color-error) !important; }

.emergency-warning-banner {
  background: var(--color-error-bg);
  border: 2px solid var(--color-error);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--color-error);
}
.emergency-warning-banner__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.35rem; }

.emergency-description {
  width: 100%;
  min-height: 130px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.emergency-description:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.btn--emergency {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.9rem 2rem;
  background: var(--color-error);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}
.btn--emergency:hover { background: #b34444; }
.btn--emergency:disabled { opacity: 0.65; cursor: not-allowed; }

.emergency-active-card { border: 2px solid var(--color-error); }
.emergency-active-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-error);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

/* Admin emergencies layout */
.emergency-layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.emergency-layout__table { flex: 3 1 0; min-width: 0; }
.emergency-layout__map { flex: 2 1 320px; min-width: 0; position: sticky; top: 1rem; }
.emergency-map { width: 100%; height: 420px; border-radius: var(--radius); background: var(--clr-darkest); }
.emergency-description-cell { max-width: 260px; white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; }

@media (max-width: 900px) {
  .emergency-layout { flex-direction: column; }
  .emergency-layout__map { position: static; width: 100%; }
  .emergency-map { height: 260px; }
}

/* Emergency stats row — always 3 columns */
.emergency-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card--cancelled .stat-card__value { color: var(--color-text-muted); }

/* Emergency fullscreen */
#emergenciesPage:-webkit-full-screen { background: var(--color-bg); overflow-y: auto; padding: 1.5rem; }
#emergenciesPage:fullscreen { background: var(--color-bg); overflow-y: auto; padding: 1.5rem; }
