/* Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease);
  padding: .55rem .9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600; font-size: .9rem;
  min-height: 40px;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--brand-grad); border-color: transparent; color: #fff;
  box-shadow: 0 1px 8px color-mix(in srgb, var(--brand-a) 35%, transparent);
}
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-small { min-height: 30px; padding: .2rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn.active { background: var(--brand-grad); border-color: transparent; color: #fff; }

/* Cards / lists ------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem;
}

.list-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  width: 100%; text-align: left;
}
.list-row { transition: background var(--dur-1) var(--ease); }
.list-row:active { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .row-sub { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: var(--photo-size); height: var(--photo-size);
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  object-fit: cover; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-muted);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { --photo-size: 96px; width: 96px; height: 96px; font-size: 1.6rem; }

/* Badges --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
html[data-theme="dark"] .badge-blue { color: #bfdbfe; }
.badge-green { background: rgba(14, 159, 110, .15); color: var(--green); border-color: transparent; }
.badge-amber { background: rgba(194, 120, 3, .15); color: var(--amber); border-color: transparent; }
.badge-red { background: rgba(220, 38, 38, .12); color: var(--red); border-color: transparent; }

/* Forms ---------------------------------------------------------------- */
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="tel"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 40px;
}
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: .7rem; }
label.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: .25rem; }

.login-card {
  width: min(360px, 90vw); display: flex; flex-direction: column; gap: .8rem; text-align: center;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 20px; padding: 2rem 1.6rem;
  box-shadow: var(--shadow-3);
}
.login-card .loading-logo { font-size: 1.9rem; }

/* Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg);
  box-shadow: var(--shadow-3);
  animation: rise var(--dur-2) var(--ease);
  width: 100%; max-width: 640px;
  max-height: calc(100dvh - 40px);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow-y: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); max-height: 88vh; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .8rem; gap: .5rem;
}
.modal-close { font-size: 1.4rem; line-height: 1; padding: .3rem .6rem; color: var(--text-muted); }

/* Toast ---------------------------------------------------------------- */
#toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 12px);
  z-index: 200; display: flex; flex-direction: column; gap: .4rem; align-items: center;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: .5rem .9rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}
.toast-error { background: var(--red); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Banner ---------------------------------------------------------------- */
.banner { padding: .6rem .9rem; font-size: .85rem; display: flex; gap: .6rem; align-items: center; justify-content: center; }
.banner-error { background: var(--red); color: #fff; }

/* Search / filter bar --------------------------------------------------- */
.searchbar { display: flex; flex-direction: column; gap: .5rem; padding: .7rem .8rem; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.filter-row { display: flex; gap: .4rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: .25rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .78rem; font-weight: 600;
}
.chip.active { background: var(--brand-grad); color: #fff; border-color: transparent; }
.count-bar { font-size: .78rem; color: var(--text-muted); padding: 0 .1rem; }

/* Assignment UI --------------------------------------------------------- */
.camper-chip {
  display: flex; align-items: center; gap: .45rem;
  padding: .35rem .55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600;
  width: 100%; text-align: left;
}
.camper-chip.dragging { opacity: .4; }
.camper-chip .avatar { --photo-size: 26px; font-size: .6rem; }
.drop-target.drag-over { outline: 2px dashed var(--blue); outline-offset: -2px; background: var(--blue-soft); }

.fill-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.fill-bar > div { height: 100%; border-radius: 999px; background: var(--green); }
.fill-bar.over > div { background: var(--red); }

.grid-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .45rem; }
.grid-cell {
  border-radius: var(--radius-sm);
  padding: .45rem .35rem;
  text-align: center;
  border: 1px solid var(--border);
  font-size: .72rem; font-weight: 700;
  background: var(--surface);
}

/* Attention / dashboard -------------------------------------------------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.stat-card { text-align: center; }
.stat-card .big { font-size: 1.7rem; font-weight: 800; }
.attn-badges { display: flex; flex-wrap: wrap; gap: .3rem; }

.capacity-row { display: flex; align-items: center; gap: .6rem; margin: .35rem 0; }
.capacity-row .lbl { width: 4.2rem; font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.capacity-row .fill-bar { flex: 1; }
.capacity-row .num { font-size: .75rem; color: var(--text-muted); width: 4.5rem; text-align: right; }

/* Print preview overlay (screen styles; print.css takes over on paper) ---- */
.print-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #f0f1f4; overflow-y: auto;
  padding: 0 0 3rem;
}
.print-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.print-sheet {
  background: #fff; color: #000;
  max-width: 8.5in; margin: 1rem auto;
  padding: .75in .6in;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .18);
}
.print-sheet .p-header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 12px; }
.print-sheet .p-camp { font-size: .7rem; font-weight: 700; letter-spacing: .04em; }
.print-sheet .p-title { font-size: 1.25rem; font-weight: 800; }
.print-sheet .p-date, .print-sheet .p-sub { font-size: .72rem; color: #444; }
.print-sheet .p-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.print-sheet .p-card { border: 1px solid #bbb; border-radius: 3px; padding: 4px; text-align: center; }
.print-sheet .p-photo { width: 100%; height: 92px; object-fit: cover; background: #eee; display: block; margin-bottom: 3px; }
.print-sheet .p-photo.empty { border: 1px dashed #999; background: #fff; }
.print-sheet .p-name { font-weight: 700; font-size: .78rem; }
.print-sheet .p-meta { font-size: .68rem; color: #333; }
.print-sheet .p-section-title { font-weight: 800; border-bottom: 1px solid #999; margin: 12px 0 6px; }
.print-sheet .p-new-page { border-top: 2px dashed #ccc; margin-top: 18px; padding-top: 10px; } /* page-break hint on screen */
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet th, .print-sheet td { border: 1px solid #999; padding: 3px 6px; font-size: .78rem; text-align: left; }
.print-sheet th { background: #eee; }
.print-sheet .p-empty { color: #555; margin-top: 12px; }
.print-sheet .p-attendance td, .print-sheet .p-attendance th { height: 26px; }
.print-sheet .p-attendance .p-datehead { border-bottom: 2px solid #000; min-width: 50px; }
.print-sheet .p-profile-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.print-sheet .p-profile-head > div { flex: 1; }
.print-sheet .p-cols { column-count: 2; column-gap: 14px; }
.print-sheet .p-block { break-inside: avoid; margin-bottom: 8px; }
.print-sheet .p-block-title { font-weight: 800; border-bottom: 1px solid #999; margin-bottom: 3px; }
.print-sheet .p-row { display: flex; gap: 6px; font-size: .78rem; padding: 1.5px 0; }
.print-sheet .p-k { color: #555; width: 100px; flex-shrink: 0; }
.print-sheet .p-v { overflow-wrap: anywhere; }
.print-sheet .p-note { white-space: pre-wrap; font-size: .78rem; }
.print-sheet .p-photo { width: 76px; height: 76px; object-fit: cover; border: 1px solid #999; display: block; margin: 0 auto 3px; background: #fff; }
.print-sheet .p-photo.empty { border: 1px dashed #999; }
.print-sheet .p-photo-lg { width: 105px; height: 105px; }

/* Import mapping table ------------------------------------------------------ */
.map-table th, .map-table td { border: 1px solid var(--border); padding: .25rem .4rem; font-size: .75rem; white-space: nowrap; }
.map-table select { min-height: 30px; padding: .15rem .3rem; font-size: .75rem; }

/* Segmented control ------------------------------------------------------ */
.seg {
  display: inline-flex; background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 3px; gap: 2px;
}
.seg button {
  padding: .3rem .9rem; border-radius: 6px;
  font-size: .82rem; font-weight: 700; color: var(--text-muted);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }


/* elevation + motion baseline */
.btn:active { transform: scale(.97); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadein { from { opacity: 0; } }
.modal-backdrop { animation: fadein var(--dur-2) var(--ease); }
/* compact medical marker inside tight chips (full MED badge lives in list rows) */
.med-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); margin-left: .35rem; vertical-align: baseline;
}

/* Designed empty state: icon, title, hint - one look everywhere */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  padding: var(--s6) var(--s4); text-align: center; color: var(--text-muted);
}
.empty-state svg { opacity: .45; }
.empty-state .es-title { font-weight: 700; color: var(--text); font-size: var(--fs-md); }
.empty-state .es-hint { font-size: var(--fs-sm); max-width: 340px; }

/* ------------------------------------------------------------------------
   Micro-interactions: restrained, consistent, expensive-feeling.
   ------------------------------------------------------------------------ */

/* interactive cards lift on hover */
button.card, .board-mm-card, .camper-chip, .list-row {
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
button.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.camper-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--blue); }
.camper-chip.dragging { transform: rotate(2deg) scale(1.03); box-shadow: var(--shadow-2); }

/* numbers everywhere align like a ledger */
.stat-card .big, .capacity-row .num, .badge, .grid-cell, .bsg-n, .mm-stats, .board-card-head .bc {
  font-variant-numeric: tabular-nums;
}

/* dashboard stat cards: bigger, tighter, with an accent underline on hover */
.stat-card { position: relative; overflow: hidden; }
.stat-card .big { font-size: 2rem; letter-spacing: -.02em; line-height: 1.15; }
.stat-card::after {
  content: ""; position: absolute; left: 20%; right: 20%; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--blue);
  transform: scaleX(0); transition: transform var(--dur-2) var(--ease);
}
button.stat-card:hover::after { transform: scaleX(1); }
.stat-card .stat-icon { color: var(--text-muted); margin-bottom: .15rem; }
.stat-card .stat-icon.ok { color: var(--success); }
.stat-card .stat-icon.warn { color: var(--warning); }

/* capacity + fill bars sweep in from the left on render */
.fill-bar > div, .bsg-fill {
  transform-origin: left;
  animation: grow-x .55s var(--ease);
}
@keyframes grow-x { from { transform: scaleX(0); } }
.fill-bar > div {
  background: linear-gradient(90deg, var(--green), color-mix(in srgb, var(--green) 70%, #d3f2e4));
}
.fill-bar.over > div {
  background: linear-gradient(90deg, var(--red), color-mix(in srgb, var(--red) 75%, #ffd7d7));
}

/* fill-grid cells breathe on hover */
.grid-cell { transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.grid-cell:hover { transform: scale(1.06); box-shadow: var(--shadow-2); z-index: 1; position: relative; }

/* the whole view eases in on tab switch */
#view > * { animation: view-in var(--dur-2) var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

/* inputs glow softly on focus */
input, select, textarea { transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
  outline: none;
}

/* ------------------------------------------------------------------------
   Hover contract: anything pressable reacts when the mouse is over it.
   Subtle by design - a border, a tint, a 1px lift; never a jump.
   ------------------------------------------------------------------------ */
.btn:hover:not(:disabled) { border-color: var(--blue); box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 2px 14px color-mix(in srgb, var(--brand-a) 45%, transparent);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--red); }
.btn.active:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { cursor: default; opacity: .45; }

.list-row:hover { background: var(--surface-2); }

.seg button { transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.seg button:not(.active):hover { color: var(--text); }

#tabbar button { transition: color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
#tabbar button:hover { color: var(--blue); transform: translateY(-1px); }

.chip { transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.chip:not(.active):hover { border-color: var(--blue); color: var(--blue); }
.chip.active:hover { filter: brightness(1.08); }

.modal-close { border-radius: var(--radius-sm); transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
.modal-close:hover { color: var(--text); background: var(--surface-2); }

a { transition: color var(--dur-1) var(--ease); }
a:hover { text-decoration: underline; }

/* Touch overlays: contain scroll chaining and show a drag handle on phones */
.modal, .peek-card, .pal-list { overscroll-behavior: contain; }
@media (max-width: 699px) {
  .modal::before, .peek-wrap:not(.anchored) .peek-card::before {
    content: ""; display: block; width: 38px; height: 4px; border-radius: 2px;
    background: var(--border); margin: .2rem auto .5rem;
  }
}

/* Bus print previews (screen twins of the print.css rules) */
.print-sheet .p-door { text-align: center; }
.print-sheet .p-door-bus { font-size: 56px; font-weight: 800; color: #1a3a5c; }
.print-sheet .p-door-bunks { font-size: 24px; font-weight: 700; color: #1a3a5c; margin: 5px 0; }
.print-sheet .p-door-count { font-size: 14px; color: #666; margin-bottom: 10px; }
.print-sheet .p-door-top { font-size: 19px; font-weight: 700; color: #1a3a5c; margin: 2px 0; }
.print-sheet .p-door-names { margin-top: 8px; }
.print-sheet .p-door-names.two-col { column-count: 2; column-gap: 36px; }
.print-sheet .p-door-name { font-size: 16px; padding: 2px 0; break-inside: avoid; }
.print-sheet .p-door-name.coun { font-weight: 700; color: #1a3a5c; }
.print-sheet .p-door-role { margin-top: 10px; }
.print-sheet .p-door-role-h { font-weight: 700; color: #1a3a5c; font-size: 14px; }
.print-sheet .p-div-name { text-align: left; }
.print-sheet .p-signin td, .print-sheet .p-signin th,
.print-sheet .p-checkin td, .print-sheet .p-checkin th {
  border: 1px solid #bbb; padding: 4px 7px; font-size: 12.5px; text-align: left;
}
.print-sheet .p-signin thead th, .print-sheet .p-checkin thead th {
  background: #1a3a5c; color: #fff; font-weight: 700;
}
.print-sheet .p-signin table, .print-sheet table.p-signin,
.print-sheet table.p-checkin { border-collapse: collapse; width: 100%; }
.print-sheet .p-coun td { background: #fdf3d8; font-weight: 700; }
.print-sheet .p-checkin .p-box { text-align: center; font-size: 17px; width: 70px; }
.print-sheet .p-signin .p-checkcell { min-width: 90px; }
