/* Green Enterprise -- ledger-book aesthetic */

:root {
  --green-dark: #2f4f33;
  --green: #3f6b44;
  --green-light: #e8f0e6;
  --paper: #fbfaf6;
  --ink: #2b2b26;
  --muted: #767163;
  --line: #ddd8cc;
  --red: #a13d3d;
  --red-light: #fbeaea;
  --gold: #b08d2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

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

.page-width {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.topbar {
  background: var(--green-dark);
  color: #fff;
}

.topbar .page-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.topbar .brand {
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 0.02em;
}

.topbar .brand small {
  display: block;
  font-size: 0.7rem;
  font-weight: normal;
  opacity: 0.8;
  letter-spacing: 0.1em;
}

.topbar form { margin: 0; }

.topbar button.link {
  background: none;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
}

nav.tabs {
  background: var(--green);
}

nav.tabs .page-width {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

nav.tabs a {
  color: #f1f7ee;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  border-bottom: 3px solid transparent;
}

nav.tabs a:hover {
  background: rgba(255,255,255,0.08);
  text-decoration: none;
}

nav.tabs a.active {
  border-bottom-color: var(--gold);
  font-weight: bold;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

h1, h2, h3 { font-family: "Georgia", serif; color: var(--green-dark); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }

.muted { color: var(--muted); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.tile {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.tile .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tile .value {
  font-size: 1.45rem;
  font-weight: bold;
  color: var(--green-dark);
}

.tile.negative { border-left-color: var(--red); }
.tile.negative .value { color: var(--red); }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  margin-bottom: 1rem;
}

table caption { text-align: left; font-weight: bold; padding-bottom: 0.5rem; }

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-size: 0.95rem;
}

th { background: var(--green-light); color: var(--green-dark); font-weight: bold; }

tr:hover td { background: #fcfcf9; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.paid { background: var(--green-light); color: var(--green-dark); }
.badge.partial { background: #fdf3e0; color: var(--gold); }
.badge.pending { background: var(--red-light); color: var(--red); }
.badge.voided { background: #eee; color: var(--muted); text-decoration: line-through; }
.badge.active { background: var(--green-light); color: var(--green-dark); }

.btn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover { background: var(--green-dark); text-decoration: none; color: #fff; }

.btn.secondary { background: #fff; color: var(--green-dark); border: 1px solid var(--green); }
.btn.secondary:hover { background: var(--green-light); }

.btn.danger { background: var(--red); }
.btn.danger:hover { background: #7e2f2f; }
.btn.success { background: #1a7a3c; }
.btn.success:hover { background: #145c2d; }
.inline-collect { display:inline-flex; gap:4px; align-items:center; }
.collect-input { width:110px; padding:0.5rem 0.55rem; border:1px solid var(--line); border-radius:4px; font-size:1rem; }

form .field { margin-bottom: 0.9rem; }
form label { display: block; font-weight: bold; margin-bottom: 0.25rem; font-size: 0.92rem; }
form input, form select, form textarea {
  width: 100%;
  max-width: 360px;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem; /* 16px minimum stops iOS Safari zooming on focus */
  background: #fff;
}
form .help { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
form .errorlist { color: var(--red); list-style: none; padding: 0; margin: 0.2rem 0; font-size: 0.85rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.6rem 1rem;
  border-radius: 5px;
  margin-bottom: 0.5rem;
  background: var(--green-light);
  color: var(--green-dark);
  border: 1px solid var(--green);
}
.messages li.error { background: var(--red-light); color: var(--red); border-color: var(--red); }

.actions { margin: 1rem 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}
.filter-form .field { margin-bottom: 0; min-width: 140px; }
.filter-form input, .filter-form select { max-width: 200px; }
.filter-form label { font-size: 0.8rem; margin-bottom: 0.2rem; }
.filter-form .field.grow { flex: 1 1 200px; }

.login-wrap {
  max-width: 360px;
  margin: 4rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem;
}

footer.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1.5rem 0;
}

/* Aliases used by templates for tile sub-elements */
.tile-label,
.tile .label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tile-value,
.tile .value {
  display: block;
  font-size: 1.45rem;
  font-weight: bold;
  color: var(--green-dark);
}

.tile-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.tile.negative .tile-value { color: var(--red); }

.negative-text { color: var(--red); }

tr.reversal { opacity: 0.65; font-style: italic; }

/* Dashboard */
.dashboard-hero {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.dashboard-hero h1 {
  color: #fff;
  margin: 0 0 0.2rem;
}

.dashboard-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
}

.dashboard-hero .date-badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pdf-export-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.6rem 1rem;
  background: var(--green-light);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.pdf-date-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0;
}

.pdf-date-form label {
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
}

.pdf-date-form input[type="date"] {
  width: auto;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
}

/* Daily-PDF download block under the activity card */
.pdf-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pdf-card-text strong { color: var(--green-dark); }

.pdf-card-text p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.tile:hover {
  box-shadow: 0 4px 12px rgba(47, 79, 51, 0.1);
  transform: translateY(-2px);
}

.tile .tile-icon {
  font-size: 1.2rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.dashboard-cols {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 820px) {
  .dashboard-cols { grid-template-columns: 1fr; }
}

.dashboard-cols .card { margin-bottom: 0; }
.dashboard-cols > div { display: flex; flex-direction: column; gap: 1rem; }

.quick-actions-card { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.quick-actions-card h2 { margin: 0; }
.quick-actions-card .actions { margin: 0; }

.section-card h2 { margin-top: 0; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 1.25rem 0.5rem;
}

/* ── Dropdown navigation ──────────────────────────────────────────── */

nav.tabs .page-width {
  align-items: stretch;  /* make groups fill the nav height */
}

.nav-group {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.nav-trigger {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  border-radius: 0;
  font-family: inherit;
  color: #f1f7ee;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  gap: 0.25rem;
}

/* Hover-open only on devices that actually have a mouse; touch uses click. */
@media (hover: hover) {
  .nav-group:hover > .nav-trigger {
    background: rgba(255,255,255,0.08);
    text-decoration: none;
  }

  .nav-group:hover > .nav-dropdown {
    display: block;
  }
}

.nav-group.active > .nav-trigger {
  border-bottom-color: var(--gold);
  font-weight: bold;
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--green-dark);
  min-width: 175px;
  z-index: 200;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  padding: 0.3rem 0;
}

.nav-group.open > .nav-trigger {
  background: rgba(255,255,255,0.08);
}

.nav-group.open > .nav-dropdown {
  display: block;
}

.nav-dropdown a {
  display: block;
  padding: 0.48rem 1.1rem;
  font-size: 0.9rem;
  color: #dcebd6;
  border-bottom: none;
  white-space: nowrap;
}

.nav-dropdown a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}

.nav-dropdown a.active {
  font-weight: bold;
  color: #fff;
  border-left: 3px solid var(--gold);
  padding-left: calc(1.1rem - 3px);
  background: rgba(255,255,255,0.07);
}

.nav-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.15);
  margin: 0.3rem 0;
}

/* On small screens the dropdown spans the full nav width so it never
   clips at the viewport edge, and menu items get finger-sized rows. */
@media (max-width: 680px) {
  nav.tabs .page-width { position: relative; }
  .nav-group { position: static; }
  .nav-dropdown {
    left: 0;
    right: 0;
    border-radius: 0 0 6px 6px;
  }
}

/* Bigger tap targets on touch devices and small screens (44px minimum). */
@media (max-width: 820px), (pointer: coarse) {
  nav.tabs a, .nav-trigger {
    padding: 0.8rem 0.9rem;
    font-size: 1rem;
  }
  .nav-dropdown a {
    padding: 0.75rem 1.1rem;
    font-size: 1rem;
  }
  .btn {
    padding: 0.7rem 1.2rem;
    font-size: 1rem;
  }
  .activity-tabs .tab-btn { /* beats the base .tab-btn rule declared later in this file */
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }
  .topbar button.link {
    padding: 0.6rem 0.4rem;
    min-height: 44px;   /* full finger-sized target, not just a text hit-box */
  }
  th, td {
    padding: 0.65rem 0.6rem;
  }
}

/* ── Visual polish ────────────────────────────────────────────────── */

/* Card shadows for depth */
.card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Section headings inside cards */
.card h2 { border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; }

/* Search / filter bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-bar input[type="search"],
.search-bar input[type="text"] {
  max-width: 280px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 20px;   /* pill shape */
  font-family: inherit;
  font-size: 0.93rem;
  background: #fff;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(63,107,68,0.12);
}

.search-bar .clear-link {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Active filter badge */
.filter-active-badge {
  display: inline-block;
  background: var(--green-light);
  color: var(--green-dark);
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 0.1rem 0.6rem;
  font-size: 0.78rem;
  font-weight: bold;
}

/* Persistent stat tiles — slightly warmer colour */
.tile.warning { border-left-color: var(--gold); }
.tile.warning .tile-value { color: var(--gold); }

/* Page header row */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.page-header h1 { margin-bottom: 0; }

/* Section summary line */
.section-summary {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* Table row hover */
tr:hover td { background: #f7f9f5; }

/* Tighten action buttons inside tables */
td .actions { margin: 0; gap: 0.35rem; }

/* Responsive: collapse dashboard cols early */
@media (max-width: 680px) {
  .dashboard-cols { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* ── Dashboard redesign ─────────────────────────────────────────────── */

.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.dash-header h1 { margin: 0; }

.dash-subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.dash-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.alert-banner.warning {
  background: #fdf3e0;
  border: 1px solid var(--gold);
  color: #7a5f1c;
}

.alert-banner.danger {
  background: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
}

.alert-banner .btn { white-space: nowrap; }

/* Cash position card */
.cash-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cash-card.negative { border-left-color: var(--red); }
.cash-card.negative .cash-value { color: var(--red); }

.cash-card-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cash-value {
  display: block;
  font-size: 1.9rem;
  font-weight: bold;
  color: var(--green-dark);
  line-height: 1.2;
}

.cash-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 24rem;
  text-align: right;
}

.cash-bar {
  display: flex;
  height: 9px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--green-light);
  margin: 0.8rem 0 0.6rem;
}

.cash-bar .seg { display: block; height: 100%; }
.cash-bar .seg.auctions      { background: var(--green-dark); }
.cash-bar .seg.collections   { background: var(--green); }
.cash-bar .seg.rent          { background: #7fa36f; }
.cash-bar .seg.contributions { background: #a9c49b; }
.cash-bar .seg.advances      { background: var(--gold); }

.cash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-size: 0.85rem;
  color: var(--ink);
  margin-top: 0.5rem;
}

.cash-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: baseline;
}

.cash-legend .dot.auctions      { background: var(--green-dark); }
.cash-legend .dot.collections   { background: var(--green); }
.cash-legend .dot.rent          { background: #7fa36f; }
.cash-legend .dot.contributions { background: #a9c49b; }
.cash-legend .dot.advances      { background: var(--gold); }
.cash-legend .dot.spent         { background: var(--red); }
.cash-legend .spend small       { color: var(--muted); }

/* Compact stat chips */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.stat-chip {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  color: var(--ink);
}

a.stat-chip:hover { text-decoration: none; border-color: var(--green); }

.stat-chip .stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-chip .stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--green-dark);
}

.stat-chip .stat-value small { font-size: 0.82rem; font-weight: normal; color: var(--muted); }
.stat-chip.alert .stat-value { color: var(--red); }
.stat-chip.alert { border-left: 4px solid var(--red); }
.stat-chip.warn .stat-value { color: var(--gold); }
.stat-chip.warn { border-left: 4px solid var(--gold); }

/* Quick links strip */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  align-items: center;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.quick-links-label { color: var(--muted); }
.quick-links a { white-space: nowrap; }

/* Tabbed activity card */
.activity-card { padding: 0; overflow: hidden; }

.activity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #fdfcf8;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover { background: var(--green-light); }

.tab-btn.active {
  border-bottom-color: var(--gold);
  font-weight: bold;
  color: var(--green-dark);
}

.tab-count {
  display: inline-block;
  min-width: 1.3em;
  padding: 0 0.35em;
  margin-left: 0.25em;
  border-radius: 10px;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: bold;
  text-align: center;
}

.tab-btn.active .tab-count { background: var(--gold); color: #fff; }

.tab-panel { padding: 0.9rem 1.25rem 0.4rem; }
.tab-panel table { margin-bottom: 0.5rem; }

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0 0.7rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Detail expander rows (shared by activity tables) */
.sale-detail-grid {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid var(--line);
}

.sale-detail-grid div { display: flex; flex-direction: column; gap: 0.1rem; }
.sale-detail-grid dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.sale-detail-grid dd { margin: 0; font-weight: 500; }
.detail-row td { padding: 0 !important; }
.btn-details.active { background: var(--green-dark); color: #fff; border-color: var(--green-dark); }

.positive-text { color: var(--green-dark); }

@media (max-width: 680px) {
  .cash-hint { text-align: left; }
  .dash-header { align-items: flex-start; flex-direction: column; }
}

/* ── Pagination ─────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}
.pagination a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 600;
}
.pagination a:hover { text-decoration: underline; }
.pagination span { color: var(--muted); }

/* ── Mobile: wide tables scroll, the page never does ──────────────────
   The ledger tables are 6–9 columns wide (auctions, employees), far wider
   than a phone. Without a scroll container the whole document scrolls
   sideways, dragging the nav and headers off-screen. Every table is wrapped
   in .table-scroll (see base.html) so only the table pans; the page body
   stays put. Data is never hidden or dropped — a bookkeeper on a phone can
   still reach every column. */

.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;   /* momentum panning on iOS */
  overscroll-behavior-x: contain;      /* don't chain to page/back-swipe */
}

/* The table must size to its content inside the scroller, not be squeezed
   back down to the container width. */
.table-scroll > table {
  margin-bottom: 0;
  min-width: 100%;
  width: auto;
}

/* Tables sitting directly in a card keep the card's edge padding while the
   scrollable strip runs the full width, so the shadow hint reaches the edge. */
.card > .table-scroll { margin-bottom: 1rem; }
.card > .table-scroll:last-child { margin-bottom: 0; }

/* Soft fade pinned to the right edge of the viewport strip, cueing that the
   table continues off-screen. Applied by JS only to tables that actually
   overflow, so tables that already fit get no stray shading. */
.table-scroll.is-scrollable {
  background-image: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.09));
  background-position: right center;
  background-repeat: no-repeat;
  background-size: 20px 100%;
}

.table-scroll .scroll-hint {
  display: none;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.35rem 0.1rem 0;
}

@media (max-width: 820px), (pointer: coarse) {
  /* Money and date columns read far better on one line; the container
     scrolls, so nothing is clipped. */
  .table-scroll td.num,
  .table-scroll th.num,
  .table-scroll td.nowrap,
  .table-scroll th.nowrap { white-space: nowrap; }

  .table-scroll.is-scrollable .scroll-hint { display: block; }

  /* 16px minimum on every text input — below this iOS Safari zooms the
     whole page on focus and the user has to pinch back out. The main form
     inputs were already 16px; the search and filter bars were not. */
  .search-bar input[type="search"],
  .search-bar input[type="text"],
  .filter-form input,
  .filter-form select { font-size: 1rem; }

  /* Filter and search controls stack full-width instead of being pinned to
     a 200–280px box that leaves an awkward gap on a narrow screen. */
  .search-bar { gap: 0.5rem; }
  .search-bar input[type="search"],
  .search-bar input[type="text"] { max-width: none; flex: 1 1 100%; }
  .filter-form { gap: 0.6rem; }
  .filter-form .field { min-width: 0; flex: 1 1 100%; }
  .filter-form input,
  .filter-form select { max-width: none; width: 100%; }

  /* Full-width action buttons are easier to hit than inline ones. */
  .actions .btn { flex: 1 1 auto; text-align: center; }
}

@media (max-width: 560px) {
  /* Reclaim horizontal space: cards and the page gutter are tighter, so the
     content column itself is wider on a small phone. */
  .page-width { padding: 0 0.75rem; }
  .card { padding: 0.9rem; }
  .login-wrap { margin: 1.5rem auto; padding: 1.25rem; }

  /* Long identifiers (emails, plate numbers, reasons) break instead of
     forcing the layout wider. */
  main { overflow-wrap: break-word; }
}

/* ── Print styles ───────────────────────────────────────────────────── */
@media print {
  /* Hide chrome */
  nav, .nav-bar, .actions, .filter-form, .filter-bar,
  .search-bar, .btn, button, form,
  .pagination { display: none !important; }

  /* Remove card shadows/borders so pages look clean */
  .card { box-shadow: none; border: 1px solid #ccc; }

  body { font-size: 11pt; color: #000; background: #fff; }
  h1 { font-size: 16pt; }
  h2 { font-size: 13pt; }

  /* Tables: no alternating background, solid borders */
  table { border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #999; padding: 4px 6px; }
  thead { background: #eee !important; }

  /* Avoid breaking rows across pages */
  tr { page-break-inside: avoid; }

  /* Show links as plain text */
  a[href]::after { content: ""; }
  a { color: inherit; text-decoration: none; }

  /* Summary and tiles */
  .section-summary { border: 1px solid #ccc; padding: 6px; }
  .tile { border: 1px solid #ccc; box-shadow: none; }
}
