:root {
  color-scheme: light;

  /* Brand palette */
  --navy: #0b2545;
  --navy-ink: #ffffff;
  --slate: #1b4965;
  --slate-ink: #ffffff;
  --sky: #5fa8d3;
  /* Sky at text size fails WCAG contrast on white/off-white, so hyperlinks
     use this deepened variant; raw --sky is reserved for large fills
     (active pills, focus glow, chart accents) where the ratio isn't an issue. */
  --sky-text: #2c6d95;
  --gold: #c9942b;
  --gold-text: #a97918;
  --success: #2e7d53;
  --due: #b3423b;

  /* Surfaces */
  --page-plane: #f7f5f1;
  --surface-1: #ffffff;
  --surface-sunken: #f1ede4;

  /* Text */
  --text-primary: #0f2540;
  --text-secondary: #3d5871;
  --text-muted: #74889a;

  /* Lines */
  --border-hairline: rgba(11, 37, 69, 0.13);
  --gridline: #e6e1d4;

  /* Legacy aliases kept so existing component rules stay in sync */
  --accent: var(--sky-text);
  --accent-ink: #ffffff;
  --status-good: var(--success);
  --status-warning: var(--gold-text);
  --status-critical: var(--due);
  --danger: var(--due);

  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Elevation */
  --shadow-card: 0 1px 2px rgba(11, 37, 69, 0.06), 0 6px 16px rgba(11, 37, 69, 0.05);
  --shadow-topbar: 0 2px 10px rgba(11, 37, 69, 0.16);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
}

main {
  max-width: 840px;
  padding: 2rem 1.5rem 4rem;
}

main.main--wide {
  max-width: 1180px;
}

/* Offset content past the fixed sidebar. Scoped to ".sidebar ~ main" (not a
   bare "main" rule) so pages that render without a sidebar — login, the
   printable receipt — are unaffected. */
.sidebar ~ main {
  margin-left: 230px;
  transition: margin-left 0.15s ease;
}

a {
  color: var(--sky-text);
  text-decoration-color: color-mix(in srgb, var(--sky-text) 40%, transparent);
}

a:hover {
  color: var(--navy);
}

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

/* Visible keyboard focus everywhere. Components on dark surfaces (sidebar)
   override the color further down so the ring stays visible on navy. */
:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Financial figures, IDs and dates read as a ledger, not prose. */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Sidebar navigation */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 230px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-topbar);
  z-index: 40;
}

.sidebar__brand-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.sidebar__brand-text {
  border-bottom: 2px solid var(--gold);
  padding-bottom: 1px;
}

.sidebar__brand-mark {
  display: none;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-family: var(--font-mono);
}

.sidebar__close {
  display: none;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem 0.6rem 1rem;
}

.sidebar__link,
.sidebar__group-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.65rem;
  margin: 1px 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  border-radius: 7px;
  text-align: left;
}

.sidebar__link:hover,
.sidebar__group-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar__link.is-active {
  color: #ffffff;
  background: rgba(95, 168, 211, 0.25);
  box-shadow: inset 3px 0 0 var(--sky);
}

.sidebar__group.is-open > .sidebar__group-toggle {
  color: #ffffff;
}

.sidebar__icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.sidebar__label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__chevron {
  flex: 0 0 auto;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease;
}

.sidebar__group.is-open > .sidebar__group-toggle .sidebar__chevron {
  transform: rotate(90deg);
  color: var(--sky);
}

.sidebar__submenu {
  display: none;
  flex-direction: column;
  padding-left: 0.2rem;
}

.sidebar__group.is-open .sidebar__submenu {
  display: flex;
}

.sidebar__submenu a {
  display: block;
  padding: 0.45rem 0.6rem 0.45rem 2.55rem;
  margin: 1px 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  border-radius: 6px;
}

.sidebar__submenu a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar__submenu a.is-active {
  color: #ffffff;
  font-weight: 600;
  background: rgba(95, 168, 211, 0.22);
  box-shadow: inset 3px 0 0 var(--sky);
}

.sidebar__user {
  flex: 0 0 auto;
  padding: 0.9rem 1.1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sidebar__username {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.sidebar__user .btn-secondary {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

.sidebar__user .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #ffffff;
}

.btn-block {
  width: 100%;
}

.sidebar :focus-visible,
.mobile-topbar :focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 1px;
  box-shadow: 0 0 0 5px rgba(95, 168, 211, 0.4);
}

/* Mobile top strip + drawer trigger. Hidden on desktop/tablet, where the
   sidebar itself is always on screen (full or icon-only). */
.mobile-topbar {
  display: none;
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.sidebar-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.45);
  z-index: 30;
}

/* Card */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h1,
.card h2 {
  margin-top: 0;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--navy);
  background-image: linear-gradient(160deg, var(--navy) 0%, var(--slate) 100%);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(11, 37, 69, 0.35);
}

.auth-card h1 {
  color: var(--navy);
  font-size: 1.6rem;
}

/* Forms */
.stacked-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1rem 0 0.35rem;
}

.stacked-form label:first-of-type {
  margin-top: 0;
}

.stacked-form input[type="text"],
.stacked-form input[type="email"],
.stacked-form input[type="password"],
.stacked-form input[type="tel"],
.stacked-form input[type="number"],
.stacked-form input[type="date"],
.stacked-form textarea,
.stacked-form select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--page-plane);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(95, 168, 211, 0.28);
}

.stacked-form input:disabled {
  color: var(--text-muted);
  background: var(--surface-sunken);
  font-family: var(--font-mono);
}

.stacked-form textarea {
  resize: vertical;
  min-height: 5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--navy);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--slate);
}

.btn-secondary {
  background: transparent;
  border-color: var(--gridline);
  color: var(--navy);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--navy) 6%, transparent);
  border-color: var(--navy);
}

.btn-danger {
  background: var(--due);
  color: #ffffff;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--due) 85%, black);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: color-mix(in srgb, var(--success) 85%, black);
}

/* "Blue" per the Wasooli reference (New Amount / Recharge / More) — Sky,
   the app's link/active-state color, used here as a solid button fill. */
.btn-info {
  background: var(--sky);
  color: var(--navy);
}

.btn-info:hover {
  background: color-mix(in srgb, var(--sky) 80%, var(--navy));
  color: #ffffff;
}

.btn-icon {
  margin-right: 0.35rem;
}

/* Per-row action dropdown (Users screen) */
.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu__toggle {
  white-space: nowrap;
}

/* position:fixed (set via JS on open, using the toggle button's
   getBoundingClientRect) rather than position:absolute, so the panel isn't
   clipped by .table-scroll's overflow-x — the same clipping bug the sidebar
   flyout hit at the tablet breakpoint. */
.action-menu__list {
  display: none;
  position: fixed;
  min-width: 190px;
  padding: 0.4rem;
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(11, 37, 69, 0.22);
  z-index: 50;
}

.action-menu__list.is-open {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.action-menu__list form {
  margin: 0;
}

.action-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: none;
  background: none;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.action-menu__item:hover {
  background: color-mix(in srgb, var(--sky) 14%, transparent);
}

.action-menu__item--danger {
  color: var(--due);
}

.action-menu__item--danger:hover {
  background: color-mix(in srgb, var(--due) 10%, transparent);
}

/* Modals (Edit / Detailed / Remarks) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.45);
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem;
  overflow-y: auto;
  z-index: 60;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 720px;
  background: var(--surface-1);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(11, 37, 69, 0.35);
}

.modal--narrow {
  max-width: 460px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--gridline);
}

.modal__header h2 {
  margin: 0;
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}

.modal__close:hover {
  color: var(--navy);
}

.modal__body {
  padding: 1.4rem;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.4rem 1.4rem;
}

/* Groups the Edit modal's fields into the rows the field spec calls for —
   a flexible grid (not a fixed 2-column .form-row) since some rows hold up
   to five fields. */
.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-form-grid label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.modal-form-grid input,
.modal-form-grid select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--page-plane);
  border: 1px solid var(--gridline);
  border-radius: 8px;
}

.modal-form-grid input:disabled {
  color: var(--text-muted);
  background: var(--surface-sunken);
  font-family: var(--font-mono);
}

.modal-form-grid input:focus,
.modal-form-grid select:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(95, 168, 211, 0.28);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem 1.5rem;
}

.detail-grid dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 0 0 0.15rem;
}

.detail-grid dd {
  margin: 0;
  font-size: 0.92rem;
}

/* Alerts */
.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert-error {
  background: color-mix(in srgb, var(--due) 10%, var(--surface-1));
  border-color: color-mix(in srgb, var(--due) 30%, transparent);
  color: var(--due);
}

.alert-success {
  background: color-mix(in srgb, var(--success) 10%, var(--surface-1));
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success);
}

/* Logo */
.logo-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.logo-preview {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid var(--gridline);
  background: var(--page-plane);
  object-fit: contain;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
}

.logo-upload-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Meter */
.meter {
  --meter-color: var(--sky);
}

.meter--good {
  --meter-color: var(--success);
}

.meter--warning {
  --meter-color: var(--gold);
}

.meter--critical {
  --meter-color: var(--due);
}

.meter__track {
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--meter-color) 18%, var(--surface-1));
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--meter-color);
  transition: width 0.2s ease;
}

.meter__caption {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.meter__icon {
  font-size: 0.95rem;
}

/* Area nav */
.area-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.area-nav a {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--gridline);
}

.area-nav a:hover {
  border-color: var(--sky);
  color: var(--navy);
}

.area-nav a.active {
  background: var(--sky);
  border-color: var(--sky);
  color: var(--navy);
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--gridline);
}

.data-table thead th {
  color: rgba(255, 255, 255, 0.82);
  background: var(--navy);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
  position: sticky;
  top: 0;
}

.data-table thead tr:first-child th:first-child {
  border-top-left-radius: 6px;
}

.data-table thead tr:first-child th:last-child {
  border-top-right-radius: 6px;
}

.data-table tbody tr:nth-child(even) {
  background: var(--surface-sunken);
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--sky) 12%, transparent);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.row-actions form {
  margin: 0;
  display: inline;
}

.link-danger {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--due);
  cursor: pointer;
  text-decoration: underline;
}

/* Same shape as .link-danger, for a POST-only row action that isn't
   destructive (e.g. Restore) so it doesn't read as a delete-style warning. */
.link-action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--sky-text);
  cursor: pointer;
  text-decoration: underline;
}

/* Wide tables that may not fit narrow viewports scroll in their own box,
   never the page. */
.table-scroll {
  overflow-x: auto;
  border-radius: 8px;
}

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-form input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--page-plane);
  border: 1px solid var(--gridline);
  border-radius: 8px;
}

.search-form input[type="text"]:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(95, 168, 211, 0.28);
}

.search-form select,
.search-form input[type="date"] {
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--page-plane);
  border: 1px solid var(--gridline);
  border-radius: 8px;
}

/* Group header row in a grouped report table (e.g. Package Wise List) */
.group-row td {
  background: color-mix(in srgb, var(--slate) 10%, var(--surface-1)) !important;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Status badge: color always paired with a label, never alone */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge--good {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.status-badge--critical {
  color: var(--due);
  background: color-mix(in srgb, var(--due) 12%, transparent);
}

.status-badge--neutral {
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text-secondary) 10%, transparent);
}

/* Partial bill status (item 4 fix, 2026-07-22) -- distinct from Unpaid's
   neutral treatment so a bill with some payment already collected toward
   it is visually distinguishable from one with none at a glance. */
.status-badge--warning {
  color: var(--gold-text);
  background: color-mix(in srgb, var(--gold) 15%, transparent);
}

/* Checkbox list (e.g. multi-select sublocalities) */
.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.4rem 1rem;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.75rem;
  margin-top: 0.35rem;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  background: var(--page-plane);
}

.checkbox-list__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 400;
}

.data-table select {
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--gridline);
  border-radius: 6px;
}

/* Stat tile (e.g. customer balance) */
.stat-tile {
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--page-plane);
  border: 1px solid var(--gridline);
  border-top: 3px solid var(--gridline);
}

.stat-tile__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-tile__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.stat-tile--critical {
  border-top-color: var(--due);
}
.stat-tile--critical .stat-tile__value {
  color: var(--due);
}

.stat-tile--good {
  border-top-color: var(--success);
}
.stat-tile--good .stat-tile__value {
  color: var(--success);
}

.stat-tile--neutral {
  border-top-color: var(--slate);
}
.stat-tile--neutral .stat-tile__value {
  color: var(--text-primary);
}

.stat-tile--warning {
  border-top-color: var(--gold);
}
.stat-tile--warning .stat-tile__value {
  color: var(--gold-text);
}

.customer-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: space-between;
}

.customer-card__details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem 1.5rem;
  flex: 1;
  min-width: 240px;
}

.customer-card__field {
  font-size: 0.88rem;
}

.customer-card__field .label {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.summary-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Elements/regions marked .no-print are hidden when the page is printed
   (e.g. via a Print button's window.print()) — nav chrome, filter controls,
   action buttons never belong in a printout. */
@media print {
  .no-print {
    display: none !important;
  }
}

/* Token chips (message template placeholders) */
.token-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.token-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--sky) 16%, var(--surface-1));
  color: var(--sky-text);
  border: 1px solid color-mix(in srgb, var(--sky) 35%, transparent);
}

code {
  font-family: var(--font-mono);
  background: var(--page-plane);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.receipt-preview {
  white-space: pre-wrap;
  padding: 0.9rem 1rem;
  margin-top: 0.5rem;
  border-radius: 8px;
  border: 1px dashed var(--gridline);
  background: var(--page-plane);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Dashboard charts grid */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-charts .card {
  margin-bottom: 0;
}

/* Tabs (dashboard "Overview" widget) */
.tabs__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gridline);
  padding-bottom: 0.75rem;
}

.tabs__button {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--gridline);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}

.tabs__button:hover {
  border-color: var(--sky);
  color: var(--navy);
}

.tabs__button.is-active {
  background: color-mix(in srgb, var(--sky) 20%, var(--surface-1));
  border-color: var(--sky);
  color: var(--navy);
}

.tabs__panel {
  display: none;
}

.tabs__panel.is-active {
  display: block;
}

/* Collections screen — find/select bar, bill action bar */
.collection-find-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.collection-find-bar .choices {
  flex: 1 1 320px;
  min-width: 240px;
  margin-bottom: 0;
}

.collection-find-bar.has-error .choices__inner {
  border-color: var(--due) !important;
  box-shadow: 0 0 0 3px rgba(179, 66, 59, 0.2);
}

.collection-action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--surface-sunken);
  border: 1px solid var(--gridline);
  border-radius: var(--radius);
}

.collection-action-bar__amount {
  width: 160px;
  padding: 0.6rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--gridline);
  border-radius: 8px;
}

.collection-action-bar__amount:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(95, 168, 211, 0.28);
}

.collection-action-bar__meta {
  margin-right: auto;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.collection-action-bar__meta .mono {
  color: var(--text-primary);
  font-weight: 600;
}

/* Choices.js theme override — matches the app's Inter/navy/sky look instead
   of the library's default styling. Loaded via CDN (see note in
   collections.ejs): there's no existing select2/choices.js pattern
   elsewhere in this app to match, despite the reference implying one. */
.choices__inner {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  background: var(--page-plane) !important;
  border: 1px solid var(--gridline) !important;
  border-radius: 8px !important;
  min-height: unset !important;
  padding: 0.5rem 0.7rem !important;
}

.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
  border-color: var(--sky) !important;
  box-shadow: 0 0 0 3px rgba(95, 168, 211, 0.28);
}

.choices__list--dropdown {
  border-color: var(--gridline) !important;
  border-radius: 8px !important;
  font-family: var(--font-ui);
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
  background: color-mix(in srgb, var(--sky) 16%, var(--surface-1)) !important;
}

.choices__list--single .choices__item {
  color: var(--text-primary);
}

/* Responsive */

/* Tablet / small desktop: sidebar collapses to an icon-only rail. Labels and
   chevrons hide; an open group flies out beside its icon instead of pushing
   the list down, since there's no vertical room for indented text. */
@media (max-width: 1024px) and (min-width: 641px) {
  .sidebar {
    width: 64px;
  }

  .sidebar__label,
  .sidebar__chevron,
  .sidebar__brand-text {
    display: none;
  }

  .sidebar__brand-mark {
    display: flex;
  }

  .sidebar__brand-row {
    padding: 1.1rem 0.7rem;
    justify-content: center;
  }

  .sidebar__link,
  .sidebar__group-toggle {
    justify-content: center;
    padding: 0.6rem;
  }

  .sidebar__username {
    display: none;
  }

  .sidebar__user {
    align-items: center;
  }

  .sidebar__user .btn-block {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 0;
    position: relative;
  }

  .sidebar__user .btn-block::after {
    content: "\21B2";
    font-size: 1rem;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar__group {
    position: relative;
  }

  /* overflow-x:hidden on .sidebar__nav (set for the expanded desktop rail)
     would otherwise clip this flyout, since an absolutely positioned
     descendant is still clipped by an overflow-hidden ancestor even though
     it escapes normal flow. */
  .sidebar__nav {
    overflow: visible;
  }

  .sidebar__group.is-open .sidebar__submenu {
    display: flex;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 210px;
    padding: 0.4rem;
    background: var(--navy);
    border-radius: 0 10px 10px 0;
    box-shadow: 6px 0 20px rgba(11, 37, 69, 0.35);
  }

  .sidebar__submenu a {
    padding-left: 0.75rem;
  }

  .sidebar ~ main {
    margin-left: 64px;
  }
}

/* Mobile: sidebar becomes an off-canvas drawer opened from a slim top strip,
   preserving the page's existing narrow-viewport behavior underneath it. */
@media (max-width: 640px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 1rem;
    background: var(--navy);
    box-shadow: var(--shadow-topbar);
    z-index: 20;
  }

  .sidebar-toggle {
    display: flex;
  }

  .mobile-topbar__brand {
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 1px;
  }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__close {
    display: inline-block;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar ~ main {
    margin-left: 0;
    padding-top: calc(52px + 1.25rem);
  }

  main {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 3rem;
  }

  .card {
    padding: 1.1rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stat-tile {
    flex: 1 1 45%;
    min-width: 140px;
    padding: 0.8rem 1rem;
  }

  .stat-tile__value {
    font-size: 1.4rem;
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem 0.4rem;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .btn {
    flex: 1 1 auto;
  }
}

/* Persistent impersonation banner (Phase B task 7) -- deliberately loud
   (gold, not the tenant navy/sky palette) so it's never mistaken for
   normal tenant chrome while a master admin is viewing as this tenant. */
.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  background: var(--gold);
  color: #3a2a04;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* ---- Landing page hero + features ---- */
.hero {
  background: var(--navy);
  background-image: linear-gradient(160deg, var(--navy) 0%, var(--slate) 100%);
  color: #ffffff;
  padding: 3rem 1.5rem;
}
.hero__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}
.hero__content {
  flex: 1 1 360px;
  min-width: 280px;
}
.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sky);
  margin: 0 0 0.75rem;
}
.hero__title {
  font-size: 2.5rem;
  margin: 0 0 1rem;
  color: #ffffff;
}
.hero__tagline {
  font-size: 1.05rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.82);
  margin: 0 0 1.75rem;
  max-width: 480px;
}
.hero__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.45);
  color: #ffffff;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.12);
  border-color: #ffffff;
}
.hero__art {
  flex: 1 1 320px;
  min-width: 260px;
  display: flex;
  justify-content: center;
}
.hero__art svg {
  width: 100%;
  max-width: 380px;
  height: auto;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2.5rem 0;
}
.feature-card {
  margin-bottom: 0;
}
.feature-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.9rem;
  color: var(--navy);
}
.feature-card__icon svg {
  width: 22px;
  height: 22px;
}
.feature-card h2 {
  font-size: 1.02rem;
}
.cta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--surface-sunken);
}
.cta-banner h2 {
  margin: 0 0 0.35rem;
}
.cta-banner p {
  margin: 0;
}
@media (max-width: 640px) {
  .hero__inner { flex-direction: column; text-align: center; }
  .hero__actions { justify-content: center; }
  .hero__tagline { max-width: none; margin-left: auto; margin-right: auto; }
  .cta-banner { flex-direction: column; text-align: center; }
}

/* ---- Login logo mark ---- */
.auth-card__brand {
  text-align: center;
  margin-bottom: 0.25rem;
}
.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.6rem;
  display: block;
}
.auth-card__brand h1 {
  margin-bottom: 0;
}

/* ---- Login logo badge (matches mobile app drawer) ---- */
.brand-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  box-shadow: 0 6px 16px rgba(11,37,69,0.18);
}
.brand-badge svg {
  width: 40px;
  height: 40px;
}

/* ---- Public marketing nav ---- */
.public-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-hairline);
}
.public-nav__inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  gap: 1rem;
}
.public-nav__brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--navy);
  text-decoration: none;
}
.public-nav__links {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}
.public-nav__link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.public-nav__link:hover {
  color: var(--sky-text);
}
.public-nav__link.is-active {
  color: var(--navy);
  font-weight: 700;
}
.public-nav__cta {
  padding: 0.5rem 1.1rem;
}
.public-nav__toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
}
.public-nav__toggle span {
  width: 22px;
  height: 2px;
  background: var(--navy);
  display: block;
}
@media (max-width: 760px) {
  .public-nav__toggle { display: flex; }
  .public-nav__links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-hairline);
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem 1.5rem 1.5rem;
    display: none;
  }
  .public-nav__links.is-open { display: flex; }
  .public-nav__cta { margin-top: 0.4rem; }
}

/* ---- Public page hero (Features / Pricing / About / Contact) ---- */
.page-hero {
  max-width: 760px;
  margin: 0 auto 2.5rem;
  text-align: center;
  padding: 3rem 1.5rem 0;
}
.page-hero h1 {
  font-size: 2.1rem;
  margin: 0.4rem 0 0.75rem;
}
.hero-eyebrow {
  display: inline-block;
  color: var(--sky-text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  margin: 0;
}

/* ---- Pricing cards ---- */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.pricing-card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
}
.pricing-card--highlight {
  border-color: var(--sky);
  box-shadow: 0 6px 20px rgba(11,37,69,0.12);
  transform: translateY(-6px);
}
.pricing-card__badge {
  position: absolute;
  top: -12px;
  left: 1.75rem;
  background: var(--sky-text);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}
.pricing-card__name {
  margin: 0.25rem 0 0.5rem;
}
.pricing-card__price {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 1rem;
}
.pricing-card__price span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}
.pricing-card__features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}
.pricing-card__features li {
  padding-left: 1.4rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.92rem;
}
.pricing-card__features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.pricing-card__cta {
  text-align: center;
}
