/* ==========================================================================
   Navaratri Pass Tracker
   Palette idea: kumkum crimson + marigold. Each theme uses one lead colour and
   one supporting colour; everything else is a tint of the same warm neutral.
   ========================================================================== */

:root {
  color-scheme: light;
  /* Light: kumkum crimson leads, marigold supports */
  --paper: #fbf6f5;
  --surface: #ffffff;
  --surface-2: #f7eeec;
  --line: #ecdedb;
  --line-strong: #d8c3bf;
  --ink: #2b1418;
  --ink-2: #5b4146;
  --muted: #7d6468;

  --p: #a3153a;
  --p-hover: #86102f;
  --p-ink: #ffffff;
  --p-soft: #fbe7ec;
  --p-text: #a3153a;

  --s: #e3a008;
  --s-soft: #fff1cd;
  --s-text: #7a5200;

  --danger: #7a0f29;
  --danger-soft: #fbe7ec;
  --focus: #a3153a;

  --side: #3a0b19;
  --side-ink: #f6e3e1;
  --side-muted: #c9a7ab;
  --side-hover: rgba(255, 255, 255, .08);
  --side-active: rgba(255, 255, 255, .13);
  --side-accent: #f3b72e;

  --shadow: 0 1px 2px rgba(58, 11, 25, .05), 0 6px 20px rgba(58, 11, 25, .05);
  --overlay: rgba(32, 8, 15, .55);
  --radius: 1rem;
  --radius-sm: .7rem;
  --nav-h: 4.5rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Dark: marigold leads, rose-crimson supports */
  --paper: #150b0f;
  --surface: #201218;
  --surface-2: #2a1a21;
  --line: #3a252d;
  --line-strong: #553843;
  --ink: #f8ece7;
  --ink-2: #d3bcb9;
  --muted: #ab9293;

  --p: #f5b93e;
  --p-hover: #ffcd62;
  --p-ink: #2a1a00;
  --p-soft: rgba(245, 185, 62, .15);
  --p-text: #f5b93e;

  --s: #ee5a82;
  --s-soft: rgba(238, 90, 130, .17);
  --s-text: #ff93ae;

  --danger: #ee5a82;
  --danger-soft: rgba(238, 90, 130, .17);
  --focus: #f5b93e;

  --side: #1b0f14;
  --side-ink: #f8ece7;
  --side-muted: #a98f91;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(245, 185, 62, .15);
  --side-accent: #f5b93e;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .28);
  --overlay: rgba(0, 0, 0, .66);
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 1440px) {
  html {
    font-size: 17px;
  }
}

@media (min-width: 1920px) {
  html {
    font-size: 18px;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Figtree", "Noto Sans Gujarati", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

body.modal-open {
  overflow: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  min-width: 0;
}

button {
  cursor: pointer;
}

h1, h2 {
  font-family: "Bricolage Grotesque", "Figtree", "Noto Sans Gujarati", system-ui, sans-serif;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Shell ---------- */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: 16rem;
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--side);
  color: var(--side-ink);
  padding: 1.75rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 .5rem;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .85rem;
  background: var(--side-accent);
  color: #2a0a12;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark .icon {
  width: 1.6rem;
  height: 1.6rem;
}

.brand strong {
  font: 800 1.25rem/1.1 "Bricolage Grotesque", sans-serif;
  letter-spacing: -.02em;
  display: block;
}

.brand small {
  display: block;
  color: var(--side-muted);
  font-size: .85rem;
  margin-top: .15rem;
}

.nav-list {
  display: grid;
  gap: .3rem;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--side-muted);
  text-align: left;
  padding: .85rem .95rem;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 3rem;
  transition: background-color .15s, color .15s;
}

.nav-item:hover {
  background: var(--side-hover);
  color: var(--side-ink);
}

.nav-item.active {
  background: var(--side-active);
  color: var(--side-ink);
  box-shadow: inset 3px 0 var(--side-accent);
}

.nav-item.active .icon {
  color: var(--side-accent);
}

.nav-item:focus-visible, .side-add:focus-visible {
  outline-color: var(--side-accent);
}

.side-add {
  margin: 0 .25rem;
  background: var(--side-accent);
  color: #2a0a12;
}

.side-add:hover {
  background: #fff;
}

.sidebar-bottom {
  margin-top: auto;
}

.event-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--side-hover);
  border-radius: .8rem;
  padding: .9rem .85rem;
}

.live-dot {
  width: .6rem;
  height: .6rem;
  background: var(--side-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 .3rem rgba(255, 255, 255, .1);
  flex-shrink: 0;
}

.event-chip strong {
  font-size: .95rem;
  display: block;
}

.event-chip small {
  display: block;
  color: var(--side-muted);
  font-size: .82rem;
  margin-top: .15rem;
}

.main {
  margin-left: 16rem;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 4.5rem;
  padding: 0 2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.m-brand {
  display: none;
}

.m-brand .brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: .7rem;
  background: var(--p);
  color: var(--p-ink);
}

.breadcrumbs {
  display: flex;
  gap: .6rem;
  align-items: center;
  font-size: .95rem;
  color: var(--muted);
  margin-right: auto;
  min-width: 0;
}

.breadcrumbs b {
  font-weight: 400;
  color: var(--line-strong);
}

.breadcrumbs strong {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.today-label {
  font-size: .95rem;
  color: var(--muted);
}

.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--p-soft);
  color: var(--p-text);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .8rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: background-color .15s, color .15s, border-color .15s;
}

.icon-button:hover {
  background: var(--p-soft);
  color: var(--p-text);
  border-color: var(--line-strong);
}

/* ---------- Pages ---------- */
.page {
  display: none;
  padding: 2.25rem 2rem 3.5rem;
  max-width: 96rem;
  margin: auto;
}

.page.active {
  display: block;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.page h1 {
  font-weight: 800;
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -.025em;
  margin: 0;
}

/* Bandhani-dot strip: the one decorative flourish */
.page h1::after {
  content: "";
  display: block;
  width: 6.5rem;
  height: .5rem;
  margin-top: .7rem;
  background: radial-gradient(circle at 50% 50%, var(--p) 0 1.7px, transparent 2.2px) 0 0 / .93rem .5rem repeat-x;
}

.page-heading p {
  margin: .6rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 40rem;
}

label {
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink-2);
}

.date-control {
  display: grid;
  gap: .4rem;
  min-width: 11rem;
}

input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: .7rem .85rem;
  min-height: 3rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input::placeholder, textarea::placeholder {
  color: var(--muted);
  opacity: .85;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px var(--p-soft);
}

textarea {
  resize: vertical;
  min-height: 5.5rem;
  line-height: 1.45;
}

/* ---------- Cards, stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1.25rem 1.35rem;
  min-width: 0;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-2);
  font-size: .95rem;
  font-weight: 600;
  gap: .5rem;
}

.stat-icon, .report-icon {
  border-radius: .75rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
}

.tone-a {
  background: var(--p-soft);
  color: var(--p-text);
}

.tone-b {
  background: var(--s-soft);
  color: var(--s-text);
}

.stat-value {
  font: 800 2.4rem/1.15 "Bricolage Grotesque", sans-serif;
  letter-spacing: -.03em;
  margin: .8rem 0 .2rem;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: .9rem;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel {
  padding: 1.5rem;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.3rem;
}

.panel-heading h2, .report-card h2, .settings-section-head h2 {
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.25;
  letter-spacing: -.015em;
  margin: 0;
}

.panel-heading p, .settings-section-head p {
  font-size: .95rem;
  color: var(--muted);
  margin: .3rem 0 0;
}

.soft-tag {
  font-size: .8rem;
  font-weight: 700;
  color: var(--p-text);
  background: var(--p-soft);
  padding: .35rem .7rem;
  border-radius: 999px;
  white-space: nowrap;
}

.inventory-visual {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: .25rem;
}

.ring {
  --pct: 0%;
  width: 10.5rem;
  height: 10.5rem;
  border-radius: 50%;
  background: conic-gradient(var(--p) var(--pct), var(--surface-2) 0);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  transition: background .3s;
}

.ring::before {
  content: "";
  position: absolute;
  inset: .85rem;
  background: var(--surface);
  border-radius: 50%;
}

.ring-inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: .1rem;
}

.ring-inner strong {
  font: 800 2.1rem/1 "Bricolage Grotesque", sans-serif;
  letter-spacing: -.03em;
}

.ring-inner span {
  font-size: .9rem;
  color: var(--muted);
}

.inventory-details {
  flex: 1;
  min-width: 0;
}

.big-count {
  display: grid;
  gap: .1rem;
  margin-bottom: 1rem;
}

.big-count strong {
  font: 800 2.2rem/1.1 "Bricolage Grotesque", sans-serif;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.big-count span {
  font-size: .95rem;
  color: var(--muted);
}

.legend-row {
  display: grid;
  grid-template-columns: .7rem 1fr auto;
  align-items: center;
  gap: .6rem;
  margin: .6rem 0;
  font-size: .95rem;
  color: var(--ink-2);
}

.legend-row b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.legend-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  display: inline-block;
}

.allocated-dot, .present-dot {
  background: var(--p);
}

.available-dot {
  background: var(--line-strong);
}

.absent-dot {
  background: var(--s);
}

.unmarked-dot {
  background: var(--line-strong);
}

.text-button {
  border: 0;
  background: none;
  padding: .6rem 0 0;
  color: var(--p-text);
  font-weight: 700;
  font-size: .95rem;
  min-height: 2.75rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inventory-warning {
  margin-top: .9rem;
  background: var(--s-soft);
  color: var(--s-text);
  padding: .75rem .9rem;
  border-radius: .6rem;
  font-size: .95rem;
  font-weight: 500;
}

.attendance-total {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin: .4rem 0 1.1rem;
}

.attendance-total strong {
  font: 800 2.4rem/1 "Bricolage Grotesque", sans-serif;
  letter-spacing: -.03em;
}

.attendance-total span {
  font-size: .95rem;
  color: var(--muted);
}

.attendance-bar {
  display: flex;
  gap: 3px;
  height: .65rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.attendance-bar div {
  height: 100%;
  width: 0;
  transition: width .3s;
}

#presentBar {
  background: var(--p);
}

#absentBar {
  background: var(--s);
}

#unmarkedBar {
  background: var(--line-strong);
}

.attendance-breakdown {
  display: grid;
  gap: .85rem;
  margin-top: 1.4rem;
}

.attendance-breakdown>div {
  display: grid;
  grid-template-columns: .7rem 1fr auto;
  gap: .6rem;
  align-items: center;
  color: var(--ink-2);
  font-size: .95rem;
}

.attendance-breakdown b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.recent-panel, .table-panel {
  padding: 0;
  overflow: hidden;
}

.recent-panel .panel-heading {
  padding: 1.4rem 1.5rem 0;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border-radius: var(--radius-sm);
  padding: .7rem 1.2rem;
  min-height: 3rem;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 700;
  transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}

.button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.button-primary {
  background: var(--p);
  color: var(--p-ink);
}

.button-primary:hover:not(:disabled) {
  background: var(--p-hover);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .button-danger {
  color: #2a0612;
}

.button-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.button-ghost-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding-inline: .8rem;
}

.button-ghost-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.button-small {
  min-height: 2.75rem;
  padding: .5rem .95rem;
  font-size: .95rem;
}

.button .spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
}

thead {
  background: var(--surface-2);
}

th {
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  padding: .85rem .75rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  font-size: 1rem;
  padding: .95rem .75rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}

th:first-child, td:first-child {
  padding-left: 1.25rem;
}

th:last-child, td:last-child {
  padding-right: 1.25rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* Remark takes whatever width is left and truncates; the short columns never wrap. */
.data-table td.c-remark {
  width: 100%;
  max-width: 0;
  min-width: 6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table td.c-sr, .data-table td.c-status, .data-table td.c-att, .data-table td.c-qty, .data-table td.c-time .when {
  white-space: nowrap;
}

.data-table td.c-party {
  min-width: 9.5rem;
}

.entry-row {
  cursor: pointer;
  transition: background-color .12s;
}

.entry-row:hover {
  background: var(--p-soft);
}

.entry-row:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
  border-radius: 0;
}

.sr {
  font-weight: 700;
  color: var(--p-text);
  font-variant-numeric: tabular-nums;
}

.c-qty strong {
  font-size: 1.1rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.party-cell strong {
  display: block;
  color: var(--ink);
  font-size: 1.02rem;
}

.party-cell small {
  display: block;
  color: var(--muted);
  margin-top: .15rem;
  font-size: .9rem;
}

.sub-date {
  color: var(--muted);
  font-size: .88rem;
  margin-top: .1rem;
}

.when {
  color: var(--ink);
}

.state {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  display: grid;
  justify-items: center;
  gap: .85rem;
}

.state strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.state p {
  margin: 0;
  max-width: 28rem;
}

.state-error .state-icon {
  color: var(--danger);
}

.state .icon {
  width: 2rem;
  height: 2rem;
}

.state-row:hover {
  background: transparent;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border-radius: 999px;
  padding: .3rem .75rem;
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: currentColor;
}

.pill-sent, .pill-present {
  background: var(--p-soft);
  color: var(--p-text);
}

.pill-pending {
  background: var(--s-soft);
  color: var(--s-text);
}

.pill-absent {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

.pill-absent::before {
  background: transparent;
  box-shadow: inset 0 0 0 2px currentColor;
}

.pill-unmarked {
  background: var(--surface-2);
  color: var(--muted);
}

.action-buttons {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
}

.mini-action {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: .6rem;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  padding: 0;
}

.mini-action .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.mini-action:hover {
  background: var(--p-soft);
  color: var(--p-text);
}

.mini-action.delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---------- Filters & summary ---------- */
.entry-summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}

.summary-chip {
  display: inline-flex;
  gap: .45rem;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .55rem .85rem;
  color: var(--muted);
  font-size: .92rem;
}

.summary-chip strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.summary-chip:first-child {
  background: var(--p-soft);
  border-color: transparent;
}

.filters {
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.search-box {
  display: flex;
  align-items: center;
  gap: .6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 .85rem;
  min-width: 18rem;
  flex: 1;
  max-width: 26rem;
  background: var(--surface);
  min-height: 3rem;
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--p);
  box-shadow: 0 0 0 3px var(--p-soft);
}

.search-box input {
  border: 0 !important;
  box-shadow: none !important;
  outline: 0;
  padding: 0;
  min-height: 2.8rem;
  background: transparent;
}

.filter-controls {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
}

.filter-field {
  display: grid;
  gap: .3rem;
  min-width: 10rem;
}

.filter-field label {
  font-size: .85rem;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  font-size: .9rem;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ---------- Reports ---------- */
.report-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.report-card {
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.report-icon {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1.1rem;
}

.report-card p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: .5rem 0 1.4rem;
}

.report-card .field {
  width: 100%;
  margin-top: auto;
  margin-bottom: 1rem;
}

.date-range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  width: 100%;
  margin-top: auto;
  margin-bottom: 1rem;
}

.full-button {
  width: 100%;
  margin-top: auto;
}

.report-includes {
  display: grid;
  gap: .6rem;
  color: var(--ink-2);
  font-size: 1rem;
  margin: 0 0 1.25rem;
}

.report-includes span {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.report-includes .icon {
  color: var(--p-text);
  width: 1.1rem;
  height: 1.1rem;
}

.report-note {
  padding: 1.1rem 1.3rem;
  background: var(--p-soft);
  border-radius: .9rem;
  margin-top: 1.25rem;
}

.report-note strong {
  color: var(--ink);
}

.report-note p {
  font-size: .97rem;
  line-height: 1.6;
  margin: .35rem 0 0;
  color: var(--ink-2);
}

/* ---------- Settings ---------- */
.settings-panel {
  padding: 1.6rem;
  margin-bottom: 1.25rem;
}

.settings-section-head {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: 1.4rem;
}

.settings-icon {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: .8rem;
  background: var(--p-soft);
  color: var(--p-text);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  max-width: 52rem;
}

.settings-actions {
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.rules-list {
  padding-left: 1.3rem;
  margin: 0;
  color: var(--ink-2);
  line-height: 1.9;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: .3rem;
  padding: .3rem;
  background: var(--surface-2);
  border-radius: .9rem;
  max-width: 100%;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: .65rem;
  padding: .65rem 1.2rem;
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  font-weight: 700;
  color: var(--ink-2);
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button[aria-checked="true"] {
  background: var(--p);
  color: var(--p-ink);
  box-shadow: var(--shadow);
}

/* ---------- Forms ---------- */
.field {
  display: grid;
  gap: .4rem;
  min-width: 0;
  align-content: start;
}

.field em {
  font-style: normal;
  color: var(--danger);
}

.field small {
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.45;
}

.field-error {
  display: none;
  color: var(--danger) !important;
  font-weight: 600;
}

.field.has-error .field-error {
  display: block;
}

.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.form-alert {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  background: var(--danger-soft);
  color: var(--ink);
  border: 1px solid var(--danger);
  border-radius: .8rem;
  padding: .8rem 1rem;
  margin-bottom: 1.1rem;
  font-size: .97rem;
  font-weight: 500;
}

.form-alert[hidden] {
  display: none;
}

.form-alert .icon {
  color: var(--danger);
  margin-top: .1rem;
}

.form-hint {
  font-size: .9rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.field-full {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  gap: .6rem;
}

/* ---------- Modal (pop-up on desktop, bottom sheet on mobile) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in .18s ease-out;
}

.modal-backdrop[hidden] {
  display: none;
}

.form-panel {
  width: min(100%, 44rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
  animation: pop-in .2s ease-out;
}

.form-panel .panel-heading {
  align-items: center;
  padding: 1.25rem 1.5rem;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.form-panel form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal-body {
  overflow-y: auto;
  padding: 1.5rem;
  overscroll-behavior: contain;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.form-footer .form-hint {
  margin-right: auto;
}

.form-footer #deleteFromForm:not([hidden])+.form-hint {
  display: none;
}

.confirm-modal {
  width: min(100%, 25rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1.75rem;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
  animation: pop-in .2s ease-out;
}

.confirm-symbol {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
}

.confirm-modal h2 {
  font-weight: 800;
  font-size: 1.35rem;
  margin: 0;
}

.confirm-modal p {
  color: var(--muted);
  line-height: 1.6;
  margin: .6rem 0 1.4rem;
}

.confirm-modal .form-alert {
  text-align: left;
}

.confirm-modal .button-row {
  justify-content: center;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }

  to {
    transform: none;
  }
}

/* ---------- Toasts & offline banner ---------- */
.toast-region {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 100;
  display: grid;
  gap: .6rem;
  justify-items: end;
  pointer-events: none;
  width: min(26rem, calc(100vw - 2rem));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border-radius: .9rem;
  padding: .9rem 1rem;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .3);
  font-size: .98rem;
  font-weight: 500;
  animation: pop-in .2s ease-out;
}

.toast .icon {
  margin-top: .1rem;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .toast.error {
  color: #2a0612;
}

.toast-text {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}

.toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: .8;
  padding: .1rem;
  border-radius: 6px;
  display: grid;
}

.toast-close:hover {
  opacity: 1;
}

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  background: var(--s);
  color: #2a1a00;
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .95rem;
  text-align: center;
}

:root[data-theme="dark"] .offline-banner {
  color: #2a0612;
}

.offline-banner[hidden] {
  display: none;
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .page {
    padding: 2rem 1.5rem 3rem;
  }

  .topbar {
    padding: 0 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-card:last-child {
    grid-column: 1 / -1;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    max-width: none;
  }
}

@media (max-width: 1280px) {
  .entries-table th:nth-child(7), .entries-table td.c-remark {
    display: none;
  }
}

@media (max-width: 1100px) {
  .entries-table th:nth-child(2), .entries-table td.c-time {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    height: 4rem;
    padding: 0 1rem;
  }

  .m-brand {
    display: block;
  }

  .crumb-root, .crumb-sep, .today-label {
    display: none;
  }

  .breadcrumbs strong {
    font: 700 1.2rem "Bricolage Grotesque", sans-serif;
  }

  .page {
    padding: 1.5rem 1rem 2rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #newEntryButton {
    display: none;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding: .4rem .5rem env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px rgba(58, 11, 25, .07);
  }

  :root[data-theme="dark"] .bottom-nav {
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .4);
  }

  .bn-item {
    border: 0;
    background: none;
    color: var(--muted);
    height: 100%;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: .15rem;
    font-size: .76rem;
    font-weight: 700;
    border-radius: .8rem;
    padding: .25rem 0;
    min-width: 0;
  }

  .bn-item .icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .bn-item.active {
    color: var(--p-text);
  }

  .bn-item.active .icon {
    background: var(--p-soft);
    border-radius: 999px;
    box-sizing: content-box;
    padding: .2rem 1rem;
  }

  .bn-add {
    justify-self: center;
    align-self: start;
    margin-top: -1.1rem;
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 50%;
    border: 4px solid var(--surface);
    background: var(--p);
    color: var(--p-ink);
    display: grid;
    place-items: center;
    padding: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  }

  .bn-add .icon {
    width: 1.7rem;
    height: 1.7rem;
  }

  .bn-add:active {
    transform: scale(.95);
  }

  .toast-region {
    right: 1rem;
    left: 1rem;
    width: auto;
    justify-items: stretch;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 1.25rem);
  }
}

/* Entries / recent tables become tap-friendly cards on phones */
@media (max-width: 760px) {
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .data-table, .data-table tbody {
    display: block;
  }

  .data-table tr.entry-row {
    display: grid;
    grid-template-columns: 2.6rem auto minmax(0, 1fr) auto;
    gap: .5rem .6rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
  }

  .data-table tr.entry-row:last-child {
    border-bottom: 0;
  }

  .data-table tr.entry-row td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .data-table tr.entry-row:active {
    background: var(--p-soft);
  }

  .c-sr {
    grid-column: 1;
    grid-row: 1;
  }

  .c-party {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .c-party strong, .c-party small {
    overflow-wrap: anywhere;
  }

  .c-qty {
    grid-column: 4;
    grid-row: 1;
    text-align: right;
    white-space: nowrap;
  }

  .c-qty strong::after {
    content: " passes";
    font-size: .85rem;
    font-weight: 500;
    color: var(--muted);
  }

  .c-status {
    grid-column: 2;
    grid-row: 2;
  }

  .c-att {
    grid-column: 3;
    grid-row: 2;
    justify-self: start;
  }

  /* The whole card is tappable and Delete lives inside the edit pop-up, so the row buttons are hidden here. */
  .c-actions {
    display: none !important;
  }

  .c-phone, .c-remark {
    grid-column: 2 / -1;
    grid-row: 3;
    color: var(--ink-2);
    overflow-wrap: anywhere;
  }

  .data-table tr.entry-row td.c-remark {
    display: block;
    width: auto;
    max-width: none;
    white-space: normal;
  }

  .data-table tr.entry-row td.c-time {
    display: block;
  }

  .data-table tr.entry-row td.c-remark.is-empty {
    display: none;
  }

  .c-time {
    grid-column: 2 / -1;
    grid-row: 4;
    font-size: .88rem;
    color: var(--muted);
  }

  .c-time .sub-date {
    display: inline;
    margin-left: .4rem;
  }

  .c-time .sub-date::before {
    content: "· ";
  }

  .data-table tr.state-row {
    display: block;
  }

  .data-table tr.state-row td {
    display: block;
    padding: 0;
  }
}

@media (max-width: 700px) {
  .page h1 {
    font-size: 1.8rem;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 1.25rem;
    gap: 1rem;
  }

  .date-control {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .date-control input {
    max-width: 12rem;
  }

  .stats-grid {
    gap: .7rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-top {
    font-size: .9rem;
    align-items: flex-start;
  }

  .stat-icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  .stat-value {
    font-size: 2rem;
    margin-top: .6rem;
  }

  .stat-note {
    font-size: .84rem;
    line-height: 1.35;
  }

  .panel, .report-card, .settings-panel {
    padding: 1.15rem;
    border-radius: .95rem;
  }

  .recent-panel, .table-panel {
    padding: 0;
  }

  .recent-panel .panel-heading {
    padding: 1.15rem 1.15rem 0;
  }

  .recent-panel .panel-heading .button {
    display: none;
  }

  .inventory-visual {
    gap: 1.25rem;
  }

  .ring {
    width: 8.5rem;
    height: 8.5rem;
  }

  .ring-inner strong {
    font-size: 1.7rem;
  }

  .big-count strong {
    font-size: 1.8rem;
  }

  .report-cards, .settings-fields, .form-grid {
    grid-template-columns: 1fr;
  }

  .report-card:last-child {
    grid-column: auto;
  }

  .field-full {
    grid-column: auto;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-actions .button {
    width: 100%;
  }

  .segmented {
    display: grid;
    width: 100%;
  }

  .segmented button {
    padding-inline: .5rem;
  }

  .filters {
    padding: 1rem;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .filter-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
  }

  .filter-field {
    min-width: 0;
  }

  .filter-reset {
    align-self: end;
  }

  .filter-field input, .filter-field select {
    font-size: .95rem;
    padding-inline: .65rem;
  }

  .table-footer {
    flex-direction: column;
  }

  .entry-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .entry-summary .summary-chip {
    justify-content: space-between;
  }

  .entry-summary .summary-chip:first-child {
    grid-column: 1 / -1;
  }

  /* Inputs at 16px+ prevent iOS from zooming on focus */
  input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
    font-size: 1rem;
    min-height: 3.1rem;
  }

  /* Pop-up becomes a bottom sheet */
  .modal-backdrop {
    place-items: end stretch;
    padding: 0;
  }

  .form-panel {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 1.4rem 1.4rem 0 0;
    border-bottom: 0;
    animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }

  .form-panel .panel-heading {
    padding: 1.1rem 1.15rem;
  }

  .form-panel .panel-heading::before {
    content: "";
    position: absolute;
    left: 50%;
    top: .5rem;
    width: 2.5rem;
    height: .3rem;
    border-radius: 99px;
    background: var(--line-strong);
    transform: translateX(-50%);
  }

  .form-panel {
    position: relative;
  }

  .modal-body {
    padding: 1.15rem;
  }

  .form-footer {
    padding: .85rem 1.15rem calc(.85rem + env(safe-area-inset-bottom, 0px));
  }

  .form-footer .form-hint {
    display: none;
  }

  .form-footer .button-row {
    flex: 1;
  }

  .form-footer .button-row .button {
    flex: 1;
  }

  .form-footer .button-row #cancelEntry {
    flex: 0 0 auto;
  }

  .form-footer .button-row #saveEntry {
    flex: 1;
  }

  .button-ghost-danger .btn-label {
    display: none;
  }

  .button-ghost-danger {
    padding-inline: .85rem;
    border-color: var(--line-strong);
  }

  .confirm-modal {
    width: 100%;
    border-radius: 1.4rem 1.4rem 0 0;
    border-bottom: 0;
    padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }

  .confirm-modal .button-row .button {
    flex: 1;
  }
}

@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}