/* ============ Tokens ============ */
:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --ink: #2b2823;
  --ink-soft: #5c574c;
  --leather: #6b4226;
  --leather-dark: #4f2f1b;
  --hunter: #2f3e2e;
  --gold: #c08a35;
  --gold-soft: #ecd9b3;
  --rust: #a3402e;
  --line: #e3dcc9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 40, 35, 0.06), 0 6px 20px rgba(43, 40, 35, 0.05);
  --font-display: 'Fraunces', serif;
  --font-body: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--leather-dark);
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

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

p { margin: 0 0 1em; color: var(--ink-soft); }

/* ============ App shell ============ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--hunter);
  color: #ece7da;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--gold-soft);
}
.brand-mark { flex-shrink: 0; }
.brand-mark {
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 600;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  color: #d8d3c2;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.07); text-decoration: none; }
.nav-link.is-active { background: rgba(255,255,255,0.12); color: #fff; }

.nav-section { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 14px; margin-top: 12px; }
.nav-section-label {
  display: block;
  padding: 0 12px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-soft);
}

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 14px; margin-top: 14px; }
.user-chip { display: flex; flex-direction: column; margin-bottom: 8px; }
.user-name { font-size: 0.9rem; color: #fff; font-weight: 600; }
.user-role { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold-soft); }

.link-button {
  background: none; border: none; color: #d8d3c2; font-size: 0.85rem; cursor: pointer; padding: 0;
  font-family: var(--font-body);
}
.link-button:hover { color: #fff; text-decoration: underline; }
.sidebar-link {
  display: block;
  color: #d8d3c2;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.sidebar-link:hover { color: #fff; text-decoration: underline; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.page-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; }

/* ============ Auth pages ============ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, var(--gold-soft) 0%, transparent 55%);
}
.auth-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.auth-card .brand {
  color: var(--leather);
  justify-content: center;
  margin-bottom: 18px;
}
.auth-card .brand-mark { width: 56px; height: 56px; border-radius: 14px; }
.auth-card h1 { text-align: center; font-size: 1.5rem; }
.auth-sub { text-align: center; margin-bottom: 22px; font-size: 0.9rem; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.88rem; }
.version-footer { text-align: center; margin-top: 14px; font-size: 0.72rem; color: var(--ink-soft); }

/* ============ Cards / panels ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat {
  display: flex; flex-direction: column; gap: 2px;
}
.stat .num { font-family: var(--font-display); font-size: 2rem; color: var(--leather); }
.stat .label { font-size: 0.82rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .sub { font-size: 0.74rem; color: var(--ink-soft); }

/* ============ Forms ============ */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.hint { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plain-list li { font-size: 0.9rem; }

/* Recurring-booking availability preview (green/red weekly chips) shown in
   the member booking modal before they commit to a multi-week series. */
.recurring-preview-summary { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 8px; }
.recurring-preview-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.recur-chip { padding: 4px 9px; border-radius: 20px; font-size: 0.76rem; border: 1px solid transparent; white-space: nowrap; }
.recur-chip-ok { background: #dde6da; color: var(--hunter); border-color: #c3d2bd; }
.recur-chip-no { background: #fbe7e2; color: #8c3322; border-color: #f0c6b8; }

@media (max-width: 600px) {
  /* Side-by-side form fields (date ranges, name+role pairs, etc.) get
     cramped down to unreadably narrow on a phone otherwise — stack them
     full-width instead. Applies everywhere .field-row is used, not just
     one page, since the same squeeze happens anywhere it appears. */
  .field-row { flex-wrap: wrap; }
  .field-row > .field { flex: 1 1 100%; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--leather);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 7px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn:hover { background: var(--leather-dark); }
.btn.btn-secondary { background: transparent; color: var(--leather); border: 1px solid var(--line); }
.btn.btn-secondary:hover { background: var(--gold-soft); }
.btn.btn-danger { background: var(--rust); }
.btn.btn-danger:hover { background: #832f21; }
.btn.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn.btn-icon { padding: 4px 9px; font-size: 0.95rem; line-height: 1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.alert-error { background: #fbe7e2; color: #8c3322; border: 1px solid #f0c6b8; }
.alert-success { background: #e9f0e3; color: var(--hunter); border: 1px solid #cfe0c2; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-booked { background: #dde6da; color: var(--hunter); }
.badge-completed { background: #e9dccb; color: var(--leather-dark); }
.badge-cancelled { background: #ece9e2; color: #847e6f; }
.badge-no_show { background: #f4dad4; color: var(--rust); }
.badge-pending { background: var(--gold-soft); color: var(--leather-dark); }
.badge-incident { background: var(--rust); color: #fff; }
/* Distinguishes automatic household horse access (My horses) from a
   deliberate, revocable permission grant — same pill shape, different color
   so it reads as "this one's just how it works" rather than "this one was
   specifically given and could be taken back." */
.badge-household { background: #d9e8f2; color: #2b5f7a; }
.badge-lesson-horse { background: #e6dcee; color: #5c3d70; }
.badge-severity-low { background: #dde6da; color: var(--hunter); }
.badge-severity-medium { background: var(--gold-soft); color: var(--leather-dark); }
.badge-severity-high { background: var(--rust); color: #fff; }

/* ============ Toast notifications (member confirm/decline alerts) ============ */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(43, 40, 35, 0.25);
  font-size: 0.9rem;
  line-height: 1.4;
  color: #fff;
  animation: toast-in 0.25s ease-out;
}
.toast-success { background: var(--hunter); }
.toast-error { background: var(--rust); }
.toast-message { flex: 1; }
.toast-close {
  background: none; border: none; color: inherit; font-size: 1.2rem; cursor: pointer;
  line-height: 1; opacity: 0.75; padding: 0; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (max-width: 760px) {
  .toast-container { left: 16px; right: 16px; max-width: none; bottom: 12px; }
}

/* ============ Conditions widget (large desktop cards + compact mobile strip) ============ */
.conditions-compact { display: none; }
@media (max-width: 760px) {
  .conditions-full { display: none; }
  .conditions-compact { display: block; }
}
.cc-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  margin-bottom: 18px;
}
.cc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.cc-head strong { color: var(--ink); font-size: 0.85rem; }
.cc-ride-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 12px;
  color: #fff;
}
.cc-ride-icon { font-size: 1rem; font-weight: 700; line-height: 1; }
.cc-ride-text { font-weight: 700; font-size: 0.95rem; flex: 1; }
.cc-ride-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.cc-ride-stat { font-size: 0.72rem; opacity: 0.92; white-space: nowrap; }
.cc-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cc-chip {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  white-space: nowrap;
}
.cc-chip.cc-tag { color: #fff; font-weight: 600; }
.cc-tomorrow-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  margin: 8px 0 4px;
}

/* ============ Per-lesson THI/AQI forecast badges ============ */
.lr-weather { display: inline-flex; gap: 6px; margin-top: 4px; }
.lr-weather-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

/* ============ List rows (mobile-friendly alternative to action tables) ============ */
.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .lr-main { flex: 1 1 220px; min-width: 0; }
.list-row .lr-when { font-weight: 600; }
.list-row .lr-meta { color: var(--ink-soft); font-size: 0.85rem; margin-top: 2px; }
.list-row .lr-note { color: var(--ink); font-size: 0.85rem; font-style: italic; margin-top: 3px; }
.list-row .lr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.list-row .lr-instructor-notes { flex: 1 1 100%; margin-top: 8px; }
.list-row .lr-instructor-notes textarea { width: 100%; font-size: 0.85rem; resize: vertical; }
.incident-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 0.82rem; color: var(--rust); cursor: pointer; margin-top: 4px; }
.incident-toggle input { cursor: pointer; }

/* ============ Horse profile photo (or the generic placeholder sketch) ============ */
.horse-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  vertical-align: middle;
  margin-right: 8px;
  background: #eef1f3;
}
.horse-thumb-small { width: 32px; height: 32px; margin-right: 6px; }
.horse-thumb-large { width: 88px; height: 88px; }
.horse-thumb-clickable { cursor: zoom-in; }

/* ============ Hazard report photo (rectangular, unlike the round horse thumb) ============ */
.hazard-thumb {
  width: 160px;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef1f3;
  flex: 0 0 auto;
}
.hazard-thumb-clickable { cursor: zoom-in; }
/* Same treatment as .horse-row-archived — greyed out, sunk to the bottom
   (see the ORDER BY in routes/hazardReports.js) rather than removed, so
   there's still a record of what's already been dealt with. */
.hazard-report-resolved { opacity: 0.55; }

/* ============ Horse profile photo lightbox (click a thumb to enlarge) ============ */
.lightbox-backdrop {
  position: fixed; inset: 0; background: rgba(43,40,35,0.75);
  display: none; align-items: center; justify-content: center; z-index: 60;
  padding: 24px;
}
.lightbox-backdrop.is-open { display: flex; }
.lightbox-backdrop img {
  max-width: 90vw; max-height: 90vh; border-radius: 8px;
  box-shadow: var(--shadow); cursor: zoom-out;
}

/* ============ Horse diary: timeline vs. per-type grid toggle ============ */
.diary-view-toggle { display: flex; gap: 8px; margin-bottom: 14px; }

/* Grid view: one box per entry type (General, Injury, Veterinary, ...),
   each box its own newest-first mini-timeline — see horse_diary_timeline.ejs. */
.diary-timeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}
.diary-type-column {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 14px 14px;
}
.diary-type-column h3 {
  margin: 12px 0 4px;
  font-size: 0.95rem;
}
.diary-type-column .list-row { border-bottom: 1px solid var(--line); }
.diary-type-column .list-row:last-child { border-bottom: none; }

/* ============ Horse vitals (weight / temperature / pulse / respiratory rate) ============ */
.vitals-icon-row { display: flex; gap: 10px; flex-wrap: wrap; }
.vital-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  min-width: 92px;
}
.vital-icon-btn .vi-icon { font-size: 1.4rem; line-height: 1; }
.vital-icon-btn .vi-label { font-size: 0.74rem; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.vital-icon-btn .vi-latest { font-size: 0.72rem; color: var(--leather); font-weight: 700; }
.vital-icon-btn:hover { background: var(--gold-soft); }
.vital-icon-btn.is-active { background: var(--leather); border-color: var(--leather); }
.vital-icon-btn.is-active .vi-label, .vital-icon-btn.is-active .vi-latest { color: #fff; }

.vital-panel { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.vital-add-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.vital-add-form .field { margin-bottom: 0; }
.vital-add-form input[type='number'] { width: 130px; }

.vital-panel-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px; }

.vital-chart-wrap { position: relative; margin-bottom: 18px; }
.vital-chart { width: 100%; height: auto; display: block; }
.vital-chart-line { fill: none; stroke: var(--leather); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.vital-chart-dot { fill: var(--leather); stroke: var(--surface); stroke-width: 2; }
.vital-chart-grid { stroke: var(--line); stroke-width: 1; }
.vital-chart-axis-label { fill: var(--ink-soft); font-size: 9px; font-family: var(--font-body); }
.vital-chart-crosshair { stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; pointer-events: none; }
.vital-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -115%);
  transition: opacity 0.1s;
  z-index: 5;
}
.vital-tooltip strong { font-weight: 700; }

/* ============ Horse feed composition ============ */
.feed-current-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.feed-current-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.feed-current-item-empty { opacity: 0.5; }
.feed-current-label { font-size: 0.74rem; color: var(--ink-soft); font-weight: 600; }
.feed-current-value { font-family: var(--font-display); font-size: 1.3rem; color: var(--leather); }
.feed-current-unit { font-size: 0.7rem; color: var(--ink-soft); }
.feed-current-supplements { font-size: 0.89rem; margin-bottom: 6px; }
.feed-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 14px;
  margin-bottom: 14px;
}
.feed-form-grid .field { margin-bottom: 0; }

/* ============ Tables ============ */
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Dropdowns dropped into a table row (e.g. the role picker on the People
   page) inherit the global input/select width:100% rule, which just means
   "fill whatever's left in this column" — and in a row crowded with other
   fixed-width fields and stacked action buttons, that can squeeze down to
   an uncomfortably narrow, compressed-looking box. Give them a sane minimum
   width instead so they render as a normal, comfortable dropdown regardless
   of how tight the rest of the row is. */
table select { width: auto; min-width: 160px; }

@media (max-width: 600px) {
  /* Not enough room on a phone for a 160px-minimum select next to
     everything else in the row — let it shrink back down there. */
  table select { min-width: 0; width: 100%; }
}

/* The People page's "Everyone" table packs more into each row than any
   other table in the app — a role dropdown, inline QuickBooks/email forms,
   several stacked action buttons — which reads as cramped at the normal
   table density on a laptop-width screen. Tighten just this one table
   rather than the shared table/input styles used everywhere else. */
.people-table th, .people-table td { padding: 6px 8px; font-size: 0.84rem; }
.people-table select,
.people-table input[type='text'],
.people-table input[type='email'],
.people-table input[type='tel'] {
  padding: 5px 8px;
  font-size: 0.82rem;
}
.people-table select.role-select { min-width: 130px; }
.people-table .badge { font-size: 0.66rem; padding: 1px 7px; }
.people-table .btn-small { padding: 5px 10px; font-size: 0.78rem; }
.people-table .hint { font-size: 0.72rem; margin-top: 2px; }
.people-role-divider th {
  background: var(--bg);
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.empty-state { text-align: center; padding: 40px 10px; color: var(--ink-soft); }
.divider { border: none; border-top: 1px solid var(--line); margin: 22px 0; }

/* Archived/removed horses: greyed out, sorted below a divider — table rows,
   card lists, and the divider row itself all share this treatment. */
.archived-divider-row td { padding: 6px 8px 10px; }
.archived-divider-row .divider { margin: 0 0 8px; }
.horse-row-archived,
.horse-card-archived { opacity: 0.55; }
.horse-row-archived td { color: var(--ink-soft); }

/* ============ Calendar ============ */
#calendar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.fc { font-family: var(--font-body); }
.fc-toolbar-title { font-family: var(--font-display) !important; color: var(--leather-dark); }
.fc-button { background: var(--leather) !important; border: none !important; }
.fc-button:hover { background: var(--leather-dark) !important; }
.fc-button-active { background: var(--leather-dark) !important; }
/* Tint today's column/cell. background-color only (not opacity) so the
   events and slots rendered inside it stay fully legible — opacity would
   fade the actual bookable content too, making today look misleadingly
   "disabled" compared to other days. */
.fc-day-today { background-color: rgba(192, 138, 53, 0.14) !important; }

/* Past days are done — shade them out so they read as historical, not
   bookable, without touching today or future days at all. FullCalendar
   applies fc-day-past automatically based on the real current date. */
.fc-day-past { background-color: rgba(43, 40, 35, 0.05) !important; }
.fc-col-header-cell.fc-day-past .fc-col-header-cell-cushion { color: var(--ink-soft); opacity: 0.7; }
.fc-event { cursor: pointer; border: none !important; font-size: 0.78rem; }

.legend { display: flex; gap: 18px; margin: 10px 0 16px; font-size: 0.82rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.legend-dot { width: 10px; height: 10px; border-radius: 99px; display: inline-block; }

.instructor-pick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.instructor-pill {
  border: 1px solid var(--line); border-radius: 99px; padding: 7px 16px; background: #fff;
  font-size: 0.86rem; font-weight: 600; cursor: pointer; color: var(--ink);
}
.instructor-pill.is-selected { background: var(--leather); color: #fff; border-color: var(--leather); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(43,40,35,0.45);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 26px 28px; width: min(380px, 90vw);
  box-shadow: var(--shadow);
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 4px; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
}
.nav-toggle:hover { background: rgba(255,255,255,0.1); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }

/* ============ Running pens (Stable Manager drag-and-drop day grid) ============ */
.rp-layout { display: flex; gap: 16px; align-items: flex-start; }
.rp-unscheduled { flex: 0 0 220px; width: 220px; }
.rp-chip-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; margin-top: 10px; }
.rp-chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: grab;
  user-select: none;
}
.rp-chip:active { cursor: grabbing; }
.rp-chip-placed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  opacity: 0.6;
}
.rp-chip-count { font-size: 0.72rem; color: var(--ink-soft); }
.rp-grid-card { flex: 1; min-width: 0; overflow-x: auto; }
.rp-ruler { display: flex; }
.rp-pen-label-spacer { flex: 0 0 110px; width: 110px; }
.rp-ruler-hours { flex: 1; display: flex; min-width: 720px; }
.rp-hour-tick {
  flex: 1;
  text-align: center;
  font-size: 0.68rem;
  color: var(--ink-soft);
  border-left: 1px solid var(--line);
  padding-bottom: 4px;
}
.rp-pen-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.rp-pen-row.rp-pen-over { background: rgba(163, 64, 46, 0.06); }
.rp-pen-label {
  flex: 0 0 110px;
  width: 110px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.rp-pen-label::before {
  content: '';
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rp-pen-color, var(--leather));
}
.rp-pen-timeline {
  flex: 1;
  min-width: 720px;
  position: relative;
  min-height: 46px;
  background-image: repeating-linear-gradient(
    to right, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(100% / 24)
  );
}
/* Each pen row's height is set inline by JS to laneCount * 40px, so
   overlapping horses (pairs/threes in the same pen) stack in their own
   lane instead of rendering on top of each other. */
.rp-block {
  position: absolute;
  height: 34px;
  box-sizing: border-box;
  /* --rp-pen-color is set per row by running-pens.js (render()), cycling
     through a fixed palette by pen position — without it, every block in
     every pen looked identically brown, making it hard to tell at a glance
     which row a block belonged to. Falls back to the old solid leather
     brown if unset. */
  background: var(--rp-pen-color, var(--leather));
  color: #fff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px;
  font-size: 0.76rem;
  overflow: hidden;
  cursor: grab;
}
.rp-block:active { cursor: grabbing; }
.rp-block-empty {
  background: transparent;
  border: 1px dashed var(--ink-soft);
  color: var(--ink-soft);
}
/* A locked (past) block keeps its pen's color family but reads as a
   lighter shade of it — filter, not opacity, so it stays a solid, legible
   fill rather than looking faded/translucent against the page. */
.rp-block-locked { cursor: default; }
.rp-block-locked:not(.rp-block-empty) { filter: brightness(1.4) saturate(0.7); }
.rp-block-locked.rp-block-empty { opacity: 0.55; }
.rp-block-ghost {
  background: rgba(163, 64, 46, 0.18);
  border: 1px dashed var(--leather);
  pointer-events: none;
}
.rp-block-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-handle { flex: 0 0 6px; align-self: stretch; cursor: ew-resize; }
.rp-remove {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #fff;
  opacity: 0.85;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.9rem;
  line-height: 1;
}
.rp-remove:hover { opacity: 1; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 14px 18px; }
  .brand { margin-bottom: 0; }
  .nav-toggle { display: inline-flex; }
  .nav, .sidebar-footer {
    display: none;
    flex-direction: column;
    align-items: flex-start;
  }
  .sidebar.is-open .nav, .sidebar.is-open .sidebar-footer { display: flex; }
  .nav { margin-top: 14px; gap: 2px; }
  .sidebar-footer {
    margin-top: 14px;
    margin-left: 0;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 14px;
  }
  .main { padding: 22px; }
}
