/* ==========================================================================
   Building charge management — RTL, mobile-first design system.
   Layout uses logical properties (inline-start/end) so RTL is the native
   direction rather than a flipped LTR sheet.
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */
:root {
  color-scheme: light;

  --sand-50: #fbf8f2;
  --sand-100: #f6f1e8;
  --sand-200: #ebe3d4;
  --sand-300: #dccfba;

  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;

  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;

  --surface: #fffcf8;
  --surface-2: #faf6ef;
  --surface-sunken: #f1ebe1;
  --canvas: var(--sand-100);

  --ink: #1a1612;
  --ink-2: #3f3a34;
  --muted: #746c63;
  --faint: #a39a90;

  --line: #e8dfd2;
  --line-strong: #d4c8b6;

  --brand: #0e6e67;
  --brand-hover: #0b5b55;
  --brand-ink: #ffffff;
  --brand-soft: #d8f6f1;
  --brand-soft-ink: #0f4f4a;

  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --danger-soft-ink: #9f1239;

  --warn: #b45309;
  --warn-soft: #ffedd5;
  --warn-soft-ink: #9a3412;

  --ok: #047857;
  --ok-soft: #d1fae5;
  --ok-soft-ink: #065f46;

  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --info-soft-ink: #1e40af;

  --focus: #0ea5e9;

  --radius-sm: 0.7rem;
  --radius: 1rem;
  --radius-lg: 1.4rem;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 22, 16, 0.05);
  --shadow: 0 2px 6px rgba(28, 22, 16, 0.04), 0 10px 28px rgba(28, 22, 16, 0.07);
  --shadow-lg: 0 10px 20px rgba(28, 22, 16, 0.07), 0 28px 56px rgba(28, 22, 16, 0.12);

  --font: "Vazirmatn", "Tahoma", system-ui, sans-serif;

  --topbar-h: 3.6rem;
  --bottomnav-h: 4.35rem;
  --sidebar-w: 16.5rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-theme="dark"] {
  color-scheme: dark;

  --surface: #221e1b;
  --surface-2: #2a2521;
  --surface-sunken: #181512;
  --canvas: #141210;

  --ink: #f6f3ee;
  --ink-2: #d8d1c8;
  --muted: #b0a79c;
  --faint: #7d746a;

  --line: #3a342e;
  --line-strong: #4d453d;

  --brand: var(--teal-500);
  --brand-hover: var(--teal-600);
  --brand-ink: #08211f;
  --brand-soft: #123d38;
  --brand-soft-ink: var(--teal-200);

  --danger: #fb7185;
  --danger-soft: #4c1224;
  --danger-soft-ink: #fecdd3;

  --warn: #fbbf24;
  --warn-soft: #45280a;
  --warn-soft-ink: #fde68a;

  --ok: #34d399;
  --ok-soft: #0d3b2e;
  --ok-soft-ink: #a7f3d0;

  --info: #60a5fa;
  --info-soft: #172a4d;
  --info-soft-ink: #bfdbfe;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35), 0 24px 48px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------- reset -- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

.skip-link {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 80;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: none;
}

/* Author display rules outrank the UA [hidden] rule, so restate it. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--canvas);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      42rem 28rem at 110% -8%,
      color-mix(in srgb, var(--teal-200) 42%, transparent),
      transparent 58%
    ),
    radial-gradient(
      36rem 24rem at -12% 108%,
      color-mix(in srgb, #f3d5a8 38%, transparent),
      transparent 55%
    ),
    var(--canvas);
}

body.is-locked {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.35rem;
}
h2 {
  font-size: 1.05rem;
}
h3 {
  font-size: 0.95rem;
}

p {
  margin: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  max-width: 100%;
}

svg {
  flex: none;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::placeholder {
  color: var(--faint);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ----------------------------------------------------------- app shell -- */
.container {
  width: min(72rem, 100%);
  margin-inline: auto;
  padding-inline: 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: calc(var(--topbar-h) + var(--safe-t));
  padding-block-start: var(--safe-t);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--topbar-h);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  inline-size: 2.35rem;
  block-size: 2.35rem;
  border-radius: 0.85rem;
  background: linear-gradient(145deg, #127a72 0%, #14b8a6 70%, #5eead4 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--teal-600) 32%, transparent);
  flex: none;
}

.brand-text {
  display: grid;
  line-height: 1.25;
}

.brand-text small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.page {
  padding-block: 1.15rem calc(var(--bottomnav-h) + var(--safe-b) + 1.85rem);
}

.sidebar {
  display: none;
}

/* ------------------------------------------------------------ icon btn -- */
.icon-btn {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  flex: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a.icon-btn {
  text-decoration: none;
}

button.icon-btn {
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.icon-btn:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.icon-btn-danger {
  color: var(--danger);
}

.icon-btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.icon-btn .dot {
  position: absolute;
  inset-block-start: 0.35rem;
  inset-inline-end: 0.35rem;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--danger);
  border: 2px solid var(--surface);
}

.icon-btn .count-badge {
  position: absolute;
  inset-block-start: 0.15rem;
  inset-inline-end: 0.1rem;
  min-inline-size: 1.05rem;
  block-size: 1.05rem;
  padding-inline: 0.22rem;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.05rem;
  text-align: center;
  border: 2px solid var(--surface);
}

/* ---------------------------------------------------------- bottom nav -- */
.bottom-nav {
  position: fixed;
  inset-block-end: calc(0.55rem + var(--safe-b));
  inset-inline: 0.7rem;
  z-index: 45;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.15rem;
  padding: 0.4rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px) saturate(1.25);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: 1.35rem;
  box-shadow: var(--shadow-lg);
}

.bottom-nav a,
.bottom-nav button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  min-block-size: 3.25rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.bottom-nav a:hover,
.bottom-nav button:hover {
  text-decoration: none;
  color: var(--ink);
}

.bottom-nav .is-active {
  color: var(--brand);
  background: var(--brand-soft);
}

.bottom-nav .is-active svg {
  stroke-width: 2.2;
}

/* --------------------------------------------------------------- sheet -- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(2px);
  animation: fade-in 0.15s ease;
}

.sheet {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 51;
  max-block-size: 82dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-start-start-radius: var(--radius-lg);
  border-start-end-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 1rem calc(1.25rem + var(--safe-b));
  animation: slide-up 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-grip {
  inline-size: 2.5rem;
  block-size: 0.25rem;
  border-radius: var(--radius-full);
  background: var(--line-strong);
  margin: 0.25rem auto 0.85rem;
}

.sheet-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-block-end: 0.5rem;
}

.sheet-links {
  display: grid;
  gap: 0.15rem;
  margin-block-end: 0.75rem;
}

.sheet-links a,
.sheet-links button {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  inline-size: 100%;
}

.sheet-links a:hover,
.sheet-links button:hover {
  background: var(--surface-sunken);
  text-decoration: none;
}

.sheet-links .is-active {
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
}

.sheet-links svg {
  color: var(--muted);
}

.sheet-links .is-active svg {
  color: inherit;
}

.sheet-links .is-danger {
  color: var(--danger);
}

.sheet-links .is-danger svg {
  color: inherit;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}

/* ------------------------------------------------------ confirm dialog -- */
.confirm-dialog {
  inset: 0;
  margin: auto;
  border: 0;
  padding: 0;
  inline-size: min(24rem, calc(100% - 2rem));
  background: transparent;
  color: var(--ink);
}

.confirm-dialog::backdrop {
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(2px);
}

[data-theme="dark"] .confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.confirm-dialog-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.2rem 1.25rem 1rem;
}

.confirm-dialog-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.5;
}

.confirm-dialog-panel p {
  margin: 0.55rem 0 0;
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.75;
}

.confirm-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-block-start: 1.15rem;
}

.confirm-dialog[open] .confirm-dialog-panel {
  animation: confirm-pop 0.18s ease;
}

@keyframes confirm-pop {
  from {
    opacity: 0;
    transform: translateY(0.4rem) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-dialog[open] .confirm-dialog-panel {
    animation: none;
  }
}

/* --------------------------------------------------------- page header -- */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block-end: 1rem;
}

.page-header .titles {
  flex: 1 1 14rem;
  min-width: 0;
}

.page-header .sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin-block-start: 0.15rem;
}

.page-header .page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-block-end: 0.6rem;
}

.back-link:hover {
  color: var(--ink);
  text-decoration: none;
}

/* ---------------------------------------------------------------- card -- */
.card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem;
  position: relative;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-block-end: 0.85rem;
}

.card-head h2,
.card-head h3 {
  flex: 1;
  min-width: 0;
}

.card-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-block-start: -0.5rem;
  margin-block-end: 0.85rem;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-flush > .card-head {
  padding: 1.1rem 1.1rem 0;
  margin-block-end: 0.6rem;
}

/* ---------------------------------------------------------------- grid -- */
.stack {
  display: grid;
  gap: 1rem;
}

.stack-sm {
  display: grid;
  gap: 0.5rem;
}

.grid {
  display: grid;
  gap: 0.85rem;
}

.grid-2,
.grid-3 {
  grid-template-columns: 1fr;
}

.grid-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- stat -- */
.stat {
  padding: 1rem;
  display: grid;
  gap: 0.4rem;
  align-content: start;
}

.stat .label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}

.stat-icon {
  inline-size: 1.85rem;
  block-size: 1.85rem;
  display: grid;
  place-items: center;
  border-radius: 0.65rem;
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  flex: none;
}

.stat-accent-danger .stat-icon {
  background: var(--danger-soft);
  color: var(--danger-soft-ink);
}

.stat-accent-ok .stat-icon {
  background: var(--ok-soft);
  color: var(--ok-soft-ink);
}

.stat-accent-brand .stat-icon {
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
}

.stat .value {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.stat .hint {
  font-size: 0.75rem;
  color: var(--faint);
}

.stat-accent-danger .value {
  color: var(--danger);
}
.stat-accent-ok .value {
  color: var(--ok);
}
.stat-accent-brand .value {
  color: var(--brand);
}

/* ------------------------------------------------------- balance hero -- */
.balance-hero {
  display: grid;
  gap: 0.4rem;
  justify-items: center;
  text-align: center;
  padding: 1.25rem 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.balance-hero .caption {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.balance-hero .amount {
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.balance-hero .note {
  font-size: 0.8rem;
  color: var(--muted);
  max-inline-size: 28rem;
}

.balance-hero[data-status="DEBTOR"] {
  background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 22%, var(--line));
}

.balance-hero[data-status="DEBTOR"] .amount {
  color: var(--danger);
}

.balance-hero[data-status="CREDITOR"] {
  background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 22%, var(--line));
}

.balance-hero[data-status="CREDITOR"] .amount {
  color: var(--ok);
}

/* --------------------------------------------------------------- badge -- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-full);
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-debt {
  background: var(--danger-soft);
  color: var(--danger-soft-ink);
}
.badge-credit {
  background: var(--ok-soft);
  color: var(--ok-soft-ink);
}
.badge-settled {
  background: var(--info-soft);
  color: var(--info-soft-ink);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn-soft-ink);
}
.badge-neutral {
  background: var(--surface-sunken);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.badge-brand {
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
}

/* -------------------------------------------------------------- button -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  min-block-size: 2.75rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.08s ease, box-shadow 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 82%, white), var(--brand));
  color: var(--brand-ink);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  background: var(--surface-sunken);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover {
  background: var(--surface-sunken);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.94);
}

.btn-danger-quiet {
  background: transparent;
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: var(--danger-soft);
}

.btn-ok {
  background: var(--ok);
  color: #fff;
}

.btn-ok:hover {
  filter: brightness(0.94);
}

.btn-sm {
  min-block-size: 2.25rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.83rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-block-size: 3.1rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-block {
  inline-size: 100%;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.actions form {
  display: contents;
}

.link-danger {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--danger);
  cursor: pointer;
  padding: 0.25rem 0;
}

/* --------------------------------------------------------------- forms -- */
.form {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.field > .label,
label.field > span:first-child {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-2);
}

.field .req {
  color: var(--danger);
  font-weight: 700;
}

.field .hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.card > .hint {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 0.85rem;
}

/* A hint that explains why the control above it cannot be used yet. */
.field .hint-warn {
  color: var(--warn);
  font-weight: 600;
}

/* 1rem keeps iOS Safari from zooming the viewport on focus. */
input,
select,
textarea {
  font: inherit;
  font-size: 1rem;
  inline-size: 100%;
  min-block-size: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-block-size: 5rem;
  resize: vertical;
  line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
  outline: none;
}

select {
  appearance: none;
  padding-inline-end: 2.25rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  background-size: 1rem;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* The native control's "Choose file / No file chosen" text is set by the
   browser locale and cannot be translated, so the input is hidden behind a
   label we control. The input itself still receives focus and the click. */
.file-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.file-field input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.file-field input[type="file"]:focus-visible + .file-btn {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.file-name {
  min-inline-size: 0;
  overflow: hidden;
  font-size: 0.82rem;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.has-file {
  color: var(--ink-2);
  font-weight: 600;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* Spinners waste width and encourage mis-clicks on large rial amounts. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.check:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
}

.check input {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  min-block-size: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
  flex: none;
  cursor: pointer;
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.9rem;
  margin: 0;
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.fieldset > legend {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-2);
  padding-inline: 0.4rem;
}

/* Collapsed optional sections keep long admin forms short enough to scan
   on a phone without hiding anything the user needs. */
.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  content: "";
  margin-inline-start: auto;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-inline-end: 2px solid var(--muted);
  border-block-end: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.disclosure[open] > summary::after {
  transform: rotate(-135deg);
}

.disclosure[open] > summary {
  border-block-end: 1px solid var(--line);
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

.disclosure > summary .tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.disclosure-body {
  display: grid;
  gap: 0.9rem;
  padding: 0.9rem;
}

.filter-grid {
  display: grid;
  gap: 0.75rem;
}

/* Unit form: hide the fields the current answers make irrelevant, so the
   form only ever asks for what it actually needs. */
.same-occupant {
  display: grid;
  gap: 0.9rem;
}

.same-occupant:has(#resident-same-as-owner:checked) #resident-fields,
.same-occupant:has(#occupy-with-owner:checked) #resident-fields {
  display: none;
}

.form:has(#unit-vacant:checked) #person-count-field,
.form:has(#unit-vacant:checked) .same-occupant {
  display: none;
}

.field-amount {
  position: relative;
}

.amount-readout {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  min-block-size: 1.2rem;
}

.amount-readout:empty {
  display: none;
}

.input-with-action {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.input-with-action input {
  flex: 1;
  min-width: 0;
}

/* -------------------------------------------------------------- tables -- */
.table-wrap {
  inline-size: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: start;
  padding: 0.7rem 0.6rem;
  border-block-end: 1px solid var(--line);
  vertical-align: middle;
}

thead th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  background: var(--surface-2);
}

tbody tr:last-child > * {
  border-block-end: 0;
}

tbody tr:hover {
  background: var(--surface-2);
}

td.num,
th.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-flush table thead th:first-child,
.card-flush table tbody td:first-child {
  padding-inline-start: 1.1rem;
}

.card-flush table thead th:last-child,
.card-flush table tbody td:last-child {
  padding-inline-end: 1.1rem;
}

.table-empty {
  text-align: center;
  color: var(--muted);
  padding-block: 2rem;
}

/* Below the md breakpoint each row becomes a card and every cell shows the
   column name from data-label, so no horizontal scrolling is needed. */
@media (max-width: 767px) {
  .table-cards thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td {
    display: block;
    inline-size: 100%;
  }

  .table-cards tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 0.35rem 0.75rem;
    margin-block-end: 0.6rem;
  }

  .table-cards tr:hover {
    background: var(--surface);
  }

  .table-cards tr:last-child {
    margin-block-end: 0;
  }

  .table-cards td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0;
    border-block-end: 1px dashed var(--line);
    text-align: end;
  }

  .table-cards td:last-child,
  .table-cards td:has(.row-actions) {
    border-block-end: 0;
  }

  .table-cards td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: start;
  }

  .table-cards td[data-label=""]::before,
  .table-cards td:not([data-label])::before {
    content: none;
  }

  .table-cards td:has(.row-actions),
  .table-cards td.cell-block {
    display: block;
    text-align: start;
  }

  .table-cards td:has(.row-actions)::before,
  .table-cards td.cell-block::before {
    display: block;
    margin-block-end: 0.25rem;
  }

  .table-cards .row-actions {
    padding-block: 0.2rem 0.35rem;
  }

  /* Static attributes that belong on the record's own page rather than in a
     phone list — every row carries a link to it. */
  .table-cards td.cell-secondary {
    display: none;
  }

  .table-cards .table-empty {
    display: block;
    border: 0;
    text-align: center;
  }

  .table-cards .table-empty::before {
    content: none;
  }

  .table-cards tfoot tr,
  .table-cards .total-row {
    background: var(--brand-soft);
    border-color: transparent;
  }
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions form {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}

.table-actions input,
.table-actions select {
  min-block-size: 2.25rem;
  max-inline-size: 11rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.total-row {
  font-weight: 800;
  background: var(--surface-2);
}

.total-row td {
  border-block-end: 0;
}

.line-detail {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.65;
  margin-block-start: 0.2rem;
}

/* ---------------------------------------------------------- data lists -- */
.data-list {
  display: grid;
  gap: 0.5rem;
}

.data-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.4rem;
  border-block-end: 1px dashed var(--line);
}

.data-row:last-child {
  border-block-end: 0;
}

.data-row dt,
.data-row .k {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 600;
  flex: none;
}

.data-row dd,
.data-row .v {
  margin: 0;
  font-weight: 600;
  text-align: end;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

/* -------------------------------------------------------- alerts/empty -- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.7;
  border: 1px solid transparent;
}

.alert svg {
  margin-block-start: 0.25rem;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-danger {
  background: var(--danger-soft);
  color: var(--danger-soft-ink);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.alert-ok {
  background: var(--ok-soft);
  color: var(--ok-soft-ink);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}

.alert-info {
  background: var(--info-soft);
  color: var(--info-soft-ink);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}

.alert-warn {
  background: var(--warn-soft);
  color: var(--warn-soft-ink);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}

.alert .alert-close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  line-height: 1;
}

.alert .alert-close:hover {
  opacity: 1;
}

.flash {
  margin-block-end: 1rem;
  box-shadow: var(--shadow);
  animation: slide-down 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

.empty {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  text-align: center;
  color: var(--muted);
  padding: 2.25rem 1rem;
}

.empty .empty-icon {
  inline-size: 3rem;
  block-size: 3rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--faint);
  margin-block-end: 0.25rem;
}

.empty strong {
  color: var(--ink-2);
  font-size: 0.98rem;
}

.empty p {
  font-size: 0.86rem;
  max-inline-size: 24rem;
}

/* ---------------------------------------------------------------- tabs -- */
.tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block-end: 0.25rem;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a {
  white-space: nowrap;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.tabs a:hover {
  text-decoration: none;
  color: var(--ink);
}

.tabs a.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

/* ------------------------------------------------------------ auth page -- */
.auth-wrap {
  min-block-size: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem calc(2.75rem + var(--safe-b));
  background:
    radial-gradient(
      44rem 26rem at 100% -10%,
      color-mix(in srgb, var(--teal-200) 60%, transparent) 0%,
      transparent 55%
    ),
    radial-gradient(
      38rem 22rem at -10% 110%,
      color-mix(in srgb, #f3d5a8 70%, transparent) 0%,
      transparent 50%
    ),
    var(--canvas);
}

.auth-card {
  inline-size: min(26.5rem, 100%);
  padding: 1.7rem 1.4rem 1.4rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.auth-head {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  text-align: center;
  margin-block-end: 1.25rem;
}

.auth-head .brand-mark {
  inline-size: 3.35rem;
  block-size: 3.35rem;
  border-radius: 1rem;
  font-size: 1.5rem;
}

.auth-head p {
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-foot {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.65;
}

.auth-credit {
  display: grid;
  justify-items: center;
  gap: 0.18rem;
  margin-block-start: 1.2rem;
  padding-block-start: 1.05rem;
  border-block-start: 1px solid var(--line);
  text-align: center;
}

.auth-credit-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--faint);
}

.auth-credit-name {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--brand);
  line-height: 1.35;
}

.auth-credit-name::before,
.auth-credit-name::after {
  content: "·";
  color: var(--teal-500);
  font-weight: 500;
  margin-inline: 0.4rem;
  opacity: 0.75;
}

.app-meta {
  display: grid;
  justify-items: center;
  gap: 0.12rem;
}

.app-author {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  line-height: 1.35;
}

.app-author-label {
  font-weight: 600;
  color: var(--faint);
  font-size: 0.68rem;
}

.app-author-name {
  font-weight: 800;
  color: var(--brand);
}

.app-versions {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--faint);
  line-height: 1.4;
}

.app-versions .ver {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.app-meta-global {
  position: fixed;
  inset-inline: 0.75rem;
  inset-block-end: calc(0.55rem + var(--safe-b));
  z-index: 35;
  pointer-events: none;
}

body:has(.bottom-nav) .app-meta-global {
  inset-block-end: calc(5.15rem + var(--safe-b));
}

body:has(.auth-credit) .app-meta-global .app-author {
  display: none;
}

.sidebar-foot .app-meta,
.sheet .app-meta {
  justify-items: start;
  padding: 0.55rem 0.5rem 0.15rem;
}

.sidebar-foot .app-author,
.sidebar-foot .app-versions,
.sheet .app-author,
.sheet .app-versions {
  justify-content: flex-start;
}

.sheet .app-meta {
  padding-inline: 0.25rem;
  padding-block-end: 0.25rem;
}

[data-pwa-install]:not([hidden]) {
  margin-block-start: 0.75rem;
}

.pw-field {
  position: relative;
}

.pw-field input {
  padding-inline-end: 2.9rem;
}

.pw-toggle {
  position: absolute;
  inset-inline-end: 0.3rem;
  inset-block-end: 0.15rem;
  inline-size: 2.35rem;
  block-size: 2.35rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.pw-toggle:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}

/* --------------------------------------------------------------- misc -- */
.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.num {
  font-variant-numeric: tabular-nums;
}

.ltr {
  direction: ltr;
  text-align: start;
  unicode-bidi: isolate;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.divider {
  block-size: 1px;
  background: var(--line);
  border: 0;
  margin-block: 1rem;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  margin-block: 1.25rem 0.6rem;
}

.thumb {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
  max-inline-size: min(100%, 28rem);
  margin-block-start: 0.75rem;
}

/* -------------------------------------------------------- greeting -- */
.greeting {
  display: grid;
  gap: 0.2rem;
  margin-block-end: 1.1rem;
}

.greeting .hello {
  font-size: clamp(1.35rem, 4.6vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.greeting .when {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------------------------------------------------------- wallet -- */
.wallet {
  position: relative;
  overflow: hidden;
  border-radius: 1.45rem;
  padding: 1.3rem 1.15rem 1.15rem;
  color: #fff;
  background: linear-gradient(150deg, #0f4f4a 0%, #0e6e67 48%, #1bb8a6 100%);
  box-shadow: 0 16px 36px color-mix(in srgb, #0e6e67 32%, transparent);
  isolation: isolate;
}

.wallet::before,
.wallet::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  z-index: -1;
}

.wallet::before {
  inline-size: 10rem;
  block-size: 10rem;
  inset-block-start: -4rem;
  inset-inline-end: -3rem;
}

.wallet::after {
  inline-size: 7rem;
  block-size: 7rem;
  inset-block-end: -3.2rem;
  inset-inline-start: -2.2rem;
}

.wallet[data-status="DEBTOR"] {
  background: linear-gradient(150deg, #9f1239 0%, #e11d48 100%);
  box-shadow: 0 16px 36px color-mix(in srgb, #e11d48 30%, transparent);
}

.wallet[data-status="CREDITOR"] {
  background: linear-gradient(150deg, #065f46 0%, #10b981 100%);
  box-shadow: 0 16px 36px color-mix(in srgb, #10b981 28%, transparent);
}

.wallet[data-status="SETTLED"] {
  background: linear-gradient(150deg, #1e3a5f 0%, #3b82f6 100%);
  box-shadow: 0 16px 36px color-mix(in srgb, #3b82f6 26%, transparent);
}

.wallet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-block-end: 0.85rem;
}

.wallet-caption {
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0.88;
}

.wallet .badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.wallet-label {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.82;
}

.wallet-amount {
  font-size: clamp(1.7rem, 7vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-block: 0.1rem 0.35rem;
}

.wallet-note {
  font-size: 0.82rem;
  line-height: 1.65;
  opacity: 0.9;
  max-inline-size: 28rem;
}

.wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-block-start: 1rem;
}

.btn-wallet-primary {
  background: #fff;
  color: #1a1612;
  border-color: transparent;
  font-weight: 800;
}

.btn-wallet-primary:hover {
  background: #f4f1ea;
}

.btn-wallet-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-wallet-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.unit-card {
  display: grid;
  gap: 0.85rem;
}

.unit-card > .card-head {
  margin-block-end: 0;
}

/* ----------------------------------------------------- action tile -- */
.tile-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.action-tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  min-block-size: 4.5rem;
}

.action-tile:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: var(--surface-2);
}

.action-tile-icon {
  inline-size: 2.6rem;
  block-size: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 0.85rem;
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  flex: none;
}

.action-tile-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, white), var(--brand));
  border-color: transparent;
  color: var(--brand-ink);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 26%, transparent);
}

.action-tile-primary .action-tile-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.action-tile-primary:hover {
  background: var(--brand-hover);
}

.action-tile strong,
.action-tile .tile-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
}

.action-tile .tile-sub {
  display: block;
  margin-block-start: 0.15rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
}

.action-tile-primary .tile-sub {
  color: color-mix(in srgb, #fff 78%, transparent);
}

/* ----------------------------------------------------------- promo -- */
.promo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  margin-block-end: 1rem;
  border: 1px solid transparent;
}

.promo:hover {
  text-decoration: none;
}

.promo-icon {
  inline-size: 2.4rem;
  block-size: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 0.8rem;
  flex: none;
}

.promo-body {
  flex: 1;
  min-width: 0;
}

.promo-body strong {
  display: block;
  font-size: 0.95rem;
}

.promo-body span {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.88;
  margin-block-start: 0.12rem;
}

.promo-warn {
  background: var(--warn-soft);
  color: var(--warn-soft-ink);
  border-color: color-mix(in srgb, var(--warn) 22%, transparent);
}

.promo-warn .promo-icon {
  background: color-mix(in srgb, #fff 45%, transparent);
}

/* -------------------------------------------------------- timeline -- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0.4rem;
  display: grid;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-block-end: 1px solid var(--line);
}

.timeline-item:last-child {
  border-block-end: 0;
}

.timeline-main {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.timeline-main strong {
  font-size: 0.92rem;
  font-weight: 700;
}

.timeline-amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.9rem;
}

.timeline-amount.is-debit {
  color: var(--danger);
}

.timeline-amount.is-credit {
  color: var(--ok);
}

/* --------------------------------------------------- notice cards -- */
.notice-card {
  position: relative;
}

.notice-card.is-unread {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface));
}

.notice-card.is-unread::before {
  content: "";
  position: absolute;
  inset-block: 0.85rem;
  inset-inline-start: 0;
  inline-size: 0.28rem;
  border-radius: var(--radius-full);
  background: var(--brand);
}

/* ------------------------------------------------------- copy row -- */
.copy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.copy-row .copy-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.copy-row .k {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.copy-row .v {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.bank-card {
  display: grid;
  gap: 0.55rem;
}

.bank-card + .bank-card {
  margin-block-start: 0.85rem;
  padding-block-start: 0.85rem;
  border-block-start: 1px dashed var(--line);
}

.auth-toolbar {
  position: absolute;
  inset-block-start: calc(0.75rem + var(--safe-t));
  inset-inline-end: 0.75rem;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(12px);
}

.auth-wrap {
  position: relative;
}

/* ---------------------------------------------------------- breakpoints -- */
@media (min-width: 600px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile-grid .action-tile-primary {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  h1 {
    font-size: 1.6rem;
  }

  .container {
    padding-inline: 1.5rem;
  }

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card {
    padding: 1.35rem;
  }

  .card-flush {
    padding: 0;
  }

  .card-flush > .card-head {
    padding: 1.35rem 1.35rem 0;
  }

  .card-flush table thead th:first-child,
  .card-flush table tbody td:first-child {
    padding-inline-start: 1.35rem;
  }

  .card-flush table thead th:last-child,
  .card-flush table tbody td:last-child {
    padding-inline-end: 1.35rem;
  }

  .stat .value {
    font-size: 1.3rem;
  }
}

/* Desktop: swap the bottom tab bar for a persistent sidebar so every
   destination is visible at once. */
@media (min-width: 1024px) {
  .bottom-nav,
  .topbar-mobile-only {
    display: none;
  }

  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-block-size: 100dvh;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: sticky;
    top: 0;
    block-size: 100dvh;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
  }

  .sidebar .brand {
    padding: 0.35rem 0.5rem 1rem;
  }

  .sidebar-group {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--faint);
    padding: 0.85rem 0.75rem 0.3rem;
  }

  .sidebar a,
  .sidebar button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-2);
    text-decoration: none;
    cursor: pointer;
    inline-size: 100%;
    text-align: start;
  }

  .sidebar a:hover,
  .sidebar button:hover {
    background: var(--surface-sunken);
    color: var(--ink);
    text-decoration: none;
  }

  .sidebar .is-active {
    background: var(--brand-soft);
    color: var(--brand-soft-ink);
    font-weight: 700;
  }

  .sidebar svg {
    color: var(--muted);
  }

  .sidebar .is-active svg {
    color: inherit;
  }

  /* Pinned to the bottom of the sidebar's own scroll area: a long nav list
     must never push "log out" out of reach. */
  .sidebar-foot {
    position: sticky;
    inset-block-end: 0;
    margin-block-start: auto;
    padding-block: 0.75rem;
    border-block-start: 1px solid var(--line);
    background: var(--surface);
  }

  body:has(.sidebar) .app-meta-global {
    display: none;
  }

  .page {
    padding-block: 1.75rem 3rem;
  }

  /* The sidebar already shows the current page and the notification link, so
     the mobile top bar would only repeat the <h1> below it. */
  .topbar {
    display: none;
  }

  .container {
    width: min(68rem, 100%);
    padding-inline: 2rem;
  }
}

@media print {
  .topbar,
  .sidebar,
  .bottom-nav,
  .page-actions,
  .actions,
  .flash,
  .app-meta,
  .app-versions {
    display: none !important;
  }

  .page {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border-color: #ccc;
    break-inside: avoid;
  }
}
