:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --bg-top: #fcfcfb;
  --bg-bottom: #f8f8f7;
  --panel: rgba(255, 255, 255, .89);
  --panel-solid: #ffffff;
  --panel-soft: rgba(251, 252, 254, .94);
  --ink: #161b25;
  --muted: #596575;
  --line: #dbe3ee;
  --line-strong: #c8d4e3;
  --primary: #5c86f6;
  --primary-dark: #3e66d8;
  --primary-rgb: 92, 134, 246;
  --primary-soft: #edf3ff;
  --primary-soft-strong: #dfe9ff;
  --primary-line: #cdddff;
  --glass: rgba(255, 255, 255, .78);
  --glass-strong: rgba(255, 255, 255, .92);
  --warn: #9a5b00;
  --danger: #b93632;
  --ok: #18734a;
  --shadow: 0 18px 48px rgba(24, 34, 56, .08);
  --shadow-soft: 0 8px 26px rgba(24, 34, 56, .05);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="graphite"] {
  --primary: #667a99;
  --primary-dark: #4f627d;
  --primary-rgb: 102, 122, 153;
  --primary-soft: #eef2f8;
  --primary-soft-strong: #e1e7f0;
  --primary-line: #cfd8e6;
}

body[data-theme="sage"] {
  --primary: #5f9087;
  --primary-dark: #456f69;
  --primary-rgb: 95, 144, 135;
  --primary-soft: #edf7f4;
  --primary-soft-strong: #deefe9;
  --primary-line: #c8e1da;
}

body[data-theme="rose"] {
  --primary: #ca7b8a;
  --primary-dark: #ab5e6c;
  --primary-rgb: 202, 123, 138;
  --primary-soft: #fff1f4;
  --primary-soft-strong: #ffe2e8;
  --primary-line: #f2cad3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
/* Visually hide content while keeping it available to assistive technology. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 45%, var(--bg-bottom) 100%);
  color: var(--ink);
  font-size: 16px;
  padding-bottom: 310px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar div { display: grid; gap: 2px; }
.topbar span { color: var(--muted); font-size: .85rem; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 10px 12px;
  background: rgba(250, 251, 253, .78);
  border-bottom: 1px solid rgba(215, 221, 230, .72);
  backdrop-filter: blur(26px) saturate(1.15);
  -webkit-backdrop-filter: blur(26px) saturate(1.15);
}
.tabs-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  min-width: 0;
  padding: 3px;
  border: 1px solid rgba(213, 221, 232, .82);
  border-radius: 14px;
  background: rgba(255, 255, 255, .68);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82);
}
.tabs-primary {
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: 0;
}
.tabs-secondary {
  flex: 0 0 auto;
  justify-content: flex-end;
  margin-left: auto;
}
.tabs a {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 0;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-decoration: none;
  font-weight: 700;
  font-size: .84rem;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow: none;
}
.tabs-primary a {
  padding-inline: 14px;
}
.tabs a .nav-icon {
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  color: #111;
}
.tabs a .nav-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}
.tabs a.is-active .nav-icon {
  color: #111;
}
.tabs a.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .82),
    0 10px 22px rgba(var(--primary-rgb), .14);
}
.tabs .icon-tab { width: 42px; min-width: 42px; padding: 0; }
.tabs-secondary a { min-width: 40px; color: #111; }
.tabs-secondary a.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), .06);
}
.tabs-secondary a:hover {
  background: rgba(245, 248, 251, .96);
}
.tabs-secondary a.is-active .nav-icon {
  color: #111;
}
.tabs .logout-tab {
  color: var(--danger);
}
.tabs-secondary .logout-tab { margin-left: 4px; }
.global-save-status {
  flex: 0 0 auto;
  width: 22px;
  min-height: 22px;
  align-self: center;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: transparent;
  font-size: .78rem;
  font-weight: 900;
}
.global-save-status:not(.ok):not(.bad):not(.loading) {
  width: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.global-save-status.ok {
  background: #effaf3;
  color: var(--ok);
}
.global-save-status.bad {
  background: #fff0f0;
  color: var(--danger);
}

main {
  width: min(1440px, calc(100% - 24px));
  margin: 0 auto;
  padding: 10px 12px 56px;
}
.section {
  padding: 24px 0;
}
h1 { margin: 0 0 18px; font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: 0; line-height: 1.02; }
h2 { margin: 0; font-size: 1.08rem; letter-spacing: 0; line-height: 1.08; }
p { margin: 0; }
.muted { color: var(--muted); }

.planner-title {
  display: grid;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}

.planner-head {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.planner-head > * {
  min-width: 0;
}
.date-form {
  min-width: 0;
}
.date-form label, label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
  font-size: .9rem;
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  padding: 10px 11px;
  font: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.72),
    0 1px 2px rgba(24, 34, 56, .03);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-line);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .12);
}
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(var(--primary-rgb), .28);
  outline-offset: 2px;
}
textarea { min-height: 88px; resize: vertical; }

.button, .icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  padding: 10px 14px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.icon-button { font-size: 2rem; line-height: 1; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 10px 24px rgba(var(--primary-rgb), .18); }
.button.primary:hover { background: var(--primary-dark); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.compact {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: .82rem;
}

.empty-state, .install-card, .group-block, .whatsapp-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.08);
  -webkit-backdrop-filter: blur(20px) saturate(1.08);
}
.empty-state {
  display: grid;
  gap: 12px;
  padding: 18px;
}
.group-block {
  margin: 10px 0;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 14px 32px rgba(24, 34, 56, .06);
}
.group-block.is-pool-context {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), .14), 0 14px 32px rgba(var(--primary-rgb), .10);
}
.group-block.is-pool-context > header {
  background: linear-gradient(90deg, rgba(var(--primary-rgb), .12) 0 8px, var(--primary-soft) 8px 100%);
}
.group-block.is-under-min {
  border-color: #e5c27a;
}
.group-block.is-under-min > header {
  background: linear-gradient(90deg, rgba(229, 194, 122, .18) 0 8px, #fffaf0 8px 100%);
}
.group-block.is-under-min.is-pool-context > header {
  background: linear-gradient(90deg, rgba(var(--primary-rgb), .12) 0 8px, #fffaf0 8px 100%);
}
.group-block.is-overbooked {
  border-color: #e18b87;
}
.group-block.is-overbooked > header {
  background: linear-gradient(90deg, rgba(225, 139, 135, .18) 0 8px, #fff8f8 8px 100%);
}
.group-block.is-overbooked.is-pool-context > header {
  background: linear-gradient(90deg, rgba(var(--primary-rgb), .12) 0 8px, #fff8f8 8px 100%);
}
.group-block > header {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 30px 30px;
  align-items: center;
  gap: 6px;
  padding: 11px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.78) 0%, rgba(243,247,252,.9) 100%);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.group-block > header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line-strong);
}
.group-block.is-pool-context > header::before { background: rgba(var(--primary-rgb), .82); }
.group-block.is-under-min > header::before { background: #c9a245; }
.group-block.is-overbooked > header::before { background: #d5736b; }
.group-block header p, .group-block header span { color: var(--muted); font-size: .9rem; }
.group-block header .group-trainers {
  margin-top: 2px;
  color: var(--primary-dark);
  font-size: .76rem;
  font-weight: 800;
}
.group-add,
.group-toggle,
.group-close {
  width: 30px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}
.group-close {
  color: var(--danger);
}
.group-body { display: block; }
.group-block.is-collapsed .group-body { display: none; }
.group-body {
  background: linear-gradient(180deg, #fff 0%, #f9fbfe 100%);
}

.horse-pool {
  position: fixed;
  left: max(8px, calc((100vw - 1120px) / 2 + 16px));
  right: max(8px, calc((100vw - 1120px) / 2 + 16px));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  gap: 7px;
  padding: 10px;
  margin: 0;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 18px 18px 16px 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.08);
  -webkit-backdrop-filter: blur(24px) saturate(1.08);
}
.horse-pool header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}
.horse-pool-tools {
  display: inline-grid;
  grid-template-columns: auto 30px;
  align-items: center;
  gap: 6px;
}
.horse-pool.is-collapsed .horse-tile-strip {
  display: none;
}
.horse-pool.is-collapsed {
  gap: 5px;
}
.rider-pool {
  display: grid;
  gap: 4px;
  padding: 0 0 5px;
  border-bottom: 1px solid var(--line);
}
.rider-pool header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}
.rider-pool header h2 {
  font-size: .82rem;
}
.rider-pool header span {
  color: var(--muted);
  font-size: .72rem;
}
.rider-pool-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 3px;
}
.rider-pool-tile {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.88);
  color: var(--ink);
  padding: 4px 5px;
  font-size: .7rem;
  font-weight: 800;
  text-align: left;
  cursor: grab;
  line-height: 1.05;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.rider-pool-tile.is-dragging {
  opacity: .55;
}
.rider-pool-tile.is-selected-rider,
.rider-card.is-selected-rider {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18);
}
.rider-pool.is-pool-drop-target {
  outline: 3px solid rgba(var(--primary-rgb), .22);
  outline-offset: 2px;
  background: var(--primary-soft);
}
.horse-pool header p,
.horse-pool header span {
  color: var(--muted);
  font-size: .72rem;
}
.horse-pool header h2 {
  font-size: .82rem;
}
.horse-pool header p {
  display: none;
}
.horse-tile-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 5px;
  max-height: none;
  overflow: visible;
  padding: 0 1px 3px;
}
.horse-tile,
.assigned-horse {
  border: 1px solid var(--primary-line);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(var(--primary-rgb), .10);
  cursor: grab;
  text-align: left;
  min-width: 0;
}
.horse-tile {
  position: relative;
  min-height: 34px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 6px 20px 6px 7px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.horse-tile:active,
.assigned-horse:active {
  cursor: grabbing;
}
.horse-tile strong,
.assigned-horse strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
  line-height: 1.05;
}
.horse-day-count {
  position: absolute;
  right: 4px;
  top: 4px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), .14);
  color: var(--primary);
  font-size: .62rem;
  font-weight: 900;
}
.horse-choice-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  padding: 12px;
  background: rgba(42, 35, 25, .18);
}
.horse-choice-sheet[hidden] {
  display: none;
}
.horse-choice-panel {
  width: min(560px, 100%);
  max-height: min(68vh, 520px);
  margin: 0 auto calc(136px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 24px 54px rgba(24, 34, 56, .18);
  backdrop-filter: blur(28px) saturate(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(1.08);
}
.horse-choice-panel header {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 8px;
}
.horse-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 7px;
  overflow: auto;
}
.horse-choice-item {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--primary-line);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--ink);
  padding: 8px;
  font: inherit;
  font-weight: 850;
  text-align: left;
}
.horse-choice-item.is-warning {
  border-color: #e5c27a;
  background: #fff6dc;
}
.horse-choice-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.horse-choice-count {
  min-width: 24px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), .14);
  color: var(--primary);
  padding: 2px 5px;
  font-size: .7rem;
  text-align: center;
}
.assigned-horse strong::before {
  content: "♞";
  display: inline-block;
  width: 1.15em;
  margin-right: 5px;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  vertical-align: -0.08em;
}
.horse-tile span,
.assigned-horse span {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
}
.horse-tile.is-warning,
.assigned-horse.is-warning {
  border-color: #e5c27a;
  background: #fff6dc;
}
.horse-tile.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft-strong);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .2);
}
.horse-tile[hidden] {
  display: none;
}
.rider-grid {
  display: grid;
  gap: 5px;
  padding: 5px;
  background: var(--panel-soft);
}
.rider-grid-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 1fr) 30px;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 6px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.rider-grid-head span:last-child {
  visibility: hidden;
}
.rider-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 1fr) 30px;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-soft);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.rider-card.is-removed {
  opacity: .5;
}
.rider-card.is-cancelled {
  opacity: .62;
  background: #fbf7f4;
}
.rider-card.is-cancelled .rider-main strong {
  text-decoration: line-through;
  color: var(--muted);
}
.rider-card.is-cancelled .horse-drop-zone {
  border-style: solid;
  background: #f2eee8;
}
.rider-card.is-cancelled .drop-placeholder {
  color: #9a5b00;
}
.rider-card.is-drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .16), 0 10px 24px rgba(var(--primary-rgb), .12);
  transform: translateY(-1px);
}
.rider-card.is-dragging {
  opacity: .55;
}
.group-block.is-group-drop-target {
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), .14), 0 14px 28px rgba(var(--primary-rgb), .10);
}
.has-selected-rider .group-block {
  opacity: .82;
  transition: opacity .16s ease, box-shadow .16s ease, transform .16s ease;
}
.has-selected-rider .group-block.is-pool-context,
.has-selected-rider .group-block.is-group-drop-target,
.has-selected-rider .group-block:has(.js-rider-card.is-selected-rider) {
  opacity: 1;
  transform: translateY(-1px);
}
.has-selected-rider .rider-pool {
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), .14), 0 10px 24px rgba(var(--primary-rgb), .08);
}
.rider-main {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 11px;
  background: #fbfcfe;
  border: 1px solid #e8edf5;
}
.rider-main strong {
  font-size: .9rem;
  line-height: 1.1;
}
.rider-main small {
  color: var(--warn);
  font-weight: 700;
}
.cancelled-note {
  display: block;
  font-size: .68rem;
  line-height: 1.05;
}
.moved-note {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .68rem;
  line-height: 1.05;
}
.horse-drop-zone {
  position: relative;
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px dashed #bdb6aa;
  border-radius: 11px;
  background: #f8fafd;
}
.has-selected-horse .horse-drop-zone:not(.has-horse) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 2px rgba(var(--primary-rgb), .12);
}
.horse-drop-zone.has-horse {
  display: grid;
  grid-template-columns: 1fr 26px;
  gap: 4px;
  padding: 4px;
  border-style: solid;
  border-color: var(--primary-line);
  background: #f9fbff;
  min-width: 0;
}
.drop-placeholder {
  color: var(--muted);
  font-weight: 750;
  font-size: .72rem;
}
.assigned-horse {
  width: 100%;
  min-height: 26px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 5px 8px;
}
.clear-horse {
  width: 24px;
  min-height: 24px;
  align-self: center;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.clear-horse svg,
.icon-action svg,
.group-close svg,
.action-icon-svg svg {
  width: 17px;
  height: 17px;
  display: block;
  margin: auto;
}
.group-close svg { width: 15px; height: 15px; }
.action-icon-svg {
  display: inline-grid;
  place-items: center;
}
.select-label span { color: var(--muted); font-size: .85rem; }
.row-actions {
  display: grid;
  place-items: center;
}
.icon-action {
  width: 28px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.icon-action.danger {
  color: var(--danger);
}
.icon-action.restore {
  color: var(--ok);
}
.actions summary {
  min-height: 40px;
  display: grid;
  align-items: center;
  font-weight: 750;
  cursor: pointer;
}
.actions[open] {
  display: grid;
  gap: 12px;
}

.add-rider {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 6px;
  padding: 8px;
  background: #fbfaf7;
}
.group-add-form {
  border-bottom: 1px solid var(--line);
}
.warnings {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}
.warning-summary {
  border: 1px solid #e5c27a;
  border-radius: 8px;
  background: #fff7df;
  color: #6d4300;
  padding: 0;
}
.warning-summary summary {
  min-height: 38px;
  display: grid;
  align-items: center;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}
.warning-summary div {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}
.warnings p, .alert {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e5c27a;
  background: #fff7df;
  color: #6d4300;
}
.alert.error { border-color: #f0b7b5; background: #fff0f0; color: #8d201c; }
.alert.success { border-color: #a8d7bd; background: #effaf3; color: #145d3a; }
.save-state {
  position: fixed;
  top: calc(68px + env(safe-area-inset-top));
  right: 16px;
  z-index: 4;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 750;
  font-size: .85rem;
  max-width: min(380px, calc(100vw - 32px));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.save-state:empty {
  display: none;
}
.save-state.ok { color: var(--ok); }
.save-state.bad { color: var(--danger); font-weight: 900; }
.global-save-status.loading {
  background: #f4efe5;
  color: var(--muted);
}

.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 26;
  pointer-events: none;
}
.install-banner-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(95, 144, 135, .28);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(240, 248, 245, .98) 0%, rgba(255, 255, 255, .96) 42%, rgba(255, 255, 255, .95) 100%);
  box-shadow: none;
  backdrop-filter: blur(28px) saturate(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(1.08);
  pointer-events: auto;
  outline: 1px solid rgba(255, 255, 255, .72);
  outline-offset: -1px;
}
.install-banner-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(95, 144, 135, .12);
  color: var(--primary-dark);
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .01em;
}
.install-banner-main {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.install-banner-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(95, 144, 135, .16);
  box-shadow: none;
  object-fit: cover;
}
.install-banner-copy {
  display: grid;
  gap: 5px;
}
.install-banner-copy strong {
  font-size: 1rem;
  line-height: 1.15;
}
.install-banner-copy p {
  color: #33414f;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.35;
}
.install-banner-copy small {
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.4;
}
.install-banner-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.install-banner-actions .button {
  width: 100%;
}
.install-banner-secondary {
  background: rgba(248, 250, 251, .94);
}
.install-banner-ios-help {
  display: grid;
}
.install-banner-ios-steps {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 251, 252, .92);
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}
.install-share-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin: 0 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  font-weight: 750;
  vertical-align: middle;
}
.install-share-chip svg {
  width: 14px;
  height: 14px;
  display: block;
}
body.has-install-banner {
  padding-bottom: 440px;
}
body.has-install-banner .horse-pool {
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 138px);
}
body.has-install-banner .horse-choice-panel {
  margin-bottom: calc(156px + env(safe-area-inset-bottom));
}

.whatsapp-panel {
  display: grid;
  gap: 0;
  padding: 0;
  margin-top: 18px;
}
.whatsapp-panel summary {
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr 18px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.whatsapp-panel summary::-webkit-details-marker { display: none; }
.whatsapp-panel summary::after {
  content: "▾";
  text-align: center;
  color: var(--muted);
  transition: transform .16s ease;
}
.whatsapp-panel[open] summary::after { transform: rotate(180deg); }
.whatsapp-panel-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}
.calendar-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin: 0 0 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.calendar-panel header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
}
.calendar-panel header h2 {
  text-align: center;
}
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin: 8px 0 16px;
  padding: 0 2px;
}
.plan-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 750;
  cursor: pointer;
}
.plan-action .action-icon {
  width: 1em;
  min-width: 1em;
  text-align: center;
  color: currentColor;
}
.plan-action.danger {
  color: var(--danger);
}
.plan-action.danger:hover {
  background: #fff4f3;
}
.plan-action:disabled {
  opacity: .48;
  cursor: not-allowed;
}
.plan-action.is-locked {
  border-color: var(--primary-line);
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.locked-plan-note {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--primary-line);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: .9rem;
  font-weight: 750;
}
.calendar-grid {
  display: grid;
  grid-template-columns: 28px repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.calendar-weekdays span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-align: center;
}
.calendar-week-number {
  min-height: 46px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 850;
}
.calendar-week-number.is-current-week {
  color: var(--primary);
  background: #fff3bf;
  border-radius: 8px;
}
.calendar-day {
  position: relative;
  min-height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  text-decoration: none;
}
.calendar-day::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 3px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
}
.calendar-day strong {
  position: absolute;
  top: 7px;
  left: 8px;
  font-size: .95rem;
}
.calendar-day span {
  position: absolute;
  right: 4px;
  top: 5px;
  min-width: 20px;
  height: 17px;
  padding-inline: 4px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
}
.calendar-day.is-muted {
  opacity: .42;
}
.calendar-day.is-past {
  border-color: #d6d9dd;
  background: #f0f1f2;
  color: #8a8f96;
}
.calendar-day.is-past span {
  background: #aeb4ba;
}
.calendar-day.has-plan {
  border-color: #7ebaae;
  background: #f0faf6;
}
.calendar-day.has-plan.is-locked {
  border-color: #b8bdc3;
  background: #eceeef;
}
.calendar-day.is-current-week {
  border-color: #e0cf93;
  background: #fffdf6;
}
.calendar-day.is-current-week::before {
  background: #cfaa2f;
}
.calendar-day.is-current-week.has-plan {
  background: #eef8f4;
}
.calendar-day.is-selected {
  outline: 2px solid rgba(31, 118, 104, .22);
  background: #e7f5f0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.85);
}
.calendar-day.is-past.is-selected {
  outline-color: rgba(105, 112, 122, .28);
  background: #e8eaec;
}
.is-plan-locked .horse-pool,
.is-plan-locked .group-body {
  opacity: .62;
  pointer-events: none;
}
.is-plan-locked .group-block {
  border-color: #c9ced4;
  background: #f6f7f8;
}
.calendar-day.is-selected.has-plan {
  border-color: #89c7bc;
  background: linear-gradient(180deg, #eef4ff 0%, #edf8f4 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.88),
    0 0 0 2px rgba(92, 134, 246, .16);
}
.calendar-day.is-selected:not(.has-plan) {
  border-color: #9bb7ff;
  background: #eef4ff;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.88),
    0 0 0 2px rgba(92, 134, 246, .16);
}
.group-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.group-preview span {
  display: inline-flex;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
  font-size: .86rem;
}
#whatsappText {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

.masterdata-tools {
  display: grid;
  grid-template-columns: minmax(240px, 460px) minmax(190px, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0 0 14px;
}
.masterdata-search {
  position: relative;
  display: block;
}
.masterdata-search .search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.masterdata-search .search-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.masterdata-search input {
  padding-left: 40px;
  background: var(--panel-solid);
}
.masterdata-directory {
  min-width: 0;
}
.masterdata-directory > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-solid);
  color: var(--ink);
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
}
.masterdata-directory > summary span {
  color: var(--muted);
  font-size: .76rem;
}
.masterdata-directory[open] > summary {
  border-color: var(--primary-line);
  background: var(--primary-soft);
}
.masterdata-directory .jump-list {
  max-height: 230px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}
.jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
}
.jump-list a {
  flex: 0 1 150px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 750;
}
.jump-list a span {
  float: right;
  color: var(--muted);
  font-size: .76rem;
}
.jump-list.is-stacked {
  grid-template-columns: 1fr;
}
.jump-list.is-stacked a {
  max-width: none;
}
.help-grid,
.auth-link-list {
  display: grid;
  gap: 12px;
}
.help-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 12px;
}
.help-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.help-card h2 {
  font-size: 1rem;
}
.help-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.help-card p {
  line-height: 1.55;
}
.help-card .muted {
  font-size: .88rem;
}
.auth-link-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}
.auth-link-list .button {
  width: 100%;
}
.mail-card {
  display: grid;
  gap: 14px;
}
.mail-card .button {
  justify-self: start;
}
.edit-table tr[id] {
  scroll-margin-top: 56px;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-title-row h1 {
  margin: 0;
}
.section-title-row .icon-action {
  width: 40px;
  min-height: 40px;
  font-size: 1.2rem;
}
.new-entity-panel {
  margin: 10px 0 14px;
}
.entity-create-form {
  display: grid;
  gap: 14px;
}
.entity-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.entity-create-grid label {
  min-width: 0;
}
.entity-create-label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
}
.entity-create-wide {
  grid-column: 1 / -1;
}
.entity-create-wide .group-picker-panel {
  position: static;
  width: 100%;
  margin-top: 8px;
  box-shadow: none;
}
.entity-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.weekday-group-section {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: clip;
}
.weekday-group-section > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f2eee5;
  cursor: pointer;
  font-weight: 850;
}
.weekday-group-section > summary span {
  color: var(--muted);
  font-size: .8rem;
}
.weekday-group-section .table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.weekday-group-section > .muted {
  padding: 12px;
}

.data-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.05);
  -webkit-backdrop-filter: blur(20px) saturate(1.05);
}
fieldset {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
fieldset label, label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
}
input[type="checkbox"] { width: auto; min-height: auto; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--ink);
}
.toggle-row input {
  width: auto;
  min-height: auto;
}
.toggle-row span {
  color: var(--ink);
  font-weight: 750;
}
.settings-fieldset {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(250, 252, 251, .94);
}
.settings-fieldset legend {
  padding: 0 4px;
  color: var(--ink);
  font-weight: 800;
}
.profile-card .settings-fieldset {
  grid-column: 1 / -1;
}
.list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.list span { color: var(--muted); text-align: right; }

.table-wrap {
  overflow-x: auto;
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.04);
  -webkit-backdrop-filter: blur(18px) saturate(1.04);
}
.edit-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}
.edit-table form {
  display: contents;
}
.edit-table th,
.edit-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
.edit-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(248, 251, 255, .92);
  color: var(--muted);
  font-size: .82rem;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.edit-table input,
.edit-table select,
.edit-table textarea {
  min-width: 120px;
}
.edit-table .name-cell input {
  font-weight: 850;
}
.edit-table textarea {
  min-height: 44px;
}
.edit-table .button {
  white-space: nowrap;
}
.masterdata-table {
  min-width: 0;
  table-layout: fixed;
}
.masterdata-table td {
  vertical-align: middle;
  transition: background-color .14s ease;
}
.masterdata-table tbody tr:nth-child(even) td {
  background: rgba(247, 249, 252, .72);
}
.masterdata-table tbody tr:hover td {
  background: rgba(var(--primary-rgb), .055);
}
.masterdata-table input,
.masterdata-table select,
.masterdata-table textarea {
  width: 100%;
  min-width: 0;
}
.masterdata-table textarea {
  resize: vertical;
}
.masterdata-table .entity-name {
  display: block;
  padding: 8px 4px;
  font-size: .9rem;
  line-height: 1.2;
}
.rider-data-table,
.horse-data-table {
  min-width: 720px;
}
.rider-data-table th:nth-child(1),
.rider-data-table td:nth-child(1) { width: 18%; }
.rider-data-table th:nth-child(2),
.rider-data-table td:nth-child(2) { width: 18%; }
.rider-data-table th:nth-child(3),
.rider-data-table td:nth-child(3) { width: 90px; }
.rider-data-table th:nth-child(4),
.rider-data-table td:nth-child(4) { width: 28%; }
.rider-data-table th:last-child,
.rider-data-table td:last-child,
.horse-data-table th:last-child,
.horse-data-table td:last-child { width: 54px; }
.horse-data-table th:nth-child(1),
.horse-data-table td:nth-child(1) { width: 24%; }
.horse-data-table th:nth-child(2),
.horse-data-table td:nth-child(2) { width: 100px; }
.horse-data-table th:nth-child(3),
.horse-data-table td:nth-child(3) { width: 170px; }
.horse-data-table th:nth-child(4),
.horse-data-table td:nth-child(4) { width: 130px; }
.group-data-table {
  min-width: 1160px;
}
.group-data-table th:nth-child(1),
.group-data-table td:nth-child(1) { width: 155px; }
.group-data-table th:nth-child(2),
.group-data-table td:nth-child(2) { width: 82px; }
.group-data-table th:nth-child(3),
.group-data-table td:nth-child(3) { width: 120px; }
.group-data-table th:nth-child(4),
.group-data-table td:nth-child(4),
.group-data-table th:nth-child(5),
.group-data-table td:nth-child(5) { width: 100px; }
.group-data-table th:nth-child(6),
.group-data-table td:nth-child(6) { width: 190px; }
.group-data-table th:nth-child(7),
.group-data-table td:nth-child(7),
.group-data-table th:nth-child(8),
.group-data-table td:nth-child(8) { width: 105px; }
.group-data-table th:nth-child(9),
.group-data-table td:nth-child(9) { width: 125px; }
.group-data-table th:last-child,
.group-data-table td:last-child { width: 54px; }
.trainer-checkboxes {
  display: grid;
  gap: 5px;
}
.trainer-checkboxes label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: .78rem;
  font-weight: 700;
}
.trainer-checkboxes input {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
}
.multi-checks {
  min-width: 150px;
  display: grid;
  gap: 5px;
}
.multi-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: .78rem;
  font-weight: 750;
}
.multi-checks input {
  flex: 0 0 auto;
}
.multi-checks span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-picker {
  position: relative;
}
.group-picker[open] {
  z-index: 5;
}
.group-picker-summary {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  cursor: pointer;
  list-style: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.group-picker-summary::-webkit-details-marker {
  display: none;
}
.group-picker-summary strong {
  font-size: .84rem;
  line-height: 1.1;
}
.group-picker-summary small {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.2;
}
.group-picker-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: min(420px, 72vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 18px 38px rgba(24, 34, 56, .14);
}
.group-checklist {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-height: 260px;
  overflow: auto;
  padding: 2px;
}
.group-chip-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .98);
}
.group-chip-option input {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 2px 0 0;
}
.group-chip-option span {
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
}
.row-save-status {
  display: inline-grid;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: transparent;
}
.row-tools,
.edit-table td.row-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.edit-table tr.is-saving .row-save-status {
  background: #e5c27a;
}
.edit-table tr.is-saved .row-save-status {
  background: var(--ok);
}
.edit-table tr.is-error .row-save-status {
  background: var(--danger);
}
.edit-table tr.is-saving input,
.edit-table tr.is-saving select,
.edit-table tr.is-saving textarea {
  border-color: #e5c27a;
}
.edit-table tr.is-saved input,
.edit-table tr.is-saved select,
.edit-table tr.is-saved textarea {
  border-color: var(--primary-line);
}
.edit-table tr.is-error input,
.edit-table tr.is-error select,
.edit-table tr.is-error textarea {
  border-color: #f0b7b5;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: clamp(46px, 13vh, 118px) 18px 18px;
  -webkit-text-size-adjust: 100%;
}
.auth-body input,
.auth-body select,
.auth-body textarea {
  font-size: 16px;
}
.install-card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
}
.profile-card {
  width: min(980px, 100%);
}
.profile-card input:disabled {
  background: #f4f6f8;
  color: #4f5968;
  opacity: 1;
}
.backup-grid {
  display: grid;
  gap: 12px;
}
.backup-card {
  width: 100%;
}
.backup-table-wrap {
  overflow-x: auto;
}
.backup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.backup-table th,
.backup-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e6e9ee;
  vertical-align: top;
  text-align: left;
}
.backup-table th {
  white-space: nowrap;
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.backup-actions form {
  margin: 0;
}
.empty-note {
  margin: 0;
  color: var(--muted);
}
.backup-warning {
  padding: 10px;
  border: 1px solid #f0d7a4;
  border-radius: 8px;
  background: #fff8e8;
}
.form-grid {
  display: grid;
  gap: 12px;
}
.form-grid h2 { margin-top: 10px; }
.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checklist span {
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 750;
  font-size: .85rem;
}
.checklist .bad { background: #fff0f0; color: var(--danger); }

@media (min-width: 760px) {
  body { padding-bottom: 250px; }
  main { padding-inline: 20px; }
  .tabs a {
    padding: 7px 11px;
  }
  .rider-pool-strip {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }
  .horse-tile-strip {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  }
  .rider-card {
    grid-template-columns: minmax(180px, 1fr) minmax(190px, 1fr) 34px;
    align-items: stretch;
  }
  .data-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .data-form .button, .data-form fieldset, .data-form label:has(textarea) {
    grid-column: 1 / -1;
  }
  .profile-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .profile-card .toggle-row,
  .profile-card .button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) {
  .backup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .backup-card-list,
  .backup-card-import {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1280px) {
  main {
    width: min(1560px, calc(100% - 32px));
  }
  .tabs-primary a,
  .tabs-secondary a {
    font-size: .9rem;
  }
}

@media (max-width: 420px) {
  .tabs {
    gap: 4px;
    padding: 6px 5px;
  }
  .tabs a {
    min-height: 34px;
    padding: 5px 7px;
    font-size: .72rem;
  }
  .tabs-row {
    padding: 2px;
    border-radius: 11px;
  }
  .tabs .icon-tab {
    width: 32px;
    min-width: 32px;
  }
  .tabs a .nav-icon,
  .tabs a .nav-icon svg {
    width: .96rem;
    height: .96rem;
  }
  body {
    padding-bottom: calc(360px + env(safe-area-inset-bottom));
  }
  body.has-install-banner {
    padding-bottom: calc(470px + env(safe-area-inset-bottom));
  }
  main {
    padding-inline: 8px;
  }
  .planner-head {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 4px;
  }
  .icon-button {
    width: 36px;
    min-height: 40px;
    padding: 4px;
  }
  .planner-head input[type="date"] {
    min-width: 0;
    min-height: 40px;
    padding-inline: 7px;
    font-size: .92rem;
  }
  .calendar-panel {
    padding: 8px;
  }
  .calendar-grid {
    grid-template-columns: 24px repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .calendar-day {
    min-height: 38px;
  }
  .calendar-day::before {
    left: 5px;
    right: 5px;
    bottom: 2px;
  }
  .calendar-day span {
    right: 4px;
    top: 4px;
    min-width: 16px;
    height: 16px;
    font-size: .64rem;
  }
  .calendar-week-number {
    min-height: 38px;
    font-size: .62rem;
  }
  .group-block {
    margin: 7px 0;
  }
  .group-block > header h2 {
    font-size: .98rem;
  }
  .group-block header p,
  .group-block header span {
    font-size: .78rem;
  }
  .horse-pool {
    left: 6px;
    right: 6px;
    bottom: max(18px, env(safe-area-inset-bottom));
    padding: 7px;
  }
  body.has-install-banner .horse-pool {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 156px);
  }
  .rider-pool-strip {
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  }
  .horse-tile-strip {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  }
  .rider-pool-tile,
  .horse-tile strong,
  .assigned-horse strong {
    font-size: .7rem;
  }
  .horse-choice-panel {
    margin-bottom: calc(172px + env(safe-area-inset-bottom));
  }
  body.has-install-banner .horse-choice-panel {
    margin-bottom: calc(302px + env(safe-area-inset-bottom));
  }
  .horse-choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .group-picker-panel {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }
}

@media (max-width: 720px) {
  .tabs {
    gap: 4px;
  }
  .tabs-primary,
  .tabs-secondary {
    gap: 2px;
  }
  .tabs a {
    font-size: .76rem;
    padding-inline: 8px;
  }
  .tabs .icon-tab {
    width: 34px;
    min-width: 34px;
  }
  .masterdata-tools {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .masterdata-directory .jump-list {
    max-height: 210px;
  }
  .save-state {
    top: calc(98px + env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    max-width: none;
  }
  .install-banner {
    left: 8px;
    right: 8px;
  }
  .install-banner-card {
    gap: 12px;
    padding: 12px;
    border-radius: 22px;
  }
  .install-banner-badge {
    min-height: 22px;
    padding-inline: 9px;
    font-size: .72rem;
  }
  .install-banner-main {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 10px;
  }
  .install-banner-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }
  .install-banner-copy strong {
    font-size: .93rem;
  }
  .install-banner-copy p,
  .install-banner-ios-steps {
    font-size: .82rem;
  }
  .install-banner-copy small {
    font-size: .75rem;
  }
  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .edit-table,
  .edit-table tbody,
  .edit-table tr,
  .edit-table td {
    display: block;
    width: 100%;
  }
  .edit-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }
  .masterdata-table td {
    width: 100% !important;
  }
  .edit-table thead {
    display: none;
  }
  .edit-table tbody {
    display: grid;
    gap: 10px;
  }
  .weekday-group-section .edit-table tbody {
    padding: 10px;
  }
  .edit-table tr {
    display: grid;
    gap: 7px;
    padding: 12px;
    background: rgba(255,255,255,.88);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
  }
  .masterdata-table tr {
    gap: 9px;
    padding: 14px;
  }
  .masterdata-table .icon-action {
    width: 36px;
    min-height: 36px;
  }
  .masterdata-table .entity-name {
    padding: 6px 0;
    font-size: 1rem;
  }
  .edit-table td {
    display: grid;
    grid-template-columns: minmax(76px, .34fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 0;
    border-bottom: 0;
  }
  .edit-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
    line-height: 1.1;
  }
  .edit-table td:last-child {
    grid-template-columns: 1fr;
  }
  .edit-table td:last-child::before {
    display: none;
  }
  .group-picker-panel {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }
  .edit-table input,
  .edit-table select,
  .edit-table textarea {
    min-width: 0;
    min-height: 38px;
    padding: 8px;
    font-size: .9rem;
  }
  .edit-table textarea {
    min-height: 58px;
  }
  .edit-table .button {
    min-height: 38px;
    padding: 8px 10px;
  }
  .entity-create-grid {
    grid-template-columns: 1fr;
  }
  .entity-create-actions {
    justify-content: stretch;
  }
  .entity-create-actions .button {
    width: 100%;
  }
  .js-inline-entity-form input[name="id"][value]:not([value=""]) ~ td:last-child .button {
    opacity: .55;
  }
}
