/* =============================================================================
   SplitUPI — assets/styles.css
   -----------------------------------------------------------------------------
   The complete design system and every component style for the app.

   Contents
     01  Design tokens — light palette (bare :root)
     02  Design tokens — dark palette (media query + [data-theme])
     03  Reset & base elements
     04  Typography
     05  Accessibility utilities (skip link, sr-only, focus ring)
     06  Layout primitives (.row .stack .cluster .grid .container)
     07  App shell (header, sidebar, bottom nav, FAB, main)
     08  Page header
     09  Cards & surfaces
     10  Buttons
     11  Forms (input, select, textarea, field, invalid state)
     12  Segmented control
     13  Chips
     14  Lists
     15  Avatars & the 8-colour member palette
     16  Badges
     17  Tabs
     18  Tables
     19  Money
     20  Stat tile & dividers
     21  Modal dialog
     22  Bottom sheet
     23  Toasts
     24  Skeleton loading
     25  Empty states
     26  UPI surfaces & .qr-frame
     27  Charts
     28  Motion (keyframes + reduced motion)
     29  Responsive — 640px
     30  Responsive — 960px
     31  Print

   Zero dependencies: no external stylesheet, no framework, no web font
   download. The type stack degrades to the platform UI font everywhere.
   ========================================================================== */


/* =============================================================================
   01  DESIGN TOKENS — LIGHT PALETTE
   Every colour is defined here on bare :root so that no value exists only
   inside a media query. Dark mode redefines these same names in section 02.
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- Surfaces ---------------------------------------------------------- */
  --bg: #f5f4fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceafa;
  --surface: #ffffff;
  --surface-hover: #f3f1fc;
  --border: #e3e0f1;
  --border-strong: #c8c2e0;

  /* --- Ink ---------------------------------------------------------------
     Contrast on --surface (#ffffff):
       --text        #1a1730  ~16.4:1   AAA
       --text-muted  #56517a   ~7.4:1   AAA
       --text-faint  #726c94   ~4.8:1   AA
     Nothing lighter than --text-faint is ever used for meaningful text. */
  --text: #1a1730;
  --text-muted: #56517a;
  --text-faint: #726c94;

  /* --- Accent: deep indigo/violet ---------------------------------------- */
  --accent: #5233c9;
  --accent-hover: #4326b3;
  --accent-active: #371f96;
  --accent-soft: #ebe6fd;
  --accent-soft-hover: #ded5fb;
  --accent-contrast: #ffffff;
  --accent-ring: rgba(82, 51, 201, 0.42);

  /* --- Semantic money colours -------------------------------------------- */
  --positive: #0e7c52;          /* 5.2:1 on white — "you are owed" */
  --positive-soft: #ddf4e9;
  --positive-strong: #0a5f3f;
  --negative: #cf2f45;          /* 5.1:1 on white — "you owe" */
  --negative-soft: #fde9ec;
  --negative-strong: #a91f34;
  --warning: #9a5b06;           /* 5.4:1 on white */
  --warning-soft: #fbeed6;
  --info: #0b6ba8;
  --info-soft: #e0f0fb;

  /* --- Radii -------------------------------------------------------------- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  /* --- Elevation ---------------------------------------------------------
     Soft, indigo-tinted and low opacity. Never a heavy black drop shadow. */
  --shadow-sm: 0 1px 2px rgba(26, 23, 48, 0.06), 0 1px 1px rgba(26, 23, 48, 0.04);
  --shadow: 0 4px 14px rgba(26, 23, 48, 0.08), 0 1px 3px rgba(26, 23, 48, 0.05);
  --shadow-lg: 0 20px 48px rgba(26, 23, 48, 0.14), 0 6px 14px rgba(26, 23, 48, 0.07);
  --shadow-accent: 0 6px 18px rgba(82, 51, 201, 0.24);

  /* --- Spacing: 8px based, with 4px half-steps ---------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

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

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --text-xl: clamp(1.1875rem, 1.06rem + 0.65vw, 1.4375rem);
  --text-2xl: clamp(1.4375rem, 1.24rem + 1vw, 1.9375rem);
  --text-3xl: clamp(1.75rem, 1.4rem + 1.75vw, 2.625rem);

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading: 1.55;

  --weight-normal: 420;
  --weight-medium: 560;
  --weight-semibold: 640;
  --weight-bold: 720;

  /* --- Motion ------------------------------------------------------------- */
  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 340ms;

  /* --- Layout metrics ----------------------------------------------------- */
  --tap: 44px;                       /* minimum interactive target */
  --header-h: 56px;
  --bottom-nav-h: 62px;
  --sidebar-w: 248px;
  --content-max: 1120px;
  --reading-max: 720px;

  /* --- Stacking ----------------------------------------------------------- */
  --z-sticky: 30;
  --z-nav: 40;
  --z-fab: 45;
  --z-sheet: 60;
  --z-modal: 70;
  --z-toast: 90;

  /* --- Member avatar palette (8 deterministic colours) --------------------
     Light mode: deep hues carrying white ink (--avatar-ink). */
  --member-1: #5233c9;
  --member-2: #0e7c52;
  --member-3: #c2410c;
  --member-4: #0369a1;
  --member-5: #9d1aa8;
  --member-6: #b45309;
  --member-7: #0f766e;
  --member-8: #be123c;
  --avatar-ink: #ffffff;

  /* --- UPI brand accents (used for the app-link buttons) ------------------ */
  --upi-gradient: linear-gradient(135deg, #5233c9 0%, #7b4fe0 48%, #16a06a 140%);
  --upi-tint: linear-gradient(180deg, rgba(82, 51, 201, 0.07), rgba(14, 124, 82, 0.05));
}


/* =============================================================================
   02  DESIGN TOKENS — DARK PALETTE
   Declared twice on purpose:
     (a) under prefers-color-scheme, guarded so an explicit light choice wins;
     (b) under [data-theme="dark"], so the in-app toggle wins over the OS.
   Dark mode expresses elevation through lightness, not shadow.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0e0c17;
    --bg-elevated: #1d1930;
    --bg-sunken: #08070f;
    --surface: #191628;
    --surface-hover: #232038;
    --border: #2c2843;
    --border-strong: #423c62;

    --text: #ece9f7;
    --text-muted: #a49ec4;
    --text-faint: #837cab;

    --accent: #9d86ff;
    --accent-hover: #b29dff;
    --accent-active: #c4b4ff;
    --accent-soft: #251d49;
    --accent-soft-hover: #2f2559;
    --accent-contrast: #150c2b;
    --accent-ring: rgba(157, 134, 255, 0.55);

    --positive: #3ddc97;
    --positive-soft: #0f3527;
    --positive-strong: #6ceab3;
    --negative: #ff7a8a;
    --negative-soft: #3c1421;
    --negative-strong: #ffa3ad;
    --warning: #f5b64a;
    --warning-soft: #392a0d;
    --info: #63bdf2;
    --info-soft: #0e2c41;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.36);
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.44);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.58);
    --shadow-accent: 0 8px 24px rgba(78, 50, 168, 0.5);

    --member-1: #9d86ff;
    --member-2: #3ddc97;
    --member-3: #ff9563;
    --member-4: #5cb8f5;
    --member-5: #e97ce8;
    --member-6: #f5c04a;
    --member-7: #45cfc0;
    --member-8: #ff849e;
    --avatar-ink: #140f26;

    --upi-gradient: linear-gradient(135deg, #6b48e6 0%, #9d86ff 48%, #2bbf86 140%);
    --upi-tint: linear-gradient(180deg, rgba(157, 134, 255, 0.12), rgba(61, 220, 151, 0.06));
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e0c17;
  --bg-elevated: #1d1930;
  --bg-sunken: #08070f;
  --surface: #191628;
  --surface-hover: #232038;
  --border: #2c2843;
  --border-strong: #423c62;

  --text: #ece9f7;
  --text-muted: #a49ec4;
  --text-faint: #837cab;

  --accent: #9d86ff;
  --accent-hover: #b29dff;
  --accent-active: #c4b4ff;
  --accent-soft: #251d49;
  --accent-soft-hover: #2f2559;
  --accent-contrast: #150c2b;
  --accent-ring: rgba(157, 134, 255, 0.55);

  --positive: #3ddc97;
  --positive-soft: #0f3527;
  --positive-strong: #6ceab3;
  --negative: #ff7a8a;
  --negative-soft: #3c1421;
  --negative-strong: #ffa3ad;
  --warning: #f5b64a;
  --warning-soft: #392a0d;
  --info: #63bdf2;
  --info-soft: #0e2c41;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.36);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.44);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.58);
  --shadow-accent: 0 8px 24px rgba(78, 50, 168, 0.5);

  --member-1: #9d86ff;
  --member-2: #3ddc97;
  --member-3: #ff9563;
  --member-4: #5cb8f5;
  --member-5: #e97ce8;
  --member-6: #f5c04a;
  --member-7: #45cfc0;
  --member-8: #ff849e;
  --avatar-ink: #140f26;

  --upi-gradient: linear-gradient(135deg, #6b48e6 0%, #9d86ff 48%, #2bbf86 140%);
  --upi-tint: linear-gradient(180deg, rgba(157, 134, 255, 0.12), rgba(61, 220, 151, 0.06));
}


/* =============================================================================
   03  RESET & BASE ELEMENTS
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg[data-fill="true"] {
  fill: currentColor;
  stroke: none;
}

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

button {
  background: none;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

hr {
  height: 1px;
  border: 0;
  background: var(--border);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

:root {
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}


/* =============================================================================
   04  TYPOGRAPHY
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.021em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

h4 {
  font-size: var(--text-md);
}

h5,
h6 {
  font-size: var(--text-base);
}

p {
  text-wrap: pretty;
}

small {
  font-size: var(--text-sm);
}

code,
kbd,
samp,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

code:not(pre code) {
  padding: 0.12em 0.4em;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
}

/* --- Text utilities ------------------------------------------------------ */

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

.faint {
  color: var(--text-faint);
}

.text-xs {
  font-size: var(--text-xs);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.strong {
  font-weight: var(--weight-semibold);
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}


/* =============================================================================
   05  ACCESSIBILITY UTILITIES
   ========================================================================== */

/* Visually hidden but available to assistive technology. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The skip link is hidden until focused, then lands as a real, visible chip. */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: 50%;
  z-index: calc(var(--z-toast) + 1);
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-5);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, calc(-100% - var(--space-6)));
  transition: transform var(--dur) var(--ease-out);
}

.skip-link:focus-visible,
.skip-link:focus {
  transform: translate(-50%, 0);
}

/* One focus treatment for the whole app: an accent ring with real offset. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.btn:focus-visible,
.btn-icon:focus-visible,
.chip:focus-visible,
.tab:focus-visible,
.list-item:focus-visible,
.nav-item:focus-visible,
.fab:focus-visible,
.segmented > *:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}


/* =============================================================================
   06  LAYOUT PRIMITIVES
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* Horizontal row: children on one line, space between by default. */
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.row-between {
  justify-content: space-between;
}

.row-end {
  justify-content: flex-end;
}

.row-start {
  align-items: flex-start;
}

.row-baseline {
  align-items: baseline;
}

/* Vertical rhythm container. */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.stack-1 { gap: var(--space-1); }
.stack-2 { gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.stack-5 { gap: var(--space-5); }
.stack-6 { gap: var(--space-6); }

/* Wrapping inline group — chips, filters, action buttons. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.cluster-3 { gap: var(--space-3); }

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

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

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.fill {
  flex: 1 1 auto;
  min-width: 0;
}

.reading {
  max-width: var(--reading-max);
}

.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.hide {
  display: none !important;
}


/* =============================================================================
   07  APP SHELL
   Mobile: sticky header + fixed bottom tab bar + floating action button.
   Desktop (>= 960px): left sidebar, wider content column, no bottom bar.
   ========================================================================== */

.app {
  display: grid;
  grid-template-areas:
    "header"
    "main";
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Header -------------------------------------------------------------- */

.app-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--header-h);
  padding: var(--space-2) var(--space-4);
  padding-top: max(var(--space-2), env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header {
    background: var(--bg);
  }
}

.app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  background: var(--upi-gradient);
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  border-radius: 9px;
  box-shadow: var(--shadow-accent);
}

.app-header-title {
  min-width: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

/* --- Sidebar (desktop only; revealed in section 30) ---------------------- */

.sidebar {
  grid-area: sidebar;
  display: none;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-4);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-heading {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* --- Nav items: shared by sidebar and bottom bar ------------------------- */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border-radius: var(--radius);
  transition: background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item[aria-current="page"],
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.nav-item .nav-count {
  margin-left: auto;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

/* --- Main ---------------------------------------------------------------- */

.app-main {
  grid-area: main;
  min-width: 0;
}

.view,
#view {
  display: block;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--space-4) var(--space-4)
    calc(var(--bottom-nav-h) + var(--space-8) + env(safe-area-inset-bottom));
}

.view > * + * {
  margin-top: var(--space-4);
}

/* --- Bottom tab bar (mobile) -------------------------------------------- */

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-nav);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  min-height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav {
    background: var(--bg-elevated);
  }
}

.bottom-nav .nav-item {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: var(--bottom-nav-h);
  padding: var(--space-2) var(--space-1);
  font-size: 10.5px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  border-radius: 0;
  text-align: center;
}

.bottom-nav .nav-item:hover {
  background: transparent;
  color: var(--text);
}

.bottom-nav .nav-item[aria-current="page"],
.bottom-nav .nav-item.is-active {
  position: relative;
  background: transparent;
  color: var(--accent);
}

.bottom-nav .nav-item[aria-current="page"]::before,
.bottom-nav .nav-item.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 26px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
  transform: translateX(-50%);
}

.bottom-nav .nav-item:active {
  transform: scale(0.94);
  transition: transform var(--dur-fast) var(--ease);
}

/* --- Floating action button --------------------------------------------- */

.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--bottom-nav-h) + var(--space-4) + env(safe-area-inset-bottom));
  z-index: var(--z-fab);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 56px;
  min-height: 56px;
  padding: 0 var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-accent), var(--shadow);
  transition: transform var(--dur) var(--ease-out),
    background-color var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.fab:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.fab:active {
  background: var(--accent-active);
  transform: translateY(0) scale(0.96);
}

.fab svg {
  stroke-width: 2.25;
}

/* Icon-only variant keeps a perfect circle. */
.fab.fab-round {
  min-width: 56px;
  padding: 0;
}


/* =============================================================================
   08  PAGE HEADER
   ========================================================================== */

.page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.page-header-back {
  flex: none;
  margin-left: calc(var(--space-2) * -1);
}

.page-header-text {
  min-width: 0;
  flex: 1 1 auto;
}

.page-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.026em;
}

.page-header-subtitle {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-base);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  margin-left: auto;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}


/* =============================================================================
   09  CARDS & SURFACES
   ========================================================================== */

.card {
  position: relative;
  display: block;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card > * + * {
  margin-top: var(--space-3);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-quiet {
  background: var(--bg-elevated);
  box-shadow: none;
}

.card-sunken {
  background: var(--bg-sunken);
  border-color: transparent;
  box-shadow: none;
}

.card-accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: none;
}

/* Interactive card (a whole group tile, for instance). */
.card-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.card-link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card-link:active {
  transform: translateY(0) scale(0.994);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
}

.card-header + .card-body {
  margin-top: var(--space-3);
}

.card-body {
  padding: 0 var(--space-4);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
}

.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
}

.card-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
}


/* =============================================================================
   10  BUTTONS
   ========================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-faint);
}

.btn:active {
  transform: scale(0.975);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}

/* --- Primary ------------------------------------------------------------- */

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: transparent;
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn-primary:active {
  background: var(--accent-active);
}

.btn-primary:disabled:hover,
.btn-primary[aria-disabled="true"]:hover {
  background: var(--accent);
}

/* --- Ghost --------------------------------------------------------------- */

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: transparent;
}

.btn-ghost:active {
  background: var(--bg-sunken);
}

.btn-ghost:disabled:hover,
.btn-ghost[aria-disabled="true"]:hover {
  background: transparent;
}

/* --- Danger -------------------------------------------------------------- */

.btn-danger {
  background: var(--negative);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--negative) 28%, transparent);
}

.btn-danger:hover {
  background: var(--negative-strong);
  border-color: transparent;
}

.btn-danger:active {
  background: var(--negative-strong);
}

.btn-danger:focus-visible {
  outline-color: var(--negative);
}

.btn-danger:disabled:hover,
.btn-danger[aria-disabled="true"]:hover {
  background: var(--negative);
}

:root[data-theme="dark"] .btn-danger,
:root[data-theme="dark"] .btn-danger:hover {
  color: #2a0810;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger,
  :root:not([data-theme="light"]) .btn-danger:hover {
    color: #2a0810;
  }
}

/* Quiet danger: destructive but not shouting. */
.btn-danger-ghost {
  background: transparent;
  color: var(--negative);
  border-color: transparent;
  box-shadow: none;
}

.btn-danger-ghost:hover {
  background: var(--negative-soft);
  color: var(--negative-strong);
  border-color: transparent;
}

/* --- Soft / secondary accent -------------------------------------------- */

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}

.btn-soft:hover {
  background: var(--accent-soft-hover);
  border-color: transparent;
}

/* --- Icon-only ----------------------------------------------------------- */

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-icon:disabled,
.btn-icon[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-icon.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- Sizes & shapes ------------------------------------------------------ */

.btn-sm {
  min-height: 34px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-sm svg {
  width: 15px;
  height: 15px;
}

.btn-lg {
  min-height: 52px;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-md);
  border-radius: var(--radius-lg);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-pill {
  border-radius: var(--radius-full);
}

/* --- Loading state -------------------------------------------------------
   The label is faded and a spinner is centred over the button so its width
   never changes mid-request. */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading > * {
  opacity: 0;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  color: var(--text);
  opacity: 0.85;
  animation: spin 620ms linear infinite;
}

.btn-primary.is-loading::after {
  color: var(--accent-contrast);
}

.btn-danger.is-loading::after {
  color: #ffffff;
}

/* --- Button groups ------------------------------------------------------- */

.btn-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.btn-row-end {
  justify-content: flex-end;
}


/* =============================================================================
   11  FORMS
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field-label,
.field > label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.field-required {
  color: var(--negative);
}

.field-hint {
  font-size: var(--text-sm);
  color: var(--text-faint);
  line-height: var(--leading-snug);
}

.field-error {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--negative);
  line-height: var(--leading-snug);
}

.field-error svg {
  width: 15px;
  height: 15px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--text-md);
  line-height: 1.4;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) {
  border-color: var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--bg-sunken);
  color: var(--text-faint);
  cursor: not-allowed;
}

.input[readonly] {
  background: var(--bg-sunken);
}

.textarea {
  min-height: 92px;
  padding: var(--space-3);
  line-height: var(--leading);
  resize: vertical;
  field-sizing: content;
}

/* Native select gets its own chevron, drawn as an inline data URI so nothing
   is fetched from the network. Two variants keep the arrow legible per theme. */
.select {
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2356517a' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px 16px;
  cursor: pointer;
}

:root[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a49ec4' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a49ec4' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  }
}

/* --- Invalid state ------------------------------------------------------- */

.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid,
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--negative);
  background: color-mix(in srgb, var(--negative-soft) 55%, var(--bg-elevated));
}

.input.is-invalid:focus,
.select.is-invalid:focus,
.textarea.is-invalid:focus,
.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  border-color: var(--negative);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--negative) 32%, transparent);
}

.field.is-invalid .field-label {
  color: var(--negative);
}

/* --- Input decorations --------------------------------------------------- */

.input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-group .input {
  padding-left: var(--space-7);
}

.input-group-icon {
  position: absolute;
  left: var(--space-3);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  pointer-events: none;
}

.input-group-icon svg {
  width: 18px;
  height: 18px;
}

.input-suffix {
  position: absolute;
  right: var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-sm);
  pointer-events: none;
}

/* Amount entry — large, mono, tabular so the rupee figure is unmistakable. */
.input-amount {
  padding-left: var(--space-7);
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-height: 60px;
}

.input-amount-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-amount-symbol {
  position: absolute;
  left: var(--space-4);
  color: var(--text-faint);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  pointer-events: none;
}

/* VPA entry is mono so handles stay readable. */
.input-vpa {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  letter-spacing: -0.01em;
}

/* --- Checkbox & radio ---------------------------------------------------- */

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  cursor: pointer;
  user-select: none;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check-label {
  min-width: 0;
  font-size: var(--text-base);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: background-color var(--dur) var(--ease);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- Form layout --------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

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

fieldset {
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
}


/* =============================================================================
   12  SEGMENTED CONTROL
   Works with buttons ([aria-pressed] / [aria-selected] / .is-active) and with
   a radio group (input.sr-only + label).
   ========================================================================== */

.segmented {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.segmented-block {
  display: flex;
  width: 100%;
}

.segmented > button,
.segmented > label,
.segmented-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-height: 38px;
  padding: var(--space-1) var(--space-3);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.segmented > button:hover,
.segmented > label:hover,
.segmented-option:hover {
  color: var(--text);
}

.segmented > button[aria-pressed="true"],
.segmented > button[aria-selected="true"],
.segmented > button.is-active,
.segmented-option.is-active,
.segmented input:checked + label,
.segmented > label:has(input:checked) {
  background: var(--surface);
  color: var(--accent);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

.segmented input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented svg {
  width: 16px;
  height: 16px;
}


/* =============================================================================
   13  CHIPS
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.chip:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.chip:active {
  transform: scale(0.96);
}

.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.chip:disabled,
.chip[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.chip svg {
  width: 15px;
  height: 15px;
}

/* Colour-tinted chip: set --chip-color inline (e.g. a category colour). */
.chip[style*="--chip-color"] {
  border-color: color-mix(in srgb, var(--chip-color) 35%, transparent);
  color: var(--chip-color);
}

.chip[style*="--chip-color"].is-active,
.chip[style*="--chip-color"][aria-pressed="true"] {
  background: color-mix(in srgb, var(--chip-color) 14%, transparent);
  border-color: color-mix(in srgb, var(--chip-color) 55%, transparent);
  color: var(--chip-color);
}

.chip-dot {
  width: 8px;
  height: 8px;
  flex: none;
  background: currentColor;
  border-radius: 50%;
}

/* Removable chip: the × is its own tap target. */
.chip-remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: -4px;
  color: inherit;
  border-radius: 50%;
  opacity: 0.65;
}

.chip-remove:hover {
  background: color-mix(in srgb, currentColor 16%, transparent);
  opacity: 1;
}

.chip-remove svg {
  width: 12px;
  height: 12px;
}

/* A static, non-interactive chip. */
.chip-static {
  cursor: default;
}

.chip-static:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}

.chip-static:active {
  transform: none;
}


/* =============================================================================
   14  LISTS
   ========================================================================== */

.list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.list-plain {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  gap: var(--space-2);
  overflow: visible;
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 60px;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  transition: background-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.list > .list-item:last-child,
.list-item:last-child {
  border-bottom: 0;
}

.list-plain > .list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Press feedback only where the row actually does something. */
a.list-item,
button.list-item,
.list-item.is-pressable {
  cursor: pointer;
}

a.list-item:hover,
button.list-item:hover,
.list-item.is-pressable:hover {
  background: var(--surface-hover);
}

a.list-item:active,
button.list-item:active,
.list-item.is-pressable:active {
  background: var(--bg-sunken);
  transform: scale(0.988);
}

.list-item.is-selected {
  background: var(--accent-soft);
}

.list-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.list-item-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
  text-align: right;
}

.list-item-lead {
  display: grid;
  place-items: center;
  flex: none;
}

.list-item-chevron {
  flex: none;
  color: var(--text-faint);
}

.list-item-chevron svg {
  width: 18px;
  height: 18px;
}

/* Section label inside a list. */
.list-group-label {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

/* A leading icon tile, e.g. the expense category glyph. */
.icon-tile {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius);
}

.icon-tile svg {
  width: 20px;
  height: 20px;
}

.icon-tile-positive {
  background: var(--positive-soft);
  color: var(--positive);
}

.icon-tile-negative {
  background: var(--negative-soft);
  color: var(--negative);
}

.icon-tile-neutral {
  background: var(--bg-sunken);
  color: var(--text-muted);
}


/* =============================================================================
   15  AVATARS
   ========================================================================== */

.avatar {
  --avatar-size: 36px;
  --avatar-bg: var(--member-1);
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex: none;
  background: var(--avatar-bg);
  color: var(--avatar-ink);
  font-size: calc(var(--avatar-size) * 0.38);
  font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
  line-height: 1;
  text-transform: uppercase;
  border-radius: 50%;
  user-select: none;
  overflow: hidden;
}

.avatar[data-color="1"] { --avatar-bg: var(--member-1); }
.avatar[data-color="2"] { --avatar-bg: var(--member-2); }
.avatar[data-color="3"] { --avatar-bg: var(--member-3); }
.avatar[data-color="4"] { --avatar-bg: var(--member-4); }
.avatar[data-color="5"] { --avatar-bg: var(--member-5); }
.avatar[data-color="6"] { --avatar-bg: var(--member-6); }
.avatar[data-color="7"] { --avatar-bg: var(--member-7); }
.avatar[data-color="8"] { --avatar-bg: var(--member-8); }

.avatar-sm { --avatar-size: 26px; }
.avatar-lg { --avatar-size: 48px; }
.avatar-xl { --avatar-size: 64px; }

/* "You" gets a ring so the user can find themselves instantly. */
.avatar.is-me {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.avatar-muted {
  --avatar-bg: var(--bg-sunken);
  color: var(--text-muted);
}

/* Overlapping stack for "paid by these 3 people". */
.avatar-stack {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding-left: 6px;
}

.avatar-stack > .avatar {
  margin-left: -8px;
  box-shadow: 0 0 0 2px var(--surface);
}

.avatar-stack > .avatar:first-child {
  margin-left: 0;
}

.avatar-more {
  --avatar-bg: var(--bg-sunken);
  color: var(--text-muted);
  font-size: calc(var(--avatar-size) * 0.34);
}

/* Name + avatar pair. */
.member-line {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.member-name {
  min-width: 0;
  font-weight: var(--weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* =============================================================================
   16  BADGES
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  line-height: 1.5;
  white-space: nowrap;
  border-radius: var(--radius-full);
}

.badge svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.25;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-positive {
  background: var(--positive-soft);
  color: var(--positive);
}

.badge-negative {
  background: var(--negative-soft);
  color: var(--negative);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
}

/* A small count bubble, e.g. unsettled transfers. */
.badge-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-full);
}


/* =============================================================================
   17  TABS
   ========================================================================== */

.tabs {
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  padding-bottom: 1px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  text-decoration: none;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.tab::after {
  content: "";
  position: absolute;
  inset: auto var(--space-2) -1px var(--space-2);
  height: 2px;
  background: transparent;
  border-radius: var(--radius-full) var(--radius-full) 0 0;
  transition: background-color var(--dur) var(--ease);
}

.tab[aria-selected="true"],
.tab.is-active {
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

.tab[aria-selected="true"]::after,
.tab.is-active::after {
  background: var(--accent);
}

.tab svg {
  width: 17px;
  height: 17px;
}

.tab .badge-count {
  min-width: 18px;
  height: 18px;
  font-size: 10px;
}

.tabpanel {
  padding-top: var(--space-4);
}

/* Pill tab variant used for in-card filters. */
.tabs-pill {
  border-bottom: 0;
  gap: var(--space-2);
}

.tabs-pill .tab {
  border-radius: var(--radius-full);
  min-height: 36px;
}

.tabs-pill .tab::after {
  display: none;
}

.tabs-pill .tab[aria-selected="true"],
.tabs-pill .tab.is-active {
  background: var(--accent-soft);
}


/* =============================================================================
   18  TABLES
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table th {
  position: sticky;
  top: 0;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.table tbody tr:hover td {
  background: var(--surface-hover);
}

.table td.num,
.table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tfoot td {
  background: var(--bg-sunken);
  font-weight: var(--weight-semibold);
}

.table-compact th,
.table-compact td {
  padding: var(--space-2) var(--space-3);
}


/* =============================================================================
   19  MONEY
   Every rupee figure uses the mono stack with tabular figures so columns of
   money line up exactly, whatever the digits.
   ========================================================================== */

.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.money-pos {
  color: var(--positive);
}

.money-neg {
  color: var(--negative);
}

.money-zero {
  color: var(--text-faint);
}

.money-lg {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}

.money-xl {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.money-sm {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.money-muted {
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

/* "You are owed ₹420" / "You owe ₹120" headline block. */
.money-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.money-summary-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

/* Inline balance pill used in lists. */
.money-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
}

.money-pill.money-pos {
  background: var(--positive-soft);
}

.money-pill.money-neg {
  background: var(--negative-soft);
}


/* =============================================================================
   20  STAT TILE & DIVIDERS
   ========================================================================== */

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat-label svg {
  width: 14px;
  height: 14px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stat-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.stat-delta-up {
  color: var(--positive);
}

.stat-delta-down {
  color: var(--negative);
}

.stat-accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
  box-shadow: none;
}

.stat-accent .stat-value {
  color: var(--accent);
}

.stat-positive .stat-value {
  color: var(--positive);
}

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

.stat-row {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* --- Dividers ------------------------------------------------------------ */

.divider {
  height: 1px;
  margin: var(--space-4) 0;
  background: var(--border);
  border: 0;
}

.divider-tight {
  margin: var(--space-2) 0;
}

/* Divider carrying a centred label: "or", "settled up". */
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: auto;
  background: none;
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.divider-label::before,
.divider-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.divider-vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
  margin: 0 var(--space-2);
  background: var(--border);
}


/* =============================================================================
   21  MODAL DIALOG
   Built on <dialog>, so the backdrop and top-layer behaviour come free.
   ========================================================================== */

.modal {
  width: min(520px, calc(100vw - var(--space-6)));
  max-width: 100%;
  max-height: min(86dvh, 780px);
  padding: 0;
  margin: auto;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal:not([open]) {
  display: none;
}

.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in var(--dur-slow) var(--ease-out) both;
}

.modal::backdrop {
  background: rgba(12, 10, 24, 0.46);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: backdrop-in var(--dur) var(--ease) both;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.modal-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

.modal-close {
  flex: none;
  margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-5) var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-header + .modal-body {
  padding-top: 0;
}

.modal-body > * + * {
  margin-top: var(--space-4);
}

.modal-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
}

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

.modal-actions-end {
  justify-content: flex-end;
}

.modal-actions-end .btn {
  flex: 0 0 auto;
}

/* Prevent background scroll while a modal or sheet is up. */
body.is-locked {
  overflow: hidden;
}


/* =============================================================================
   22  BOTTOM SHEET
   Mobile-first: slides up from the bottom edge, full width, with a grab handle.
   On desktop it centres like a modal (see section 30).
   ========================================================================== */

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 88dvh;
  padding: 0;
  margin: 0;
  background: var(--bg-elevated);
  color: var(--text);
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.sheet:not([open]) {
  display: none;
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-up var(--dur-slow) var(--ease-out) both;
}

.sheet::backdrop {
  background: rgba(12, 10, 24, 0.46);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: backdrop-in var(--dur) var(--ease) both;
}

.sheet.is-closing {
  animation: sheet-down var(--dur) var(--ease) both;
}

.sheet-handle {
  display: grid;
  place-items: center;
  flex: none;
  padding: var(--space-2) 0 var(--space-1);
  cursor: grab;
  touch-action: none;
}

.sheet-handle::before {
  content: "";
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  padding: var(--space-2) var(--space-4) var(--space-3);
}

.sheet-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-4)
    calc(var(--space-5) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-body > * + * {
  margin-top: var(--space-4);
}

.sheet-actions {
  display: flex;
  gap: var(--space-2);
  flex: none;
  padding: var(--space-3) var(--space-4)
    calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

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


/* =============================================================================
   23  TOASTS
   Stacked bottom-centre, above the bottom nav, never blocking the FAB.
   ========================================================================== */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + var(--space-3) + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--space-2);
  width: min(440px, calc(100vw - var(--space-6)));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out) both;
}

.toast.is-leaving {
  animation: toast-out var(--dur) var(--ease) both;
}

.toast-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
}

.toast-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
}

.toast-message {
  flex: 1 1 auto;
  min-width: 0;
  line-height: var(--leading-snug);
}

.toast-close {
  flex: none;
  width: 28px;
  height: 28px;
  min-height: 28px;
  margin-right: calc(var(--space-1) * -1);
}

.toast-success {
  border-left-color: var(--positive);
}

.toast-success .toast-icon {
  color: var(--positive);
}

.toast-error {
  border-left-color: var(--negative);
}

.toast-error .toast-icon {
  color: var(--negative);
}

.toast-info {
  border-left-color: var(--accent);
}

.toast-info .toast-icon {
  color: var(--accent);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}


/* =============================================================================
   24  SKELETON LOADING
   ========================================================================== */

.skeleton {
  position: relative;
  display: block;
  min-height: 1em;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  overflow: hidden;
  color: transparent;
  user-select: none;
  pointer-events: none;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--surface) 78%, transparent) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: shimmer 1500ms var(--ease) infinite;
}

.skeleton-text {
  height: 0.85em;
  margin: 0.25em 0;
  border-radius: var(--radius-full);
}

.skeleton-title {
  width: 45%;
  height: 1.1em;
}

.skeleton-line {
  width: 100%;
}

.skeleton-line-short {
  width: 60%;
}

.skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.skeleton-card {
  height: 96px;
  border-radius: var(--radius-lg);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.skeleton-row:last-child {
  border-bottom: 0;
}


/* =============================================================================
   25  EMPTY STATES
   ========================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-1);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.6;
}

.empty-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
}

.empty-body {
  max-width: 40ch;
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: var(--leading);
  text-wrap: pretty;
}

.empty-action {
  margin-top: var(--space-2);
}

/* A compact empty state that sits inside a card. */
.empty-inline {
  padding: var(--space-5) var(--space-4);
  gap: var(--space-2);
}

.empty-inline .empty-icon {
  width: 44px;
  height: 44px;
}

.empty-inline .empty-icon svg {
  width: 20px;
  height: 20px;
}

/* "All settled up" celebration state. */
.empty-settled .empty-icon {
  background: var(--positive-soft);
  color: var(--positive);
}


/* =============================================================================
   26  UPI SURFACES & QR FRAME
   The UPI surfaces are deliberately the most decorated thing in the app: a
   gradient hairline and a tinted ground, so "pay" never looks like a grey box.
   ========================================================================== */

.upi-card {
  position: relative;
  padding: var(--space-5) var(--space-4);
  background:
    var(--upi-tint),
    var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Gradient hairline border drawn with a mask so it works on any background. */
.upi-card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  background: var(--upi-gradient);
  border-radius: inherit;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.upi-card > * {
  position: relative;
}

.upi-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.upi-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  background: var(--upi-gradient);
  color: #ffffff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: var(--radius-full);
}

.upi-vpa {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-sunken);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

.upi-vpa-missing {
  color: var(--warning);
  background: var(--warning-soft);
  font-family: var(--font);
}

/* Row of "Open in GPay / PhonePe / Paytm" launchers. */
.upi-apps {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.upi-app {
  --upi-app-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border: 1px solid var(--border);
  border-left: 3px solid var(--upi-app-color);
  border-radius: var(--radius);
  transition: background-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.upi-app:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.upi-app:active {
  transform: translateY(0) scale(0.97);
}

.upi-app-dot {
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--upi-app-color);
  border-radius: 50%;
}

/* --- The QR frame: a framed, printable payment card ---------------------- */

.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: var(--space-5);
  background: #ffffff;
  color: #16121f;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

/* The QR itself always sits on true white with a quiet zone, whatever the
   theme, because scanners need the contrast. */
.qr-frame-code {
  display: grid;
  place-items: center;
  padding: var(--space-3);
  background: #ffffff;
  border: 1px solid #e6e3f0;
  border-radius: var(--radius);
}

.qr-frame-code svg,
.qr-frame-code canvas,
.qr-frame-code img {
  display: block;
  width: min(240px, 62vw);
  height: auto;
  image-rendering: pixelated;
  shape-rendering: crispEdges;
}

.qr-frame-payee {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

.qr-frame-vpa {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #4a4468;
  word-break: break-all;
}

.qr-frame-amount {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: #2a1f6b;
}

.qr-frame-note {
  max-width: 32ch;
  font-size: var(--text-sm);
  color: #56517a;
  text-wrap: pretty;
}

.qr-frame-brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 10px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7a7499;
}

/* --- Settlement plan rows ------------------------------------------------ */

.transfer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.transfer-arrow {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--text-faint);
}

.transfer-arrow svg {
  width: 18px;
  height: 18px;
}

.transfer-parties {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
}

.transfer-amount {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

/* Marked paid: settles into a calm green and pulses once. */
.transfer.is-paid {
  background: var(--positive-soft);
  border-color: color-mix(in srgb, var(--positive) 35%, transparent);
  animation: success-pulse 900ms var(--ease-out) 1;
}

.transfer.is-paid .transfer-amount {
  color: var(--positive);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--positive) 55%, transparent);
}


/* =============================================================================
   27  CHARTS
   Inline SVG primitives from components.js; the stylesheet owns colour only.
   ========================================================================== */

.chart {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.7;
}

.chart-label {
  fill: var(--text-muted);
  stroke: none;
  font-family: var(--font);
  font-size: 11px;
}

.chart-value {
  fill: var(--text);
  stroke: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
}

.chart-bar-track {
  fill: var(--bg-sunken);
}

.chart-bar-fill {
  fill: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-area {
  fill: var(--accent);
  stroke: none;
  opacity: 0.12;
}

.chart-point {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2;
}

.donut-track {
  fill: none;
  stroke: var(--bg-sunken);
}

.donut-segment {
  fill: none;
  stroke-linecap: butt;
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out);
}

.donut-center-value {
  fill: var(--text);
  stroke: none;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-bold);
}

.donut-center-label {
  fill: var(--text-muted);
  stroke: none;
  font-family: var(--font);
  font-size: 11px;
}

/* Legend below a chart. */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 3px;
  background: var(--accent);
}

/* Simple horizontal meter used in balance breakdowns. */
.meter {
  width: 100%;
  height: 8px;
  background: var(--bg-sunken);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease-out);
}

.meter-fill.is-positive {
  background: var(--positive);
}

.meter-fill.is-negative {
  background: var(--negative);
}


/* =============================================================================
   28  MOTION
   Restrained and purposeful: sheets rise, toasts fade, rows depress, and a
   settled transfer pulses green exactly once.
   ========================================================================== */

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

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes sheet-down {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

@keyframes success-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--positive) 45%, transparent);
  }
  60% {
    box-shadow: 0 0 0 12px color-mix(in srgb, var(--positive) 0%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--positive) 0%, transparent);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fade-up var(--dur-slow) var(--ease-out) both;
}

/* --- Reduced motion ------------------------------------------------------
   Honour the preference completely: no slides, no shimmer, no pulse. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .skeleton::after {
    display: none;
  }

  .btn.is-loading::after {
    animation: none;
    border-top-color: currentColor;
    opacity: 0.4;
  }

  .btn:active,
  .chip:active,
  .list-item:active,
  .card-link:active,
  .fab:active,
  .upi-app:active,
  .bottom-nav .nav-item:active {
    transform: none;
  }
}


/* =============================================================================
   29  RESPONSIVE — 640px (large phone / small tablet)
   ========================================================================== */

@media (min-width: 640px) {
  :root {
    --header-h: 60px;
  }

  .container,
  .view,
  #view {
    padding-inline: var(--space-5);
  }

  .view,
  #view {
    padding-top: var(--space-5);
  }

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

  .form-grid .field-wide {
    grid-column: 1 / -1;
  }

  .form-actions {
    justify-content: flex-end;
  }

  .form-actions .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }

  .stat-row {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .modal-actions {
    justify-content: flex-end;
  }

  .modal-actions .btn {
    flex: 0 0 auto;
    min-width: 120px;
  }

  /* The sheet stops being full-bleed and gains rounded shoulders. */
  .sheet {
    left: 50%;
    right: auto;
    width: min(560px, calc(100vw - var(--space-6)));
    margin-inline: 0;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .sheet[open] {
    animation: sheet-up-centered var(--dur-slow) var(--ease-out) both;
  }

  .sheet.is-closing {
    animation: sheet-down-centered var(--dur) var(--ease) both;
  }

  @keyframes sheet-up-centered {
    from {
      transform: translate(-50%, 100%);
    }
    to {
      transform: translate(-50%, 0);
    }
  }

  @keyframes sheet-down-centered {
    from {
      transform: translate(-50%, 0);
    }
    to {
      transform: translate(-50%, 100%);
    }
  }

  .qr-frame {
    padding: var(--space-6);
  }

  .qr-frame-code svg,
  .qr-frame-code canvas,
  .qr-frame-code img {
    width: 260px;
  }

  .page-header-title {
    font-size: var(--text-3xl);
  }
}


/* =============================================================================
   30  RESPONSIVE — 960px (desktop)
   The bottom bar and FAB give way to a persistent sidebar and inline actions.
   ========================================================================== */

@media (min-width: 960px) {
  .app {
    grid-template-areas:
      "sidebar header"
      "sidebar main";
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .app-header {
    padding-inline: var(--space-6);
  }

  /* The brand lives in the sidebar on desktop. */
  .app-header .brand {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .fab {
    display: none;
  }

  .view,
  #view {
    padding: var(--space-6);
    padding-bottom: var(--space-8);
  }

  .toast-region {
    bottom: var(--space-5);
  }

  .grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .card {
    padding: var(--space-5);
  }

  .stat {
    padding: var(--space-5);
  }

  .stat-value {
    font-size: var(--text-2xl);
  }

  .list-group-label {
    top: var(--header-h);
  }

  /* Two-column split used by the settle and insights views. */
  .split {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    align-items: start;
  }

  .split-sticky {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
  }

  /* A sheet opened on desktop behaves like a centred modal. */
  .sheet {
    inset: 0;
    width: min(560px, calc(100vw - var(--space-7)));
    max-height: min(84dvh, 760px);
    margin: auto;
    transform: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .sheet[open],
  .sheet.is-closing {
    animation: modal-in var(--dur-slow) var(--ease-out) both;
  }

  .sheet-handle {
    display: none;
  }
}

@media (min-width: 1280px) {
  :root {
    --sidebar-w: 276px;
  }

  .view,
  #view {
    padding-inline: var(--space-7);
  }
}


/* =============================================================================
   31  PRINT
   A settlement plan should print as a clean white sheet: no chrome, no
   shadows, the QR intact and scannable.
   ========================================================================== */

@media print {
  :root {
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --bg-sunken: #ffffff;
    --surface: #ffffff;
    --surface-hover: #ffffff;
    --border: #c9c4de;
    --border-strong: #8e88ab;
    --text: #000000;
    --text-muted: #333042;
    --text-faint: #4a4560;
    --accent: #2a1f6b;
    --accent-soft: #ffffff;
    --positive: #0a5f3f;
    --negative: #a91f34;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: none;
    --shadow-accent: none;
  }

  @page {
    margin: 14mm;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app {
    display: block;
    min-height: 0;
  }

  /* Navigation, floating chrome and transient UI never print. */
  .app-header,
  .sidebar,
  .bottom-nav,
  .fab,
  .toast-region,
  .skip-link,
  .tabs,
  .segmented,
  .page-header-actions,
  .card-footer,
  .modal-actions,
  .sheet-actions,
  .btn,
  .btn-icon,
  .chip,
  .list-item-chevron,
  .skeleton,
  [data-print="hide"] {
    display: none !important;
  }

  .view,
  #view {
    max-width: none;
    padding: 0 !important;
    margin: 0;
  }

  .card,
  .list,
  .stat,
  .table-wrap,
  .upi-card,
  .transfer {
    background: #ffffff !important;
    border: 1px solid #c9c4de !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .upi-card::before {
    display: none;
  }

  .list-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* The QR is the point of the printout. */
  .qr-frame {
    display: flex !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .qr-frame-code {
    border-color: #000000 !important;
  }

  .qr-frame-code svg,
  .qr-frame-code canvas,
  .qr-frame-code img {
    width: 52mm !important;
    height: auto !important;
  }

  .qr-frame-amount,
  .qr-frame-payee,
  .qr-frame-vpa,
  .qr-frame-note {
    color: #000000 !important;
  }

  .money-pos {
    color: #0a5f3f !important;
  }

  .money-neg {
    color: #a91f34 !important;
  }

  .avatar {
    color: #ffffff !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .badge {
    border: 1px solid #c9c4de !important;
    background: #ffffff !important;
    color: #333042 !important;
  }

  a {
    color: #000000 !important;
    text-decoration: none;
  }

  /* Expose the destination of meaningful links in the printed copy. */
  .print-url::after {
    content: " (" attr(href) ")";
    font-family: var(--font-mono);
    font-size: 10px;
    word-break: break-all;
  }

  * {
    animation: none !important;
    transition: none !important;
  }
}


/* =============================================================================
   32  SPLITUPI APPLICATION VIEWS
   These small view-specific pieces sit on top of the reusable system above.
   ========================================================================== */

.text-sm { font-size: var(--text-sm); }
.centered { padding: var(--space-5); text-align: center; }

.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: var(--space-1); }
.sidebar-back { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3); color: var(--text-muted); font-size: var(--text-sm); text-decoration: none; }
.sidebar-title { margin: var(--space-3) var(--space-3) var(--space-1); overflow: hidden; color: var(--text); font-size: var(--text-lg); font-weight: var(--weight-bold); text-overflow: ellipsis; white-space: nowrap; }

/* auto-fill (not auto-fit) so a lone group stays card-sized instead of
   stretching across the whole content column. */
.group-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.group-card { display: flex; flex-direction: column; min-height: 210px; color: var(--text); text-decoration: none; transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.group-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.group-card-top { display: flex; align-items: center; gap: var(--space-2); }
.group-card-top .icon { margin-left: auto; color: var(--text-faint); }
.group-emoji { display: grid; width: 42px; height: 42px; place-items: center; background: var(--accent-soft); border-radius: var(--radius); font-size: 23px; }
.group-card h2 { margin: var(--space-4) 0 var(--space-1); font-size: var(--text-xl); letter-spacing: -0.03em; }
.group-card-money { display: flex; align-items: baseline; gap: var(--space-2); margin-top: auto; }
.group-card-money strong { font-family: var(--font-mono); font-size: var(--text-xl); letter-spacing: -0.04em; }
.group-card-footer { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--text-sm); }

.filter-row { display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr) minmax(120px, .42fr); margin-bottom: var(--space-4); }
.expense-row { color: var(--text); text-decoration: none; }
.expense-row-content { display: flex; width: 100%; align-items: center; gap: var(--space-3); }
.expense-row-icon { display: grid; width: 38px; height: 38px; flex: none; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); }
.expense-row-amount { flex: none; font-family: var(--font-mono); font-size: var(--text-md); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }

.participant-picker { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.participant-picker .chip { min-height: 36px; cursor: pointer; user-select: none; }
.participant-picker input { inline-size: 16px; block-size: 16px; accent-color: var(--accent); }
.split-details { min-height: 24px; }
.compact-card { padding: var(--space-3); }
.split-input-row { display: grid; align-items: center; gap: var(--space-3); grid-template-columns: minmax(0, 1fr) 130px; padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.split-input-row:first-of-type { border-top: 0; }
.amount-field { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.balance-hero { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); background: var(--accent-soft); }
.balance-hero strong { font-size: var(--text-xl); letter-spacing: -0.03em; }
.balance-hero.is-positive { background: var(--positive-soft); }
.balance-hero.is-negative { background: var(--negative-soft); }
.balance-row { gap: var(--space-3); }
.member-avatar-placeholder { display: grid; width: 38px; height: 38px; flex: none; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 50%; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.settle-summary { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); background: var(--accent-soft); }
.settle-summary strong { font-family: var(--font-mono); font-size: var(--text-xl); }
.transfer { flex-wrap: wrap; }
.transfer .cluster { margin-left: auto; }

.toggle-row { display: flex; align-items: center; gap: var(--space-4); min-height: var(--tap); cursor: pointer; }
.toggle-row input { inline-size: 20px; block-size: 20px; accent-color: var(--accent); }
.danger-zone { border-color: color-mix(in srgb, var(--negative) 35%, var(--border)); }
.danger-zone h2 { color: var(--negative); }

@media (min-width: 960px) {
  .sidebar { padding-top: var(--space-6); }
  .app-tabbar { display: none; }
}
