/*
 * Application styles (mobile first, RTL). Layout shell, components, pages.
 * Tokens live in tokens.css; fonts in fonts.css.
 */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 700; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-hover); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; direction: ltr; unicode-bidi: embed; }
.fa-num { font-family: var(--font-fa-num); }
.ltr { direction: ltr; unicode-bidi: embed; text-align: left; }
.num { direction: ltr; unicode-bidi: embed; display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.text-muted { color: var(--c-text-muted); }
.text-2 { color: var(--c-text-2); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.fw-500 { font-weight: 500; }
.fw-700 { font-weight: 700; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--c-primary-200); outline-offset: 2px; }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 2; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 36px; height: 36px; stroke-width: 1.5; }

/* ---------- Skip link ---------- */
.skip-link { position: absolute; top: -100px; right: var(--sp-4); background: var(--c-surface); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); box-shadow: var(--sh-md); z-index: 100; }
.skip-link:focus { top: var(--sp-2); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  /* Installed PWA: keep the bar below the notch / status bar and clear of rounded corners. */
  padding-top: var(--safe-top);
  padding-left: calc(var(--sp-3) + var(--safe-left));
  padding-right: calc(var(--sp-3) + var(--safe-right));
  box-sizing: content-box;
}
.topbar .brand { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-text); font-weight: 700; min-width: 0; }
.topbar .brand-mark { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--c-primary); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.topbar .brand-mark .icon { width: 18px; height: 18px; }
.topbar .brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-md); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-1); }
.icon-btn {
  width: var(--touch); height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: var(--r-md); color: var(--c-text-2);
  transition: background var(--ease), color var(--ease);
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn.is-active { color: var(--c-primary); }

/* ---------- Shell ---------- */
.shell { min-height: calc(100vh - var(--topbar-h)); }
.main { min-width: 0; padding: var(--gutter); padding-left: calc(var(--gutter) + var(--safe-left)); padding-right: calc(var(--gutter) + var(--safe-right)); padding-bottom: calc(var(--gutter) + var(--tabbar-h) + var(--safe-bottom)); }
.main-inner { max-width: var(--content-max); margin: 0 auto; }
.topbar .context { display: none; color: var(--c-text-2); font-size: var(--fs-sm); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 60;
  width: min(var(--sidebar-w), 86vw);
  background: var(--c-sidebar-bg); color: var(--c-sidebar-text);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms ease;
  box-shadow: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--sh-lg); }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(10, 25, 22, 0.55); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 220ms ease; }
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
body.sidebar-open { overflow: hidden; }
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.sidebar-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); min-height: var(--topbar-h); border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex: 0 0 auto; }
.sidebar-head > div:not(.brand-mark) { min-width: 0; flex: 1 1 auto; }
.sidebar-head .brand-mark { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--c-primary-500); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.sidebar-head .title { font-weight: 500; color: #fff; font-size: var(--fs-md); line-height: 1.3; }
.sidebar-head .subtitle { font-size: var(--fs-xs); color: var(--c-sidebar-text); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-head .icon-btn { margin-inline-start: auto; color: var(--c-sidebar-text); flex: 0 0 auto; }
.sidebar-nav { padding: var(--sp-3) var(--sp-2); flex: 1 1 auto; }
.nav-section { font-size: var(--fs-xs); color: rgba(207, 227, 223, 0.6); padding: var(--sp-3) var(--sp-3) var(--sp-1); letter-spacing: 0.02em; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--touch); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); color: var(--c-sidebar-text); font-weight: 400;
  transition: background var(--ease), color var(--ease);
  width: 100%; border: 0; background: transparent; text-align: right;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-link.is-active { background: var(--c-sidebar-active); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 var(--c-primary-500); }
.nav-link .icon { opacity: 0.9; }
.nav-link .nav-badge { margin-inline-start: auto; font-size: var(--fs-xs); background: rgba(255, 255, 255, 0.12); padding: 1px 8px; border-radius: var(--r-full); }
.sidebar-foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: var(--fs-xs); display: flex; align-items: center; gap: var(--sp-2); color: rgba(207, 227, 223, 0.8); flex: 0 0 auto; }
.sidebar-foot .avatar { width: 28px; height: 28px; border-radius: var(--r-full); background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; color: #fff; flex: 0 0 auto; }
.sidebar-foot .avatar .icon { width: 16px; height: 16px; }

@media (min-width: 1024px) {
  /* Sidebar stays fixed and always visible; topbar and content are offset by its width. */
  .sidebar { transform: none; width: var(--sidebar-w); }
  body.sidebar-open .sidebar { box-shadow: none; }
  .topbar, .main { margin-right: var(--sidebar-w); }
  .main { padding-bottom: calc(var(--gutter) + var(--safe-bottom)); }
  .sidebar-backdrop, .sidebar-head .icon-btn, .js-sidebar-toggle, .topbar .brand, .tabbar { display: none; }
  .topbar .context { display: block; }
  body.sidebar-open { overflow: auto; }
}

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.page-header .page-title { font-size: var(--fs-xl); }
.page-header .page-desc { color: var(--c-text-muted); font-size: var(--fs-sm); margin: var(--sp-1) 0 0; }
.page-header .page-heading { min-width: 0; flex: 1 1 240px; }
.page-header .page-title { overflow-wrap: anywhere; }
.page-header .page-actions { margin-inline-start: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
@media (max-width: 639.98px) {
  .page-header .page-actions { flex: 1 1 100%; margin-inline-start: 0; }
  .page-header .page-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Cards ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card-body { padding: var(--sp-4); }
.card-header { padding: var(--sp-4); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: var(--sp-2); }
.card-header h2 { font-size: var(--fs-md); }
.card-header .icon { color: var(--c-primary); }
.card-footer { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card + .card { margin-top: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-4); }
@media (min-width: 768px) { .card-body, .card-header { padding: var(--sp-5); } }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: 1fr; }
.grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
}

/* ---------- Stat tiles (1.9.1 redesign) ----------
   One markup for every page: .stat > .stat-label (icon + text) > .stat-value > .stat-sub.
   The label's icon becomes a tinted chip at the inline end, the value is bold and tabular,
   a tone (stat-warn / stat-ok / stat-lead) colours the chip, the value and a 3px start stripe
   instead of flooding the whole card; linked tiles lift on hover. */
.stat {
  --stat-tone: transparent; --stat-chip: var(--c-primary-50); --stat-chip-fg: var(--c-primary);
  position: relative; overflow: hidden; min-width: 0;
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.stat::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--stat-tone); }
.stat-label { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 34px; font-size: var(--fs-sm); font-weight: 500; color: var(--c-text-2); line-height: 1.5; }
.stat-label .icon { order: 2; flex: 0 0 auto; box-sizing: border-box; width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--stat-chip); color: var(--stat-chip-fg); }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-value a { color: inherit; }
.stat-value a:hover { color: var(--c-primary); }
.stat-sub { font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.6; }
.stat-sm { padding: var(--sp-3); gap: 2px; }
.stat-sm .stat-label { min-height: 28px; }
.stat-sm .stat-label .icon { width: 28px; height: 28px; padding: 6px; border-radius: 8px; }
.stat-sm .stat-value { font-size: var(--fs-xl); }
.stat .capacity-meter { margin: var(--sp-1) 0; }
/* Tones */
.stat-warn { --stat-tone: var(--c-danger); --stat-chip: var(--c-danger-100); --stat-chip-fg: var(--c-danger); }
.stat-warn .stat-value { color: var(--c-danger); }
.stat-ok { --stat-tone: var(--c-success); --stat-chip: var(--c-success-100); --stat-chip-fg: var(--c-success); }
.stat-ok .stat-value { color: var(--c-success); }
.stat-lead { --stat-tone: var(--c-warning); --stat-chip: var(--c-warning-100); --stat-chip-fg: var(--c-warning); }
/* Linked tiles */
a.stat-link { color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--c-primary-200); box-shadow: var(--sh-md); transform: translateY(-1px); }
a.stat-link.stat-warn:hover { border-color: var(--c-danger-border); }
a.stat-link.stat-ok:hover { border-color: var(--c-success-border); }
a.stat-link.stat-lead:hover { border-color: var(--c-warning-border); }
@media (hover: none) { a.stat-link:hover { transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); padding: 0 var(--sp-4);
  border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 500; font-size: var(--fs-base); line-height: 1.2;
  background: var(--c-surface); color: var(--c-text);
  transition: background var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: #fff; }
.btn-outline { border-color: var(--c-border-strong); color: var(--c-text-2); background: var(--c-surface); }
.btn-outline:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-ghost { background: transparent; color: var(--c-text-2); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 48px; padding: 0 var(--sp-5); font-size: var(--fs-md); font-weight: 700; }
.btn-sm { min-height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-sm .icon { width: 14px; height: 14px; }
.btn:disabled, .btn.is-loading { opacity: 0.65; cursor: default; }
.btn.is-loading { position: relative; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
@media (min-width: 768px) { .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .span-2 { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field-label { font-weight: 500; font-size: var(--fs-sm); color: var(--c-text-2); display: flex; align-items: center; gap: var(--sp-1); }
.field-label .req { color: var(--c-danger); }
.input, .select, .textarea {
  width: 100%; min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); color: var(--c-text);
  transition: border-color var(--ease), box-shadow var(--ease);
  -webkit-appearance: none; appearance: none;
  font-size: var(--fs-input); /* 16px on touch screens (no iOS zoom on focus), body size with a mouse */
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-100); }
.input::placeholder { color: var(--c-text-muted); opacity: 0.8; }
.input.is-invalid { border-color: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-border); }
.input.is-valid { border-color: var(--c-success); box-shadow: 0 0 0 3px var(--c-success-border); }
.input-ltr { direction: ltr; text-align: left; }
.input-num { direction: ltr; text-align: left; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.input-group { position: relative; display: flex; align-items: stretch; }
.input-group .input { flex: 1 1 auto; }
.input-group .input-addon {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: var(--touch); display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--c-text-muted); border-radius: var(--r-md);
}
.input-group .input-addon:hover { color: var(--c-primary); }
.input-group .input { padding-left: var(--touch); }
.input-group .input-icon { position: absolute; top: 0; bottom: 0; right: var(--sp-3); display: inline-flex; align-items: center; color: var(--c-text-muted); pointer-events: none; }
.input-group.has-icon .input { padding-right: calc(var(--sp-3) + 26px); }
.field-hint { font-size: var(--fs-xs); color: var(--c-text-muted); min-height: 1.2em; }
.field-hint.is-error { color: var(--c-danger); font-weight: 500; }
.field-hint.is-success { color: var(--c-success); font-weight: 500; }
.field-hint.is-muted { color: var(--c-text-muted); }
.field-error { font-size: var(--fs-xs); color: var(--c-danger); font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.form-actions .btn { flex: 1 1 auto; }
@media (min-width: 768px) { .form-actions .btn { flex: 0 0 auto; min-width: 160px; } }

/* Switch (checkbox) */
.switch { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--touch); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 44px; height: 26px; border-radius: var(--r-full); background: var(--c-border-strong); position: relative; transition: background var(--ease); flex: 0 0 auto; }
.switch .track::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--sh-sm); transition: transform var(--ease); }
.switch input:checked + .track { background: var(--c-primary); }
.switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--c-primary-200); outline-offset: 2px; }
.switch .switch-text { display: flex; flex-direction: column; }
.switch .switch-text small { color: var(--c-text-muted); font-size: var(--fs-xs); }

/* ---------- Flash messages ---------- */
.flash-stack { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.flash { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid; font-size: var(--fs-sm); transition: opacity 200ms ease, transform 200ms ease; }
.flash.is-leaving { opacity: 0; transform: translateY(-4px); }
.flash .icon { margin-top: 2px; }
.flash-text { flex: 1 1 auto; }
.flash-close { margin-inline-start: auto; width: 28px; height: 28px; border: 0; background: transparent; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; color: inherit; opacity: 0.7; }
.flash-close:hover { opacity: 1; background: rgba(0, 0, 0, 0.05); }
.flash-success { background: var(--c-success-bg); border-color: var(--c-success-border); color: var(--c-success); }
.flash-error { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); }
.flash-warning { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.flash-info { background: var(--c-info-bg); border-color: var(--c-info-border); color: var(--c-info); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--c-text-muted); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.empty-state .empty-icon { width: 56px; height: 56px; border-radius: var(--r-full); background: var(--c-primary-50); color: var(--c-primary); display: grid; place-items: center; margin-bottom: var(--sp-2); }
.empty-state .empty-title { font-weight: 700; color: var(--c-text); font-size: var(--fs-md); }
.empty-state .empty-text { max-width: 36ch; font-size: var(--fs-sm); margin: 0; }
.empty-state .empty-action { margin-top: var(--sp-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 500; border: 1px solid transparent; line-height: 1.7; white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge-success { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-border); }
.badge-danger { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger-border); }
.badge-warning { background: var(--c-warning-bg); color: var(--c-warning); border-color: var(--c-warning-border); }
.badge-info { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info-border); }
.badge-neutral { background: var(--c-surface-2); color: var(--c-text-2); border-color: var(--c-border); }

/* ---------- Lists / description ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); min-height: var(--touch); }
.list-item:last-child { border-bottom: 0; }
.list-item .list-icon { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--c-surface-2); display: grid; place-items: center; color: var(--c-text-2); flex: 0 0 auto; }
.list-item .list-main { flex: 1 1 auto; min-width: 0; }
.list-item .list-title { font-weight: 500; overflow-wrap: anywhere; }
.list-item .list-meta { font-size: var(--fs-xs); color: var(--c-text-muted); }
.dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.dl .dl-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); }
.dl .dl-row:last-child { border-bottom: 0; }
.dl dt { color: var(--c-text-muted); font-size: var(--fs-sm); margin: 0; }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Tables (degrade to cards below 768px) ---------- */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-border); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-3); text-align: right; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table th { background: var(--c-surface-2); font-weight: 500; color: var(--c-text-2); white-space: nowrap; }
.table .num { overflow-wrap: normal; } /* the table scrolls sideways; numbers must not break into digits */
.table tr:last-child td { border-bottom: 0; }
@media (max-width: 767.98px) {
  .table-cards .table, .table-cards thead, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards thead { display: none; }
  .table-cards tr { border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
  .table-cards td { display: flex; justify-content: space-between; gap: var(--sp-3); border: 0; padding: var(--sp-1) var(--sp-3); }
  .table-cards td::before { content: attr(data-label); color: var(--c-text-muted); font-size: var(--fs-xs); }
  .table-cards .table-wrap { border: 0; }
}

/* ---------- Segmented radio control ---------- */
.segmented { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.segmented .segment { position: relative; flex: 1 1 auto; min-width: 0; }
.segmented .segment input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented .segment span {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--touch); padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); color: var(--c-text-2); font-weight: 500; font-size: var(--fs-sm);
  cursor: pointer; transition: background var(--ease), border-color var(--ease), color var(--ease);
  text-align: center;
}
.segmented .segment span .icon { width: 15px; height: 15px; }
.segmented .segment input:checked + span { background: var(--c-primary-50); border-color: var(--c-primary); color: var(--c-primary-800); box-shadow: inset 0 0 0 1px var(--c-primary); }
.segmented .segment input:focus-visible + span { outline: 3px solid var(--c-primary-200); outline-offset: 2px; }
.segmented-lg .segment span { min-height: 48px; font-size: var(--fs-base); }

/* ---------- Choice rows (radio / checkbox with label) ---------- */
.choice { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--touch); cursor: pointer; }
.choice input { width: 18px; height: 18px; accent-color: var(--c-primary); flex: 0 0 auto; margin: 0; }
.stack-sm > * + * { margin-top: var(--sp-2); }
.inline-form { display: inline; }

/* ---------- Member rows (family form) ---------- */
.member-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.member-row { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); background: var(--c-surface-2); }
.member-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.member-row-title { font-weight: 700; font-size: var(--fs-sm); color: var(--c-text-2); }
.member-grid { grid-template-columns: 1fr; }
@media (min-width: 768px) { .member-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .member-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.icon-btn-sm { width: 34px; height: 34px; }
.icon-btn-sm .icon { width: 16px; height: 16px; }

/* ---------- Bulk re-price rows (settings, 1.9.3) ---------- */
.reprice-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; justify-content: space-between; padding: var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-2); }
.reprice-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.reprice-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.reprice-meta { display: flex; flex-wrap: wrap; gap: 4px var(--sp-3); font-size: var(--fs-sm); color: var(--c-text-2); }
.reprice-meta .icon { vertical-align: -2px; margin-inline-end: 3px; }
.reprice-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-2); }
.reprice-actions .field { min-width: 220px; }
@media (max-width: 639.98px) { .reprice-actions, .reprice-actions .field, .reprice-actions .btn { width: 100%; } }

/* ---------- Installment cheques (registration form, 1.9.2) ---------- */
.cheque-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.cheque-row { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); background: var(--c-surface-2); }
.cheque-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.cheque-row-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--fs-sm); color: var(--c-text-2); }
.cheque-row-title .icon { color: var(--c-warning); }
.cheque-grid { grid-template-columns: 1fr; }
@media (min-width: 640px) { .cheque-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .cheque-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) { .cheque-down { max-width: 360px; } }
.cheque-summary { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3); background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--c-text-2); }
.cheque-summary strong { color: var(--c-text); }

/* ---------- Registrants list ---------- */
.filter-bar .card-body { padding: var(--sp-3); }
.filter-search { display: flex; gap: var(--sp-2); align-items: center; }
.filter-search .input-group { flex: 1 1 auto; }
.filter-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--sp-3); }
.filter-grid .field-label { font-size: var(--fs-xs); }
.filter-buttons { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filter-grid .filter-actions { grid-column: 1 / -1; }
@media (min-width: 768px) { .filter-grid .filter-actions { grid-column: auto; } }
.btn .nav-badge { background: var(--c-primary-100); color: var(--c-primary-800); font-size: var(--fs-xs); padding: 0 8px; border-radius: var(--r-full); line-height: 1.8; }
@media (min-width: 768px) { .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .filter-bar .card-body { padding: var(--sp-4); } }
@media (min-width: 1200px) { .filter-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.results { position: relative; }
.results.is-loading { opacity: 0.55; pointer-events: none; transition: opacity 120ms ease; }
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.grid-stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .grid-stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid-stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.grid-stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .grid-stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid-stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* Payment-pending leads: the amber stat-lead tone (see the stat tiles block) */
.registration-state { flex: 0 0 auto; }
.registration-state .select { min-width: 150px; padding-top: 0; padding-bottom: 0; }
@media (max-width: 767.98px) { .filter-search { flex-wrap: wrap; } .registration-state { flex: 1 1 100%; order: 3; } }
tr.row-lead td { background: #fffaf0; }
.table-cards tr.row-lead { border-right: 3px solid var(--c-warning-border); }
.lead-people { display: flex; flex-direction: column; gap: 2px; }
.lead-people li { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; }
.lead-people .icon { color: var(--c-warning); width: 14px; height: 14px; }
.resume-link-row { display: flex; gap: var(--sp-2); align-items: center; }
.resume-link-row .input { flex: 1 1 auto; min-width: 0; direction: ltr; text-align: left; font-size: var(--fs-xs); }
.attempt-list .dl-row dd { text-align: left; }
.stat-value-sm { font-size: var(--fs-lg) !important; }
.stat-sep { color: var(--c-border-strong); font-weight: 400; }
/* ---------- People table (desktop, 1.9.1 refresh): initial avatars, family rail, hover ---------- */
.table-registrants th { padding-left: var(--sp-2); padding-right: var(--sp-2); }
.table-registrants td { padding: var(--sp-2); }
.table-registrants .person-cell { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex-wrap: nowrap; }
.table-registrants td:first-child { min-width: 160px; }
.table-registrants .badge { padding: 1px 7px; }
.table-registrants .gender-mark .icon { width: 14px; height: 14px; }
/* The word is redundant next to the coloured mars / venus icon in the dense table. */
.table-registrants td[data-label="جنسیت"] .gender-mark { font-size: 0; gap: 0; }
.table-registrants td[data-label="جنسیت"] .gender-mark .icon { font-size: initial; }
.table-registrants td[data-label="مانده"] { white-space: nowrap; }
.person-cell-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person-cell-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.person-cell-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-xs); }
.person-cell-sub .group-link { white-space: nowrap; }
.table-registrants .person-name { white-space: nowrap; }
.person-name { font-weight: 600; color: var(--c-text); }
.person-name:hover { color: var(--c-primary); }
.badge-leader { padding: 1px 8px; }
.tel-link { color: inherit; }
.tel-link:hover { color: var(--c-primary); }
.table-registrants tbody tr:hover td { background: var(--c-surface-2); }
/* A family is one block: tinted leader row, indented member rows, a rail in the family colour on the start edge. */
tr.is-leader td { border-top: 2px solid var(--c-border); }
tr.is-leader td, tr.is-member td { background: hsl(var(--party-hue, 170) 40% 98.5%); }
tr.is-leader td:first-child, tr.is-member td:first-child { box-shadow: inset -3px 0 0 hsl(var(--party-hue, 170) 45% 62%); }
tr.is-member td:first-child { padding-right: var(--sp-6); }
.table-registrants tbody tr.is-leader:hover td, .table-registrants tbody tr.is-member:hover td { background: hsl(var(--party-hue, 170) 40% 96%); }
tr.is-last td { border-bottom: 2px solid var(--c-border); }
tr.is-dim td { opacity: 0.55; }
.td-actions { white-space: nowrap; text-align: left; }
.th-actions { width: 1%; }
/* Initial avatars (people lists): the party colour, a ring for family leaders. */
.avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border-radius: var(--r-full); background: hsl(var(--party-hue, 170) 45% 92%); color: hsl(var(--party-hue, 170) 40% 30%); font-weight: 700; font-size: var(--fs-sm); line-height: 1; text-decoration: none; user-select: none; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar.is-leader { box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px hsl(var(--party-hue, 170) 45% 62%); }
.gender-mark { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 400; color: var(--c-text-muted); white-space: nowrap; }
.gender-mark .icon { width: 12px; height: 12px; }
.gender-mark.is-male .icon { color: var(--c-male); }
.gender-mark.is-female .icon { color: var(--c-female); }
.party-role { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 500; color: var(--c-primary-800); background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--r-full); padding: 0 7px; line-height: 1.6; white-space: nowrap; }
.party-role .icon { width: 11px; height: 11px; }
/* Per-person transport (1.9.4): mark in member rows + the family's transport form */
.transport-mark { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 500; border-radius: var(--r-full); padding: 0 7px; line-height: 1.6; white-space: nowrap; }
.transport-mark .icon { width: 11px; height: 11px; }
.transport-mark.is-bus { color: var(--c-info); background: var(--c-info-100); }
.transport-mark.is-car { color: var(--c-text-2); background: var(--c-surface-2); }
.transport-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.transport-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-2); }
.transport-person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.transport-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transport-row .segmented { flex: 0 0 auto; }
.segmented-sm .segment span { min-height: 34px; padding: 0 10px; font-size: var(--fs-xs); gap: 4px; }
.segmented-sm .segment span .icon { width: 13px; height: 13px; }
@media (max-width: 479.98px) { .transport-row { align-items: stretch; } .transport-row .segmented { width: 100%; } }

/* Personal tour price (1.9.1): compact tag in people lists / meta lines */
.price-tag { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 500; color: var(--c-info); background: var(--c-info-100); border-radius: var(--r-full); padding: 0 7px; line-height: 1.6; white-space: nowrap; }
.price-tag .icon { width: 11px; height: 11px; }
.field-price .field-label .icon { width: 12px; height: 12px; margin-inline-end: 4px; color: var(--c-info); vertical-align: -1px; }
@media (max-width: 767.98px) {
  .table-cards tr.is-leader { border-top: 3px solid var(--c-primary-200); background: var(--c-primary-50); }
  .table-cards tr.is-member { background: #fbfdfc; margin-right: var(--sp-4); border-right: 3px solid var(--c-primary-100); }
  .table-cards tr.is-member td:first-child { padding-right: var(--sp-3); }
  .table-cards .td-actions { justify-content: flex-start; }
  .table-cards .td-actions::before { display: none; }
}

/* ---------- Party cards (phase 8.1, redesigned 1.9.1): registrants and bus passengers below 1024px ----------
   One card per family / single person; the tables (.table-desktop) take over from 1024px.
   Anatomy: head (avatar in the party colour, name, sub line, actions) > status pills >
   member rows (families) > foot (balance due / credit, or the bus unassign form). */
.party-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
/* Tablets: two balanced columns (multi-column, so a short single card never leaves a hole beside a tall family). */
@media (min-width: 640px) {
  .party-list { display: block; columns: 2; column-gap: var(--sp-3); }
  .party-list .party-card { break-inside: avoid; margin-bottom: var(--sp-3); }
}
.party-card { position: relative; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden; min-width: 0; padding: 0; }
.party-card.is-debtor { border-color: var(--c-danger-border); }
.party-card.is-dim { opacity: 0.55; }
.party-card-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.party-card.is-lead .party-card-head { background: var(--c-warning-bg); border-bottom: 1px solid var(--c-warning-border); padding-bottom: var(--sp-3); }
.party-card.is-lead .party-card-head.is-closed { background: var(--c-surface-2); border-bottom-color: var(--c-border); }
.party-avatar { width: 44px; height: 44px; border-radius: 14px; font-size: var(--fs-lg); position: relative; }
.party-avatar.is-family .icon { width: 22px; height: 22px; }
.party-avatar.is-warning { background: var(--c-warning-100); color: var(--c-warning); }
.party-avatar-count { position: absolute; bottom: -5px; inset-inline-start: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--r-full); background: hsl(var(--party-hue, 170) 40% 30%); color: #fff; font-size: 10px; font-weight: 700; line-height: 19px; text-align: center; border: 2px solid var(--c-surface); }
.party-card-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.party-card-name-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.party-card-name { font-weight: 700; font-size: var(--fs-md); color: var(--c-text); overflow-wrap: anywhere; line-height: 1.4; }
.party-card-name:hover { color: var(--c-primary); }
.party-card-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.6; }
.party-card-sub a { color: inherit; }
.party-card-sub a:hover { color: var(--c-primary); }
.party-sub-item { display: inline-flex; align-items: center; min-width: 0; }
.party-sub-item + .party-sub-item::before { content: '·'; margin-inline-end: var(--sp-2); color: var(--c-border-strong); }
.party-card-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; margin-inline-end: calc(-1 * var(--sp-1)); }
.party-card-actions .icon-btn { color: var(--c-text-2); }
.party-card-link { flex: 0 0 auto; color: var(--c-primary-800); margin-inline-end: calc(-1 * var(--sp-2)); }
.party-card-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-2); padding: 0 var(--sp-3) var(--sp-3); }
.party-tag { display: inline-flex; align-items: center; gap: 4px; }
.party-tag-k { font-size: var(--fs-xs); color: var(--c-text-muted); }
.party-people { display: flex; flex-direction: column; border-top: 1px solid var(--c-border); }
.party-person, .member-list > .row-person { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); min-height: 54px; border-bottom: 1px solid var(--c-border); }
.party-person:last-child, .member-list > .row-person:last-child { border-bottom: 0; }
.party-person.is-dim { opacity: 0.55; }
.party-person-mark { width: 34px; height: 34px; font-size: var(--fs-sm); }
.party-person-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.party-person-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; line-height: 1.5; }
.party-person-name a { font-weight: 700; color: var(--c-text); overflow-wrap: anywhere; }
.party-person-name a:hover { color: var(--c-primary); }
.party-person-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-2); }
.party-person-meta a { color: inherit; }
.party-person-meta a:hover { color: var(--c-primary); }
.party-person-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; margin-inline-end: calc(-1 * var(--sp-2)); }
.party-person-actions .icon-btn { color: var(--c-text-muted); }
.party-person-actions .seat-chip { margin-inline-end: var(--sp-1); }
.seat-chip.is-none { background: var(--c-surface-2); color: var(--c-text-muted); }
.party-card-foot { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-3); min-height: 40px; border-top: 1px solid var(--c-border); background: var(--c-surface-2); font-size: var(--fs-sm); }
.party-card-foot.is-debt { background: var(--c-danger-bg); border-top-color: var(--c-danger-border); color: var(--c-danger); }
.party-card-foot.is-credit { background: var(--c-success-bg); border-top-color: var(--c-success-border); color: var(--c-success); }
.party-foot-label { display: inline-flex; align-items: center; gap: 4px; }
.party-foot-value { font-weight: 700; }
.party-card-foot .btn, .party-card-foot .inline-form { margin-inline-start: auto; }
.party-card-foot.is-debt .btn { color: var(--c-danger); }
.party-card-foot.is-credit .btn { color: var(--c-success); }
/* Lead cards (payment-pending registrations) keep their compact people list + facts grid. */
.party-people.is-compact .party-person { min-height: 0; padding: var(--sp-2) var(--sp-3); }
.party-people.is-compact .party-person-mark { width: 28px; height: 28px; border-radius: var(--r-full); background: var(--c-surface-2); color: var(--c-text-muted); display: grid; place-items: center; flex: 0 0 auto; }
.party-people.is-compact .party-person.is-leader .party-person-mark { background: var(--c-warning-100); color: var(--c-warning); }
.party-people.is-compact .party-person-main { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px var(--sp-3); }
.party-people.is-compact .party-person-name span:first-child { font-weight: 500; }
.party-meta-item { display: inline-flex; align-items: center; gap: 4px; color: inherit; min-width: 0; }
.party-meta-item .icon { color: var(--c-text-muted); }
a.party-meta-item:hover { color: var(--c-primary); }
.party-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-2) var(--sp-3); align-items: center; margin: 0; padding: var(--sp-3); border-top: 1px solid var(--c-border); background: var(--c-surface-2); font-size: var(--fs-sm); }
.party-facts > div { display: contents; }
.party-facts dt { color: var(--c-text-muted); white-space: nowrap; }
.party-facts dd { margin: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; overflow-wrap: anywhere; }
/* ---------- Party profile pages (1.9.1): family page + single edit page ----------
   Head card (avatar in the party colour, name, sub line, status pills) with quick-action
   tiles, the members list (same rows as the cards) and collapsible secondary cards. */
.profile-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.profile-avatar { width: 52px; height: 52px; border-radius: 16px; font-size: var(--fs-xl); position: relative; }
.profile-avatar.is-family .icon { width: 26px; height: 26px; }
.profile-avatar .party-avatar-count { font-size: var(--fs-xs); min-width: 21px; height: 21px; line-height: 21px; }
.profile-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.profile-name { margin: 0; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-lg); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.profile-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.7; }
.profile-sub a { color: inherit; }
.profile-sub a:hover { color: var(--c-primary); }
.profile-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-2); margin-top: var(--sp-1); }
.profile-badges a.badge { text-decoration: none; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 1px; background: var(--c-border); border-top: 1px solid var(--c-border); border-radius: 0 0 var(--r-lg) var(--r-lg); overflow: hidden; }
/* three tiles per row on phones; a short last row stretches its tiles instead of leaving a hole */
.profile-action { position: relative; flex: 1 1 30%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 62px; padding: var(--sp-2); background: var(--c-surface-2); color: var(--c-text-2); font-size: var(--fs-xs); font-weight: 500; text-decoration: none; text-align: center; transition: background var(--ease), color var(--ease); }
.profile-action .icon { width: 20px; height: 20px; color: var(--c-primary); }
.profile-action:hover { background: var(--c-primary-50); color: var(--c-primary-800); }
.profile-action.is-alert .icon { color: var(--c-danger); }
.profile-action.is-alert::after { content: ''; position: absolute; top: 8px; inset-inline-end: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-danger); box-shadow: 0 0 0 2px var(--c-surface-2); }
@media (min-width: 640px) {
  .profile-actions { flex-wrap: nowrap; }
  .profile-action { flex: 1 1 0; flex-direction: row; min-height: 46px; font-size: var(--fs-sm); }
  .profile-action .icon { width: 18px; height: 18px; }
}
.party-role.is-neutral { color: var(--c-text-2); background: var(--c-surface-2); border-color: var(--c-border); }
.card-header .card-header-action { margin-inline-start: auto; }
.member-list { border-top: 0; }
.member-list > .row-person.is-leader { background: hsl(var(--party-hue, 170) 40% 98%); }
.icon-btn.is-danger:hover { background: var(--c-danger-bg); color: var(--c-danger); }
/* Collapsible cards: closed below 1024px unless .is-open (header tap, hash target, data-open); always open on desktop. */
.card-collapsible .card-header[data-collapse-toggle] { cursor: pointer; user-select: none; }
.collapse-chevron { margin-inline-start: auto; display: inline-flex; color: var(--c-text-muted); transition: transform var(--ease); }
.collapse-summary { margin-inline-start: auto; }
.collapse-summary + .collapse-chevron { margin-inline-start: 0; }
.card-collapsible.is-open .collapse-chevron { transform: rotate(180deg); }
@media (max-width: 1023.98px) {
  .card-collapsible:not(.is-open) > .collapsible-body { display: none; }
  .card-collapsible:not(.is-open) > .card-header { border-bottom: 0; }
}
@media (min-width: 1024px) {
  .collapse-chevron { display: none; }
  .card-collapsible .card-header[data-collapse-toggle] { cursor: default; }
}
/* Flat variant inside another card (bus page): dividers instead of boxed cards. */
.party-list-flat .party-list { display: flex; columns: auto; gap: 0; margin: 0; }
.party-list-flat .party-card { border: 0; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--c-border); margin-bottom: 0; }
.party-list-flat .party-card:last-child { border-bottom: 0; }
.table-desktop { display: none; }
@media (min-width: 1024px) {
  .party-list, .party-list-flat { display: none; }
  .table-desktop { display: block; }
}

/* ---------- Task manager (phase 9): checklists, quick-add, one-tap rows ---------- */
.tasks { display: flex; flex-direction: column; gap: var(--sp-4); }
.task-summary { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.task-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 10px; border-radius: var(--r-full); border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; }
.task-chip .icon { color: var(--c-text-muted); }
.task-chip.is-overdue { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); }
.task-chip.is-overdue .icon { color: var(--c-danger); }
.task-chip.is-today { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.task-chip.is-today .icon { color: var(--c-warning); }
.task-chip.is-muted { color: var(--c-success); border-color: var(--c-success-border); background: var(--c-success-bg); }
.task-chip.is-muted .icon { color: var(--c-success); }
.task-filters { margin-bottom: 0; }
.tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--c-surface-2); color: var(--c-text-muted); font-size: var(--fs-xs); font-weight: 500; }
.tab.is-active .tab-count { background: var(--c-primary-50); color: var(--c-primary-800); }
.task-list { overflow: visible; }
.task-list-head { flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.task-list-heading { flex: 1 1 200px; min-width: 0; }
.task-list-heading h2 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); overflow-wrap: anywhere; }
.task-list-heading h2 .icon { color: var(--c-primary); flex: 0 0 auto; }
.task-list.is-complete .task-list-heading h2 .icon { color: var(--c-success); }
.task-list-desc { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--c-text-muted); }
.task-progress { display: flex; flex-direction: column; gap: 4px; min-width: 120px; flex: 0 1 160px; }
.task-progress-text { font-size: var(--fs-sm); color: var(--c-text-2); direction: ltr; text-align: right; }
.task-progress-text strong { color: var(--c-text); }
.task-progress-sep { color: var(--c-border-strong); margin: 0 2px; }
.task-meter { margin: 0; }
.capacity-fill.is-complete { background: var(--c-success); }
.task-list-edit-link { flex: 0 0 auto; color: var(--c-text-muted); margin-inline-end: calc(-1 * var(--sp-2)); }
.task-list-edit { display: flex; flex-direction: column; gap: var(--sp-3); }
.task-list-delete { display: flex; justify-content: flex-end; }
.task-delete { color: var(--c-danger); }
.task-delete:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.task-quick-add { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.task-quick-title { flex: 1 1 200px; min-width: 0; display: block; }
.task-quick-due { flex: 0 0 auto; width: 128px; display: block; }
.task-quick-due .input { text-align: center; }
.task-quick-submit { flex: 0 0 auto; padding-inline: var(--sp-3); }
.task-quick-error { flex: 1 1 100%; }
@media (max-width: 479.98px) {
  .task-quick-title { flex-basis: 100%; }
  .task-quick-due { flex: 1 1 auto; width: auto; }
  .task-quick-submit { flex: 1 1 auto; }
}
.task-rows { display: flex; flex-direction: column; }
.task { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--c-border); transition: background 160ms ease; }
.task:last-child { border-bottom: 0; }
.task.is-busy { opacity: 0.7; }
.task-toggle { flex: 0 0 auto; display: flex; align-items: center; min-height: 40px; }
.task-check { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-full); cursor: pointer; color: transparent; padding: 0; -webkit-tap-highlight-color: transparent; }
.task-check::before { content: ''; position: absolute; width: 26px; height: 26px; border-radius: var(--r-full); border: 2px solid var(--c-border-strong); background: var(--c-surface); transition: background 120ms ease, border-color 120ms ease; }
.task-check { position: relative; }
.task-check .icon { position: relative; stroke-width: 3; }
.task-check:hover::before, .task-check:focus-visible::before { border-color: var(--c-primary); }
.task.is-done .task-check { color: #fff; }
.task.is-done .task-check::before { background: var(--c-success); border-color: var(--c-success); }
.task-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 8px; }
.task-title { font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.task.is-done .task-title { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--c-text-muted); font-weight: 400; }
.task-desc { font-size: var(--fs-sm); color: var(--c-text-2); white-space: pre-line; overflow-wrap: anywhere; }
.task.is-done .task-desc { color: var(--c-text-muted); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--sp-2); font-size: var(--fs-xs); }
.task-due { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-full); border: 1px solid var(--c-border); background: var(--c-surface-2); color: var(--c-text-2); font-weight: 500; line-height: 1.7; }
.task-due .icon { width: 13px; height: 13px; }
.task-due-date { color: var(--c-text-muted); font-weight: 400; }
.task:not(.is-done) .task-due.is-overdue, .task:not(.is-done) .task-due.is-today { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); }
.task:not(.is-done) .task-due.is-overdue .task-due-date, .task:not(.is-done) .task-due.is-today .task-due-date { color: var(--c-danger); opacity: 0.8; }
.task:not(.is-done) .task-due.is-soon { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.task:not(.is-done) .task-due.is-soon .task-due-date { color: var(--c-warning); opacity: 0.85; }
.task-done-at { display: inline-flex; align-items: center; gap: 4px; color: var(--c-success); }
.task-done-at .icon { width: 13px; height: 13px; }
.task-edit { flex: 0 0 auto; color: var(--c-text-muted); margin: 0 calc(-1 * var(--sp-2)) 0 0; }
.task.is-editing { background: var(--c-primary-50); }
.task-edit-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.task-edit-form .form-actions { margin-top: 0; }
.task-edit-form .form-actions .btn { flex: 0 0 auto; }
.task-due-field { max-width: 240px; }
.task-delete-form { display: flex; justify-content: flex-end; margin-top: var(--sp-2); }
.task-empty { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4); color: var(--c-text-muted); font-size: var(--fs-sm); }
.task-empty .icon { flex: 0 0 auto; }
.task-new-list summary { list-style: none; cursor: pointer; }
.task-new-list summary::-webkit-details-marker { display: none; }
.task-new-list summary h2 { font-size: var(--fs-md); }
.task-new-list:not([open]) summary { border-bottom: 0; }
.task-new-list summary .icon { color: var(--c-primary); }
/* Fixed toast above the tab bar (admin pages that post over fetch). */
.app-toast { position: fixed; bottom: calc(var(--sp-4) + var(--tabbar-h) + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-full); background: var(--c-text); color: #fff; font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--sh-lg); text-align: center; }
.app-toast.is-ok { background: var(--c-success); }
.app-toast.is-undo { background: var(--c-warning); }
.app-toast.is-error { background: var(--c-danger); }
@media (min-width: 1024px) { .app-toast { bottom: calc(var(--sp-4) + var(--safe-bottom)); } }
/* Navigation badges for overdue tasks: red count in the drawer, red dot on the tab bar item. */
.nav-badge.is-danger { background: var(--c-danger); color: #fff; }
.tabbar-item { position: relative; }
.tabbar-dot { position: absolute; top: 5px; left: calc(50% - 15px); width: 8px; height: 8px; border-radius: 50%; background: var(--c-danger); box-shadow: 0 0 0 2px var(--c-surface); }

/* ---------- Pager ---------- */
.pager { margin-top: var(--sp-4); }
.pager ul { display: flex; gap: var(--sp-1); justify-content: center; flex-wrap: wrap; }
.pager-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 var(--sp-2); border-radius: var(--r-md); border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-sm); }
.pager-link:hover { border-color: var(--c-primary); color: var(--c-primary); }
.pager-link.is-current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pager-link.is-disabled { opacity: 0.4; }
.pager-gap { display: inline-flex; align-items: center; height: 36px; padding: 0 var(--sp-1); color: var(--c-text-muted); }

/* ---------- Person / group header ---------- */
.person-head { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-start; justify-content: space-between; }
.person-head-name { font-size: var(--fs-lg); font-weight: 700; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.person-head-name .icon { color: var(--c-primary); }
.person-head-badges { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.quick-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.card-danger { border-color: var(--c-danger-border); }
.card-danger .card-header { background: var(--c-danger-bg); border-color: var(--c-danger-border); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card-danger .card-header .icon { color: var(--c-danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-border); margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--touch); padding: 0 var(--sp-4); color: var(--c-text-2); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--c-text); }
.tab.is-active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ---------- SMS center ---------- */
.placeholder-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-2); }
.chip { border: 1px solid var(--c-border-strong); background: var(--c-surface-2); color: var(--c-text-2); border-radius: var(--r-full); padding: 3px 9px; font-size: var(--fs-xs); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; min-height: 28px; }
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-primary-50); }
.composer-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.recipients-summary { display: flex; flex-direction: column; gap: var(--sp-1); }
.recipients-count { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); }
.recipients-count .icon { color: var(--c-primary); }
.recipients-count strong { font-size: var(--fs-xl); }
.recipient-list { margin-top: var(--sp-3); max-height: 320px; overflow-y: auto; border: 1px solid var(--c-border); border-radius: var(--r-md); }
.recipient-list li { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--c-border); font-size: var(--fs-sm); }
.recipient-list li:last-child { border-bottom: 0; }
.recipient-mobile { color: var(--c-text-2); }
#segment-recipients.is-loading { opacity: 0.5; }
.pick-row { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); }
.pick-row.is-disabled { opacity: 0.55; cursor: default; }
.pick-main { display: flex; flex-direction: column; }
.pick-name { font-weight: 500; }
.sms-bubble { background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); }
.sms-bubble-text { white-space: pre-wrap; line-height: 1.8; margin-top: var(--sp-1); overflow-wrap: anywhere; word-break: break-word; }
.sms-template-raw { white-space: pre-wrap; font-family: inherit; background: var(--c-surface-2); border-radius: var(--r-md); padding: var(--sp-3); margin: var(--sp-2) 0 0; font-size: var(--fs-sm); }
.sms-text { white-space: pre-wrap; font-size: var(--fs-sm); max-width: 46ch; overflow-wrap: anywhere; word-break: break-word; }
.table-sms .td-text { min-width: 240px; }
.progress { height: 12px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--c-primary); border-radius: var(--r-full); transition: width 250ms ease; }
.job-counters { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }
.dl-compact .dl-row { padding: var(--sp-1) 0; }
.placeholder-doc { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }

/* ---------- SMS presets ---------- */
.preset-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-3); }

/* ---------- Buses ---------- */
.capacity-meter { height: 8px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-full); overflow: hidden; margin: 4px 0; }
.capacity-fill { height: 100%; background: var(--c-primary); border-radius: var(--r-full); transition: width 250ms ease; }
.capacity-fill.is-full { background: var(--c-danger); }
.bus-row { color: inherit; }
.bus-row:hover .list-title { color: var(--c-primary); }
.grid-stats-3 { grid-template-columns: 1fr; gap: var(--sp-2); }
@media (min-width: 640px) { .grid-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.grid-stats-3 .stat-value { font-size: var(--fs-lg); }
.seat-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 8px; background: var(--c-primary-100); color: var(--c-primary-800); font-weight: 700; font-size: var(--fs-sm); }
.seat-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.warning-list { margin: var(--sp-1) 0 0; padding-right: var(--sp-4); font-size: var(--fs-sm); }
.seatmap-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); margin-top: var(--sp-4); }
@media (min-width: 900px) { .seatmap-grid { grid-template-columns: minmax(280px, 380px) 1fr; } }
[data-seatmap].is-loading { opacity: 0.55; pointer-events: none; }
.bus-shell { border: 2px solid var(--c-border-strong); border-radius: 28px 28px 16px 16px; padding: var(--sp-3); background: var(--c-surface-2); max-width: 380px; }
.bus-front, .bus-back { text-align: center; font-size: var(--fs-xs); color: var(--c-text-muted); display: flex; justify-content: center; align-items: center; gap: 6px; padding: var(--sp-1) 0 var(--sp-2); }
.bus-back { padding: var(--sp-2) 0 0; }
.bus-rows { display: flex; flex-direction: column; gap: 6px; }
.seat-row { display: grid; grid-template-columns: 1fr 28px 1fr; align-items: center; gap: 6px; }
.seat-pair { display: flex; gap: 6px; justify-content: center; }
.seat-pair:last-child:has(.seat:only-child) { justify-content: flex-start; } /* 2+1: the lone seat hugs the aisle */
.aisle { text-align: center; font-size: var(--fs-xs); color: var(--c-text-muted); }
.seat { position: relative; width: 60px; height: 52px; border-radius: 10px 10px 6px 6px; border: 2px solid var(--c-border-strong); background: var(--c-surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px 4px; font-size: var(--fs-xs); line-height: 1.2; cursor: pointer; transition: transform 80ms ease, box-shadow 120ms ease; color: var(--c-text-2); }
.seat:hover { transform: translateY(-1px); box-shadow: var(--sh-sm); }
.seat .seat-no { font-weight: 700; font-size: 10.5px; color: var(--c-text-muted); }
.seat.is-taken { background: hsl(var(--party-hue, 150) 55% 92%); border-color: hsl(var(--party-hue, 150) 45% 60%); color: var(--c-text); }
.seat.is-taken .seat-name { font-weight: 500; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.seat.is-taken .seat-no { color: hsl(var(--party-hue, 150) 45% 30%); }
.seat-gender { position: absolute; top: 3px; left: 4px; width: 10px; height: 10px; opacity: 0.7; }
.seat.is-empty.is-target { border-style: dashed; border-color: var(--c-primary); }
.seat.is-selected, .unseated.is-selected { outline: 3px solid var(--c-primary); outline-offset: 1px; }
.seat.is-mini { width: 34px; height: 28px; display: inline-flex; vertical-align: middle; cursor: default; margin: 0 2px; }
.icon-xs { width: 12px; height: 12px; }
.seat-side { min-width: 0; }
@media (max-width: 399.98px) { .seat { width: 52px; height: 48px; } .seat.is-taken .seat-name { max-width: 46px; } .seat-row { grid-template-columns: 1fr 20px 1fr; gap: 4px; } .seat-pair { gap: 4px; } }
.seat-selection { background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--r-md); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.seat-selection-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
.unseated-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.unseated { width: 100%; display: flex; align-items: center; gap: var(--sp-2); text-align: right; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); min-height: var(--touch); cursor: pointer; }
.unseated:hover { border-color: var(--c-primary); }
.unseated.is-disabled { cursor: default; opacity: 0.7; }
.unseated-name { font-weight: 500; flex: 1 1 auto; }
.party-dot { width: 12px; height: 12px; border-radius: 50%; background: hsl(var(--party-hue, 150) 50% 55%); flex: 0 0 auto; }
.seat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ---------- Rooms / hotel rooming ---------- */
.hotel-card { display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.hotel-card-main { flex: 1 1 260px; }
.hotel-card-side { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--c-text-2); text-align: left; }
a.card.stat-link:hover { border-color: var(--c-primary); }
.rooming-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 1024px) { .rooming-grid { grid-template-columns: minmax(320px, 5fr) minmax(320px, 6fr); align-items: start; } }
.unassigned-parties { display: flex; flex-direction: column; gap: var(--sp-3); max-height: 70vh; overflow-y: auto; padding-inline-end: 4px; }
.unassigned-parties .party-card { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); background: var(--c-surface); box-shadow: none; overflow: visible; }
.party-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.party-title { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.party-title .icon { color: var(--c-primary); }
.party-members { margin: var(--sp-2) 0; display: flex; flex-direction: column; gap: 2px; }
.party-members li.is-placed { opacity: 0.7; }
.choice-compact { min-height: 30px; padding: 2px 4px; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 6px; }
.party-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.party-actions .select { flex: 1 1 180px; }
.select-sm { min-height: 36px; padding-top: 0; padding-bottom: 0; }
.select-xs { min-height: 30px; padding: 0 26px 0 8px; font-size: var(--fs-xs); max-width: 170px; }
.room-list { display: grid; grid-template-columns: 1fr; gap: var(--sp-3); }
@media (min-width: 700px) { .room-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.room-card { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); background: var(--c-surface); }
.room-card.is-full { border-color: var(--c-danger-border); }
.room-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.room-title { display: inline-flex; align-items: center; gap: 6px; }
.room-title .icon { color: var(--c-primary); }
.room-occupancy { font-size: var(--fs-sm); color: var(--c-text-2); display: inline-flex; align-items: center; gap: 6px; }
.room-members { margin-top: var(--sp-2); display: flex; flex-direction: column; gap: 4px; }
.room-members li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); padding: 4px 6px; border-radius: 8px; font-size: var(--fs-sm); flex-wrap: wrap; }
.room-members li.is-family { background: hsl(var(--party-hue, 150) 55% 95%); }
.room-member-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.room-member-actions { display: inline-flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; max-width: 100%; flex-wrap: wrap; }
.room-foot { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
.room-edit-form { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.room-edit-form .input { max-width: 220px; }
.room-edit-form .input-num { max-width: 80px; }
.input-sm { min-height: 36px; padding-top: 0; padding-bottom: 0; }
.rooming-print { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 900px) { .rooming-print { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rooming-room { break-inside: avoid; page-break-inside: avoid; }
.rooming-room-title { font-size: var(--fs-md); margin: 0 0 var(--sp-1); display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 4px; }
.rooming-room-meta { font-size: var(--fs-xs); color: #555; font-weight: 400; }
.rooming-empty { color: #777; font-size: var(--fs-sm); margin: 0; }
.rooming-table { margin-bottom: var(--sp-2); }
.rooming-table tr.is-family td:nth-child(4) { border-right: 5px solid hsl(var(--family-tone, 150) 50% 60%); }
.rooming-unassigned { margin-top: var(--sp-5); }

/* ---------- Print layout (manifest) ---------- */
body.print-page { background: #fff; color: #111; }
.print-toolbar { display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); position: sticky; top: 0; }
.print-wrap { padding: var(--sp-5) var(--sp-4); max-width: 1100px; margin: 0 auto; }
.manifest-head { display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; border-bottom: 2px solid #111; padding-bottom: var(--sp-3); margin-bottom: var(--sp-4); }
.manifest-title { font-size: var(--fs-xl); margin: 0 0 4px; }
.manifest-sub, .manifest-meta { font-size: var(--fs-sm); color: #333; }
.manifest-meta { text-align: left; }
.manifest-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manifest-table th, .manifest-table td { border: 1px solid #999; padding: 6px 8px; text-align: right; vertical-align: middle; }
.manifest-table th { background: #eee; font-weight: 700; }
.manifest-table .col-seat { width: 56px; text-align: center; font-weight: 700; }
.manifest-table .col-no { width: 36px; text-align: center; color: #666; }
.manifest-table .col-check { width: 44px; text-align: center; }
.manifest-table tr.is-family td:nth-child(5) { border-right: 5px solid hsl(var(--family-tone, 150) 50% 60%); }
.checkbox-print { display: inline-block; width: 16px; height: 16px; border: 1.5px solid #333; border-radius: 3px; }
.manifest-foot { font-size: var(--fs-xs); color: #555; margin-top: var(--sp-3); }
@media print {
  @page { size: A4; margin: 12mm; }
  body.print-page { font-size: 12px; }
  .print-toolbar { display: none; }
  .print-wrap { padding: 0; max-width: none; }
  .manifest-table { font-size: 11.5px; }
  .manifest-table th, .manifest-table td { padding: 4px 6px; }
  .manifest-table thead { display: table-header-group; }
  .manifest-table tr { page-break-inside: avoid; }
  .manifest-table tr.is-family td:nth-child(5), .rooming-table tr.is-family td:nth-child(4) { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rooming-print { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6mm; }
}

/* ---------- Jalali datepicker theming ---------- */
.jdp-container { font-family: var(--font-sans) !important; }

/* ---------- Offline banner ---------- */
.offline-banner { background: var(--c-warning-bg); color: var(--c-warning); border-bottom: 1px solid var(--c-warning-border); padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--sp-2); justify-content: center; }

/* ---------- Auth layout ---------- */
.auth-body { background: radial-gradient(1200px 600px at 50% -10%, var(--c-primary-100), transparent), var(--c-bg); }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--sp-6) var(--sp-4); padding-top: max(var(--sp-6), var(--safe-top)); padding-bottom: max(var(--sp-6), var(--safe-bottom)); }
.auth-card { width: 100%; max-width: 420px; background: var(--c-surface); border-radius: var(--r-xl); box-shadow: var(--sh-md); border: 1px solid var(--c-border); padding: var(--sp-6) var(--sp-5); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; margin-bottom: var(--sp-6); }
.auth-brand .brand-mark { width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--c-primary); color: #fff; display: grid; place-items: center; box-shadow: var(--sh-md); }
.auth-brand .brand-mark .icon { width: 30px; height: 30px; stroke-width: 1.75; }
.auth-brand h1 { font-size: var(--fs-lg); }
.auth-brand p { color: var(--c-text-muted); font-size: var(--fs-sm); margin: 0; }
.auth-card .form-actions .btn { flex: 1 1 100%; }
.auth-foot { margin-top: var(--sp-5); text-align: center; color: var(--c-text-muted); font-size: var(--fs-xs); }
@media (min-width: 768px) { .auth-card { padding: var(--sp-8) var(--sp-8); } }

/* ---------- Plain pages (errors, offline, installer) ---------- */
.plain-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--sp-6) var(--sp-4); }
.plain-card { width: 100%; max-width: 520px; background: var(--c-surface); border-radius: var(--r-xl); box-shadow: var(--sh-md); border: 1px solid var(--c-border); padding: var(--sp-8) var(--sp-5); text-align: center; }
.plain-card .plain-icon { width: 64px; height: 64px; border-radius: var(--r-full); background: var(--c-primary-50); color: var(--c-primary); display: grid; place-items: center; margin: 0 auto var(--sp-4); }
.plain-card .plain-icon.is-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.plain-card .plain-icon.is-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.plain-card h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
.plain-card p { color: var(--c-text-2); }
.plain-card .actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; margin-top: var(--sp-5); }
.plain-card .debug { text-align: left; direction: ltr; font-size: 12px; background: #1f2937; color: #e5e7eb; border-radius: var(--r-md); padding: var(--sp-3); overflow: auto; max-height: 50vh; margin-top: var(--sp-4); white-space: pre-wrap; }

/* ---------- Installer ---------- */
.installer-wrap { max-width: 720px; margin: 0 auto; padding: var(--sp-6) var(--sp-4) var(--sp-12); }
.installer-head { text-align: center; margin-bottom: var(--sp-6); }
.installer-head .brand-mark { width: 52px; height: 52px; border-radius: var(--r-lg); background: var(--c-primary); color: #fff; display: grid; place-items: center; margin: 0 auto var(--sp-3); }
.installer-head .brand-mark .icon { width: 28px; height: 28px; }
.steps { display: flex; justify-content: space-between; gap: var(--sp-1); margin: var(--sp-5) 0; counter-reset: step; }
.steps .step { flex: 1; text-align: center; font-size: var(--fs-xs); color: var(--c-text-muted); position: relative; padding-top: 32px; }
.steps .step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; background: var(--c-surface); border: 2px solid var(--c-border-strong); display: grid; place-items: center; font-weight: 700; color: var(--c-text-2); font-size: 12px; }
.steps .step.is-done::before { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.steps .step.is-current { color: var(--c-primary); font-weight: 700; }
.steps .step.is-current::before { border-color: var(--c-primary); color: var(--c-primary); }
.check-list { display: flex; flex-direction: column; }
.check-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); }
.check-row:last-child { border-bottom: 0; }
.check-row .check-main { flex: 1; min-width: 0; }
.check-row .check-title { font-weight: 500; }
.check-row .check-detail { font-size: var(--fs-xs); color: var(--c-text-muted); }
.check-row .icon { width: 20px; height: 20px; }
.check-ok .icon { color: var(--c-success); }
.check-fail .icon { color: var(--c-danger); }
.check-warn .icon { color: var(--c-warning); }
.code-block { direction: ltr; text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #0f172a; color: #e2e8f0; padding: var(--sp-3); border-radius: var(--r-md); overflow: auto; white-space: pre; }

/* ---------- Gate mode (phase 7): full-screen, phone-first check-in ---------- */
.layout-gate { background: var(--c-bg); }
.gate-bar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--sp-2); height: var(--topbar-h); padding: 0 var(--sp-2); padding-top: var(--safe-top); padding-left: calc(var(--sp-2) + var(--safe-left)); padding-right: calc(var(--sp-2) + var(--safe-right)); box-sizing: content-box; background: var(--c-primary-800); color: #fff; }
.gate-bar .icon-btn { color: #fff; }
.gate-bar .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.gate-bar-title { flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gate-progress { display: inline-flex; align-items: baseline; gap: 4px; padding: 0 var(--sp-3); height: 32px; border-radius: var(--r-full); background: rgba(255, 255, 255, 0.14); font-weight: 700; direction: ltr; line-height: 32px; }
.gate-progress-num { font-size: var(--fs-lg); }
.gate-progress-sep { opacity: 0.7; }
.gate-meter { height: 6px; background: var(--c-primary-900); }
.gate-meter-fill { height: 100%; background: #5eead4; transition: width 250ms ease; }
.layout-gate { --bar-offset: calc(var(--tabbar-h) + var(--safe-bottom)); }
.gate-main { padding: var(--sp-4) calc(var(--sp-4) + var(--safe-right)) calc(var(--sp-8) + var(--bar-offset)) calc(var(--sp-4) + var(--safe-left)); max-width: 720px; margin: 0 auto; }
.gate-stack { display: flex; flex-direction: column; gap: var(--sp-6); }
.gate-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.gate-heading { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); }
.gate-heading .icon { color: var(--c-primary); width: 20px; height: 20px; }
.gate-hint { color: var(--c-text-muted); font-size: var(--fs-sm); margin: 0; }
.gate-origin { display: flex; align-items: center; gap: var(--sp-1); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; margin-top: var(--sp-1); }
.gate-choices { display: flex; flex-direction: column; gap: var(--sp-2); }
.gate-choice { display: flex; align-items: center; gap: var(--sp-3); min-height: 68px; padding: var(--sp-3) var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); color: var(--c-text); transition: border-color var(--ease), box-shadow var(--ease); }
.gate-choice:hover, .gate-choice:focus-visible { border-color: var(--c-primary); box-shadow: var(--sh-md); color: var(--c-text); }
.gate-choice:active { transform: scale(0.99); }
.gate-choice-icon { width: 44px; height: 44px; border-radius: var(--r-md); background: var(--c-primary-50); color: var(--c-primary); display: grid; place-items: center; flex: 0 0 auto; }
.gate-choice-icon .icon { width: 22px; height: 22px; }
.gate-choice-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gate-choice-title { font-weight: 700; font-size: var(--fs-md); }
.gate-choice-sub { color: var(--c-text-muted); font-size: var(--fs-xs); }
.gate-choice-main .capacity-meter { display: block; margin-top: 4px; }
.gate-choice-main .capacity-fill { display: block; }
.gate-choice-count { font-weight: 700; font-size: var(--fs-xl); color: var(--c-primary); direction: ltr; white-space: nowrap; }
.gate-choice-of { font-size: var(--fs-sm); color: var(--c-text-muted); font-weight: 500; }
.gate-choice.is-complete .gate-choice-icon { background: var(--c-success-bg); color: var(--c-success); }
.gate-choice.is-complete .gate-choice-count { color: var(--c-success); }
.gate-choice-primary { border-color: var(--c-primary-200); }
.gate-links { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.gate-tools { position: sticky; top: calc(var(--topbar-h) + var(--safe-top) + 6px); z-index: 30; background: var(--c-bg); padding: var(--sp-1) 0 var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.gate-search { position: relative; display: flex; align-items: center; }
.gate-search > .icon { position: absolute; right: 14px; color: var(--c-text-muted); pointer-events: none; }
.gate-search-input { width: 100%; min-height: 46px; padding: 0 42px; border: 1px solid var(--c-border-strong); border-radius: var(--r-lg); background: var(--c-surface); font-size: var(--fs-input); box-shadow: var(--sh-sm); -webkit-appearance: none; appearance: none; }
.gate-search-input:focus { outline: 3px solid var(--c-primary-200); border-color: var(--c-primary); }
.gate-search-input::-webkit-search-cancel-button { display: none; }
.gate-search-clear { position: absolute; left: 5px; width: 36px; height: 36px; border: 0; background: transparent; border-radius: var(--r-md); color: var(--c-text-muted); display: grid; place-items: center; }
.gate-search-clear:hover { background: var(--c-surface-2); color: var(--c-text); }
.gate-filters { display: flex; gap: var(--sp-1); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-full); padding: 3px; }
.gate-filter { flex: 1; min-height: 36px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 var(--sp-2); }
.gate-filter.is-active { background: var(--c-primary); color: #fff; }
.gate-filter-n { font-weight: 700; direction: ltr; }
.gate-people { display: flex; flex-direction: column; gap: var(--sp-2); }
.gate-person { position: relative; display: flex; align-items: stretch; gap: var(--sp-1); }
.gate-tap { flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; gap: var(--sp-3); text-align: right; padding: var(--sp-2) var(--sp-3); background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); transition: background 120ms ease, border-color 120ms ease, transform 80ms ease; -webkit-tap-highlight-color: transparent; }
.gate-tap:active { transform: scale(0.99); }
.gate-badge { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--r-md); background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); }
.gate-seat { font-weight: 700; font-size: var(--fs-lg); direction: ltr; }
.gate-seat.is-none { color: var(--c-text-muted); font-weight: 500; }
.gate-person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gate-person-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.5; overflow-wrap: anywhere; }
.gate-person-sub { color: var(--c-text-muted); font-size: var(--fs-xs); line-height: 1.6; }
.gate-tag { display: inline-block; padding: 0 6px; border-radius: var(--r-full); background: var(--c-info-bg); color: var(--c-info); border: 1px solid var(--c-info-border); font-size: 10.5px; line-height: 1.7; }
.gate-sms-tag { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-border); }
.gate-state { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 48px; }
.gate-state-icon { width: 32px; height: 32px; border-radius: var(--r-full); border: 2px solid var(--c-border-strong); display: grid; place-items: center; color: transparent; transition: background 120ms ease, border-color 120ms ease, color 120ms ease; }
.gate-state-icon .icon { width: 18px; height: 18px; stroke-width: 3; }
.gate-state-time { font-size: 10.5px; color: var(--c-success); font-weight: 700; direction: ltr; min-height: 14px; line-height: 14px; }
.gate-person.is-checked .gate-tap { background: var(--c-success-bg); border-color: var(--c-success-border); }
.gate-person.is-checked .gate-state-icon { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.gate-person.is-checked .gate-badge { background: #fff; }
.gate-person.is-busy .gate-tap { opacity: 0.75; }
.gate-undo { flex: 0 0 auto; width: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 2px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-xs); font-weight: 500; }
.gate-undo:hover { border-color: var(--c-danger-border); color: var(--c-danger); background: var(--c-danger-bg); }
.gate-toast { position: fixed; bottom: calc(var(--sp-4) + var(--bar-offset)); left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-full); background: var(--c-text); color: #fff; font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--sh-lg); text-align: center; }
.gate-toast.is-ok { background: var(--c-success); }
.gate-toast.is-undo { background: var(--c-warning); }
.gate-toast.is-error { background: var(--c-danger); }
.gate-toast.is-info { background: var(--c-info); }
/* Confirmation sheet (1.9.1): bottom sheet on phones, centred dialog from 640px; above the tab bar and the toast. */
.gate-confirm { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center; }
.gate-confirm[hidden] { display: none; }
.gate-confirm-backdrop { position: absolute; inset: 0; background: rgba(15, 47, 43, 0.45); }
.gate-confirm-sheet { position: relative; width: 100%; max-width: 480px; background: var(--c-surface); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + var(--safe-bottom)); box-shadow: var(--sh-lg); text-align: center; animation: gate-sheet-in 160ms ease-out; }
.gate-confirm-icon { width: 52px; height: 52px; margin: 0 auto var(--sp-3); border-radius: var(--r-full); display: grid; place-items: center; background: var(--c-primary-50); color: var(--c-primary); }
.gate-confirm-icon .icon { width: 26px; height: 26px; }
.gate-confirm.is-undo .gate-confirm-icon { background: var(--c-danger-100); color: var(--c-danger); }
.gate-confirm-title { margin: 0 0 var(--sp-1); font-size: var(--fs-lg); font-weight: 700; }
.gate-confirm-text { margin: 0 0 var(--sp-4); color: var(--c-text-2); font-size: var(--fs-md); line-height: 1.8; overflow-wrap: anywhere; }
.gate-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.gate-confirm-actions .btn { width: 100%; }
body.gate-confirm-open { overflow: hidden; }
@keyframes gate-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .gate-confirm { align-items: center; padding: var(--sp-4); }
  .gate-confirm-sheet { border-radius: var(--r-xl); padding-bottom: var(--sp-4); }
}
@media (prefers-reduced-motion: reduce) { .gate-confirm-sheet { animation: none; } }
@media (min-width: 1024px) {
  /* Desktop: the gate sits beside the fixed sidebar like every other admin page; no tab bar. */
  .layout-gate { --bar-offset: var(--safe-bottom); }
  .layout-gate .gate-shell { margin-right: var(--sidebar-w); }
}
@media (min-width: 768px) {
  .gate-main { padding-left: var(--sp-6); padding-right: var(--sp-6); }
  .gate-choices { display: grid; grid-template-columns: 1fr 1fr; }
  .gate-choice-primary { grid-column: 1 / -1; }
}
/* ---------- Party ledger (phase 10): charges vs receipts, receipt list, receipt form ---------- */
.ledger-head { flex-wrap: wrap; }
.ledger-head-badges { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); margin-inline-start: auto; }
@media (max-width: 639.98px) { .ledger-head-badges { display: none; } } /* the kind cards below repeat them */
.ledger-kinds { display: grid; grid-template-columns: 1fr; gap: var(--sp-3); }
@media (min-width: 700px) { .ledger-kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ledger-kind { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); background: var(--c-surface); min-width: 0; }
.ledger-kind.is-na { background: var(--c-surface-2); }
.ledger-kind-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.ledger-kind-head .icon { color: var(--c-primary); }
.ledger-dl .dl-row { padding: var(--sp-2) 0; }
.ledger-dl dd { text-align: left; }
/* Per-person price lines (1.9.1): shown when a member has a personal tour price */
.ledger-dl .ledger-lines-row dd { flex: 1 0 100%; text-align: right; font-weight: 400; }
.ledger-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ledger-line { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-2); padding: 3px var(--sp-2); border-radius: var(--r-sm); background: var(--c-surface-2); }
.ledger-line.is-custom { background: var(--c-info-100); color: var(--c-info); }
.ledger-line-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-line-price { display: inline-flex; align-items: center; gap: 3px; font-weight: 500; white-space: nowrap; }
.ledger-line-price .icon { width: 11px; height: 11px; }
.ledger-balance { background: var(--c-surface-2); margin: 0 calc(-1 * var(--sp-3)); padding: var(--sp-2) var(--sp-3) !important; border-bottom: 0 !important; border-radius: 0 0 var(--r-md) var(--r-md); }
.ledger-balance dd strong { font-size: var(--fs-md); }
.ledger-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.ledger-total { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin-top: var(--sp-3); padding: var(--sp-3); background: var(--c-primary-50); border: 1px solid var(--c-primary-100); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--c-text-2); }
.ledger-total strong { color: var(--c-text); }
.ledger-note { display: flex; align-items: flex-start; gap: 6px; margin: var(--sp-3) 0 0; line-height: 1.7; }
.ledger-note .icon { flex: 0 0 auto; margin-top: 3px; }
.ledger-receipts { border-top: 1px solid var(--c-border); }
.ledger-receipts-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.ledger-receipts-head h3 { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-base); }
.ledger-list { display: flex; flex-direction: column; }
.ledger-row { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row.is-void { opacity: 0.55; }
.ledger-row.is-editing { background: var(--c-primary-50); margin: 0 calc(-1 * var(--sp-4)); padding-left: var(--sp-4); padding-right: var(--sp-4); }
.ledger-row-icon { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--c-surface-2); color: var(--c-text-2); display: grid; place-items: center; flex: 0 0 auto; }
.ledger-row-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; } /* basis 0: stays beside the icon when the row wraps on phones */
.ledger-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-2); }
.ledger-row-meta { display: flex; flex-wrap: wrap; gap: 4px var(--sp-3); font-size: var(--fs-xs); color: var(--c-text-muted); }
.ledger-row-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ledger-row-note { color: var(--c-text-2); }
.ledger-row-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.ledger-form summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; color: var(--c-primary-800); }
.ledger-form summary::-webkit-details-marker { display: none; }
.ledger-form[open] summary { border-bottom: 1px solid var(--c-border); border-radius: 0; }
.ledger-form .card-body { border-top: 0; }
@media (max-width: 479.98px) {
  .ledger-row { flex-wrap: wrap; }
  .ledger-row-actions { flex: 1 1 100%; justify-content: flex-start; padding-inline-start: 40px; }
}

/* ---------- Finance report (phase 10) ---------- */
.finance-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.finance .stat-row > span:first-child { min-width: 0; }
/* Bus-card fee actions (phase 10): long labels wrap instead of pushing the page wider on narrow phones. */
.bus-fee-actions .btn { white-space: normal; text-align: center; padding-top: var(--sp-2); padding-bottom: var(--sp-2); max-width: 100%; }
@media (min-width: 900px) { .finance-split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.finance-table td.is-amount, .finance-table th.is-amount { text-align: left; white-space: nowrap; }
.finance-print-title { display: none; }
.finance.is-print .finance-print-title { display: block; margin-bottom: var(--sp-3); }
.finance.is-print .finance-print-title h2 { font-size: var(--fs-lg); margin: 0 0 var(--sp-1); }
@media print {
  .finance-print-title { display: block; margin-bottom: var(--sp-3); }
  .finance-actions, .page-actions, .tabs { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
  .finance .grid-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finance-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-table { font-size: 11.5px; }
  .finance-table th, .finance-table td { padding: 4px 6px; }
  .finance-table thead { display: table-header-group; }
  .finance-table tr { page-break-inside: avoid; }
}

/* ---------- Dashboard hero (greeting, registration switch, tour line, public links with copy) ---------- */
.hero-card { background: linear-gradient(160deg, var(--c-primary-50) 0%, var(--c-surface) 45%); border-color: var(--c-primary-100); }
.hero-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.hero-greeting { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; flex: 1 1 240px; }
.hero-avatar { width: 46px; height: 46px; border-radius: var(--r-full); background: var(--c-primary); color: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: var(--sh-sm); }
.hero-avatar .icon { width: 22px; height: 22px; }
.hero-heading { min-width: 0; }
.hero-title { font-size: var(--fs-lg); line-height: 1.4; overflow-wrap: anywhere; }
.hero-date { display: flex; align-items: center; gap: 5px; margin: 3px 0 0; color: var(--c-text-muted); font-size: var(--fs-sm); }
.hero-toggle { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.hero-tour { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--c-primary-100); }
.hero-tour-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.hero-tour-name .icon { color: var(--c-primary); flex: 0 0 auto; }
.hero-tour-dates { display: inline-flex; align-items: center; gap: 5px; color: var(--c-text-2); font-size: var(--fs-sm); }
.hero-tour-dates .icon { color: var(--c-text-muted); }
.hero-tour-settings { margin-inline-start: auto; }
.hero-links { display: grid; grid-template-columns: 1fr; gap: var(--sp-2); margin-top: var(--sp-4); }
.hero-link { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-sm); min-width: 0; }
.hero-link-icon { width: 38px; height: 38px; border-radius: var(--r-md); background: var(--c-primary-50); color: var(--c-primary); display: grid; place-items: center; flex: 0 0 auto; }
.hero-link-main { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hero-link-label { font-size: var(--fs-xs); color: var(--c-text-2); font-weight: 500; }
.hero-link-hint { color: var(--c-text-muted); font-weight: 400; }
.hero-link-url { display: block; font-size: var(--fs-sm); color: var(--c-text); direction: ltr; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hero-link-url:hover { color: var(--c-primary); }
.hero-link-actions { display: flex; gap: var(--sp-2); flex: 0 0 auto; }
.hero-link-actions .btn.is-copied { background: var(--c-success); border-color: var(--c-success); color: #fff; }
@media (min-width: 900px) { .hero-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 479.98px) {
  .hero-toggle { flex: 1 1 100%; }
  .hero-toggle .btn { margin-inline-start: auto; }
  .hero-tour-settings { margin-inline-start: auto; }
  .hero-link-hint { display: none; }
  .hero-link-actions { flex: 1 1 100%; }
  .hero-link-actions .btn { flex: 1 1 0; }
}

/* ---------- Attendance reports + final dashboard (phase 7) ---------- */
.pb-0 { padding-bottom: 0 !important; }
.person-cell { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-border); font-size: var(--fs-sm); }
.stat-row:last-child { border-bottom: 0; }
.stat-row a { color: inherit; }
.stat-row a:hover { color: var(--c-primary); }
.stat-row .stat-row-value { font-weight: 700; white-space: nowrap; }
.stat-row .stat-row-value.is-danger { color: var(--c-danger); }
.stat-row .stat-row-value.is-warning { color: var(--c-warning); }
.stat-row .stat-row-value.is-success { color: var(--c-success); }
.sheet-table .col-check { width: 46px; text-align: center; }
.sheet-table .col-check .checkbox-print { margin: 0 auto; }
.sheet { break-after: page; page-break-after: always; margin-bottom: var(--sp-8); }
.sheet:last-child { break-after: auto; page-break-after: auto; margin-bottom: 0; }
.sheet-table .col-note { width: 110px; }
.sheet-table tr.is-family td.col-family { border-right: 5px solid hsl(var(--family-tone, 150) 50% 60%); }
.sheet-table td { height: 30px; }
@media print { .sheet-table tr.is-family td.col-family { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.h-inline { display: flex; align-items: center; gap: var(--sp-2); }

/* ---------- Bottom tab bar (phase 8, below 1024px) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--c-surface); border-top: 1px solid var(--c-border);
  box-shadow: 0 -4px 16px rgba(23, 33, 30, 0.06);
}
.tabbar-item {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 2px 4px; border: 0; background: transparent; color: var(--c-text-muted);
  font-size: 10.5px; font-weight: 400; line-height: 1.3; -webkit-tap-highlight-color: transparent;
  transition: color var(--ease);
}
.tabbar-item .icon { width: 20px; height: 20px; }
.tabbar-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbar-item.is-active { color: var(--c-primary); font-weight: 500; }
.tabbar-item:hover { color: var(--c-primary-800); }
.tabbar-item:focus-visible { outline-offset: -3px; }
body.sidebar-open .tabbar { pointer-events: none; }
@media (min-width: 1024px) { .tabbar { display: none; } }
@media print { .tabbar, .topbar, .sidebar { display: none !important; } .main { margin: 0; padding: 0; } }
/* ---------- Settings tab strip (phase 8): wraps instead of scrolling so every tab stays visible on phones ---------- */
.settings-tabs { flex-wrap: wrap; overflow: visible; }
.settings-tabs .tab { flex: 1 1 auto; justify-content: center; min-width: 0; }
.template-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-1); }
.template-head .field-label { margin-bottom: 0; }
.link-btn { border: 0; background: none; padding: 0; color: var(--c-primary); text-decoration: underline; text-underline-offset: 3px; font: inherit; font-size: inherit; cursor: pointer; }
.template-text { max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); color: var(--c-text-2); }
.custom-template-form { border-top: 1px solid var(--c-border); }