/* ==========================================================================
   MERCHANT WALLET — Daily Collections  ·  Owner PWA
   Design system: "Refined institutional fintech"
   Mercury / Ramp / Stripe-grade — sophisticated neutrals + deep emerald.
   Mobile-first (~402px) · elegant up to desktop · AA contrast · a11y aware.
   Authored as a complete rewrite against fixed markup (HTML never changes).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* --- Brand: deep emerald scale --- */
  --brand-25:  #f0fdf6;
  --brand-50:  #e6f9ef;
  --brand-100: #c9f0dc;
  --brand-200: #98e2bd;
  --brand-300: #5fcd97;
  --brand-400: #34b377;
  --brand-500: #16965c;   /* primary action */
  --brand-600: #0f7d4c;   /* hover / pressed */
  --brand-700: #0c6440;   /* hero base */
  --brand-800: #0a4e33;   /* hero deep */
  --brand-900: #073a27;   /* hero shadow / deepest */

  /* --- Neutrals: cool slate --- */
  --ink-900: #0c1411;   /* primary text */
  --ink-800: #18211d;
  --ink-700: #2a342f;
  --ink-600: #4a564f;   /* secondary text */
  --ink-500: #69756d;   /* muted text */
  --ink-400: #97a39a;   /* placeholder */
  --ink-300: #c3cbc6;
  --ink-200: #dde3df;   /* borders */
  --ink-150: #e7ebe8;
  --ink-100: #f1f4f2;   /* subtle fills */
  --ink-50:  #f7faf8;   /* app background */
  --white:   #ffffff;

  /* --- Semantic --- */
  --success:     #16965c;
  --success-bg:  #e6f9ef;
  --success-ink: #0c6440;
  --warning:     #c77d0a;
  --warning-bg:  #fdf3e2;
  --warning-ink: #8a5605;
  --danger:      #d23b46;
  --danger-bg:   #fdeaec;
  --danger-ink:  #9e2832;
  --info:        #2563c9;
  --info-bg:     #e8f0fd;

  /* --- Surfaces --- */
  --surface:        var(--white);
  --surface-sunken: var(--ink-50);
  --surface-raised: var(--white);
  --app-bg:         var(--ink-50);
  --border:         var(--ink-200);
  --border-strong:  var(--ink-300);

  /* --- Typography --- */
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-2xs: 10px;
  --fs-xs:  11.5px;
  --fs-sm:  13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  19px;
  --fs-2xl: 23px;
  --fs-3xl: 30px;
  --fs-hero: 34px;

  /* --- Spacing scale (4pt) --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* --- Radius --- */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* --- Shadows: soft, layered, low-spread --- */
  --sh-xs: 0 1px 2px rgba(12, 32, 24, .06);
  --sh-sm: 0 1px 3px rgba(12, 32, 24, .07), 0 1px 2px rgba(12, 32, 24, .04);
  --sh-md: 0 4px 12px rgba(12, 32, 24, .08), 0 2px 4px rgba(12, 32, 24, .05);
  --sh-lg: 0 12px 28px rgba(12, 32, 24, .12), 0 4px 10px rgba(12, 32, 24, .06);
  --sh-xl: 0 24px 60px rgba(12, 32, 24, .18), 0 8px 20px rgba(12, 32, 24, .08);
  --sh-hero: 0 18px 40px rgba(7, 58, 39, .32), 0 6px 14px rgba(7, 58, 39, .22);
  --ring: 0 0 0 4px rgba(22, 150, 92, .22);

  /* --- Motion --- */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-1: .14s;
  --dur-2: .22s;
  --dur-3: .34s;

  /* --- Layout --- */
  --shell-w: 402px;
  --nav-h: 68px;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink-900);
  background:
    radial-gradient(1100px 700px at 15% -10%, #eaf6ef 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 10%, #e9f3f7 0%, transparent 50%),
    var(--ink-100);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

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

button { font-family: inherit; cursor: pointer; }

input,
select,
textarea { font-family: inherit; }

a { color: var(--brand-600); text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-200);
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

::selection { background: var(--brand-200); color: var(--ink-900); }

/* --------------------------------------------------------------------------
   3. APP SHELL — phone window framing
   -------------------------------------------------------------------------- */
.phone-shell {
  width: 100%;
  max-width: var(--shell-w);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--app-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.status-bar {
  height: env(safe-area-inset-top, 0px);
  min-height: 0;
  background: transparent;
  flex: 0 0 auto;
}

.app-root {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--app-bg);
}

/* Desktop: float the phone as a polished app window */
@media (min-width: 768px) {
  body {
    align-items: center;
    padding: 32px 24px;
  }
  .phone-shell {
    min-height: 0;
    height: min(880px, calc(100vh - 64px));
    border-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    border: 1px solid rgba(12, 32, 24, .06);
    overflow: hidden;
  }
  .status-bar {
    min-height: 14px;
    background: linear-gradient(120deg, var(--brand-800), var(--brand-700));
  }
}

/* --------------------------------------------------------------------------
   4. SCREENS & TRANSITIONS  (JS toggles .active)
   -------------------------------------------------------------------------- */
.screen { display: none; }

.screen.active {
  display: block;
  animation: screen-in var(--dur-3) var(--ease-out) both;
}

/* Screens that own their own scroll/chrome become column flex */
#screen-dashboard.active,
#screen-profile.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   5. LOADING OVERLAY & SPINNER
   -------------------------------------------------------------------------- */
#loadingOverlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(247, 250, 248, .72);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
}
#loadingOverlay.active,
#loadingOverlay[style*="flex"],
#loadingOverlay[style*="block"] { display: flex; }

.loader {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3.5px solid var(--brand-100);
  border-top-color: var(--brand-500);
  animation: spin .8s linear infinite;
  box-shadow: var(--sh-sm);
}

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

/* --------------------------------------------------------------------------
   6. AUTH SCREEN
   -------------------------------------------------------------------------- */
.auth-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7) var(--sp-5) calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(120% 80% at 50% -20%, var(--brand-50) 0%, transparent 60%),
    var(--app-bg);
}

.auth-logo {
  width: 76px;
  height: 76px;
  border-radius: var(--r-lg);
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  box-shadow: var(--sh-hero), inset 0 1px 0 rgba(255, 255, 255, .22);
  margin-bottom: var(--sp-5);
  position: relative;
}
.auth-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.auth-logo-inner {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.auth-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.02em;
  text-align: center;
}

.auth-subtitle {
  font-size: var(--fs-sm);
  color: var(--ink-500);
  text-align: center;
  margin-top: var(--sp-1);
  margin-bottom: var(--sp-6);
  max-width: 280px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  box-shadow: var(--sh-lg);
}

/* --------------------------------------------------------------------------
   7. FORMS
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: var(--sp-4); }
.form-group:last-child { margin-bottom: 0; }

.form-label,
label.form-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-700);
  letter-spacing: .01em;
  margin-bottom: 6px;
}

.input,
.select,
select.input,
input.input {
  width: 100%;
  height: 46px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-md);
  color: var(--ink-900);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

textarea.input { height: auto; padding: var(--sp-3) var(--sp-4); resize: vertical; }

.input::placeholder { color: var(--ink-400); }

.input:hover,
.select:hover { border-color: var(--border-strong); }

.input:focus,
.select:focus,
select:focus {
  border-color: var(--brand-500);
  box-shadow: var(--ring);
  background: var(--white);
}

.input:read-only,
.input[readonly] {
  background: var(--ink-100);
  color: var(--ink-600);
  cursor: default;
  border-color: var(--ink-150);
}
.input:read-only:focus { box-shadow: none; border-color: var(--ink-150); }

.input:disabled,
.select:disabled { opacity: .6; cursor: not-allowed; }

/* Custom select chevron */
.select,
select.select,
select.input {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a564f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: 42px;
  cursor: pointer;
}

input[type="date"].input {
  cursor: pointer;
  min-height: 46px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: .55;
  cursor: pointer;
  filter: saturate(0);
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: .9; }

/* helper text under fields */
.form-group small.text-muted,
small.text-muted {
  display: block;
  margin-top: 5px;
  font-size: var(--fs-xs);
  color: var(--ink-500);
  line-height: 1.4;
}

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink-800);
}

.label-soft {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-600);
  cursor: pointer;
}

.label-soft input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-500);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  --btn-h: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 var(--sp-5);
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  background: var(--ink-100);
  color: var(--ink-800);
  white-space: nowrap;
  user-select: none;
  transition: transform var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Primary — emerald gradient */
.btn-primary {
  background: linear-gradient(160deg, var(--brand-500), var(--brand-600));
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(15, 125, 76, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover {
  background: linear-gradient(160deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 8px 18px rgba(15, 125, 76, .34), inset 0 1px 0 rgba(255, 255, 255, .18);
}

/* Secondary — solid emerald, slightly lighter/flat */
.btn-secondary {
  background: var(--brand-500);
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 3px 8px rgba(15, 125, 76, .22);
}
.btn-secondary:hover { background: var(--brand-600); }

/* Outline — emerald outline on white */
.btn-outline {
  background: var(--white);
  color: var(--brand-600);
  border-color: var(--brand-300);
}
.btn-outline:hover {
  background: var(--brand-25);
  border-color: var(--brand-500);
  color: var(--brand-700);
}

/* Ghost — quiet neutral */
.btn-ghost {
  background: transparent;
  color: var(--ink-600);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--ink-100);
  color: var(--ink-900);
}

/* Sizes */
.btn-full { width: 100%; display: flex; }
.btn-sm {
  --btn-h: 38px;
  height: var(--btn-h);
  padding: 0 var(--sp-4);
  font-size: var(--fs-sm);
  border-radius: var(--r-xs);
}
.btn-xs {
  --btn-h: 32px;
  height: var(--btn-h);
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--r-xs);
}

/* Ghost back-buttons (← Dashboard) — pill chip look */
.screen-inner > .btn-ghost.btn-sm:first-child {
  margin-bottom: var(--sp-2);
  padding-left: var(--sp-3);
  margin-left: calc(-1 * var(--sp-2));
  color: var(--ink-600);
}

.text-muted {
  color: var(--ink-500);
  font-size: var(--fs-sm);
}

/* --------------------------------------------------------------------------
   9. APP CHROME — top bar, scroll area, headings
   -------------------------------------------------------------------------- */
.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: calc(var(--sp-4)) var(--sp-5) var(--sp-3);
  background: rgba(247, 250, 248, .9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ink-150);
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.top-brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
  color: var(--white);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .5px;
  display: grid;
  place-items: center;
  box-shadow: var(--sh-sm), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.top-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.top-brand-text > span:first-child {
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-500);
}
.top-brand-text > span:nth-child(2) {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-brand-text .subtitle {
  font-size: var(--fs-xs);
  color: var(--ink-500);
  font-weight: 500;
}

.top-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(150deg, var(--brand-400), var(--brand-600));
  box-shadow: var(--sh-sm), inset 0 1px 0 rgba(255, 255, 255, .25);
  border: 2px solid var(--white);
}
.avatar-circle.large {
  width: 72px;
  height: 72px;
  font-size: var(--fs-2xl);
  border-width: 3px;
  box-shadow: var(--sh-md), inset 0 1px 0 rgba(255, 255, 255, .25);
}

/* Scrollable content region for dashboard/profile */
.main-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-5) var(--sp-5)
           calc(var(--nav-h) + var(--sp-6) + env(safe-area-inset-bottom, 0px));
}

/* Inner padding for the simple (non-scroll-chrome) screens */
.screen-inner {
  padding: var(--sp-5) var(--sp-5)
           calc(var(--nav-h) + var(--sp-6) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

.title-lg {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.02em;
  margin: var(--sp-2) 0 var(--sp-1);
}
.title-lg + .text-muted { margin-bottom: var(--sp-5); }

.section-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.01em;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-6) 0 var(--sp-3);
}

.subtitle {
  font-size: var(--fs-sm);
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   10. DASHBOARD — gradient hero balance card
   -------------------------------------------------------------------------- */
.balance-card {
  position: relative;
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5);
  color: var(--white);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 255, 255, .14) 0%, transparent 45%),
    radial-gradient(120% 120% at 100% 0%, rgba(95, 205, 151, .35) 0%, transparent 50%),
    linear-gradient(155deg, var(--brand-700) 0%, var(--brand-800) 55%, var(--brand-900) 100%);
  box-shadow: var(--sh-hero);
  overflow: hidden;
  isolation: isolate;
}
.balance-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}
.balance-card::after {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -70px;
  bottom: -110px;
  background: radial-gradient(circle, rgba(152, 226, 189, .28) 0%, transparent 70%);
  z-index: -1;
}

.balance-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .82);
}

.balance-amount {
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--white);
  margin: var(--sp-2) 0 var(--sp-4);
  line-height: 1.05;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.balance-sub {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip-on-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--white);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--r-pill);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Quick actions grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.action-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: var(--sp-3) var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-700);
  text-align: center;
  cursor: pointer;
  box-shadow: var(--sh-xs);
  transition: transform var(--dur-1) var(--ease),
              box-shadow var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease);
}
.action-pill:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--brand-200);
}
.action-pill:active { transform: translateY(0) scale(.98); }

.action-pill-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--brand-50), var(--brand-100));
  border: 1px solid var(--brand-100);
}
/* CRITICAL: icon must be high-contrast accent on the light tile */
.action-pill-icon i {
  font-size: 18px;
  color: var(--brand-600);
  line-height: 1;
}
.action-pill:hover .action-pill-icon {
  background: linear-gradient(150deg, var(--brand-100), var(--brand-200));
}
.action-pill:hover .action-pill-icon i { color: var(--brand-700); }

/* --------------------------------------------------------------------------
   11. CARDS / CARD-LIST  (JS toggles inline display on some — no !important)
   -------------------------------------------------------------------------- */
.card-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-sm);
  margin-bottom: var(--sp-4);
}
.card-list .section-title { margin-bottom: 2px; }
.card-list .subtitle { margin-bottom: var(--sp-2); }

.link-small {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--brand-600);
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.link-small:hover { background: var(--brand-50); color: var(--brand-700); }

/* --------------------------------------------------------------------------
   12. DYNAMIC ROWS (servant today, latest tx, daily approval)
   -------------------------------------------------------------------------- */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--ink-100);
}
.row:last-child { border-bottom: none; }
.row:first-child { padding-top: var(--sp-2); }

.row-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  flex: 1 1 auto;
}

.row-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--brand-700);
  background: linear-gradient(150deg, var(--brand-50), var(--brand-100));
  border: 1px solid var(--brand-100);
}

.row-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.row-meta > span:first-child {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta > span:nth-child(2) {
  font-size: var(--fs-xs);
  color: var(--ink-500);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amount {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: 0 0 auto;
  text-align: right;
}
.row-amount strong {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.01em;
}
.row-amount .label-soft {
  font-size: var(--fs-2xs);
  color: var(--ink-500);
  justify-content: flex-end;
}

/* daily approval action buttons inside rows/cards */
.row + div:has(> .btn),
.card-list .btn-sm + .btn-sm { margin-top: var(--sp-2); }

/* --------------------------------------------------------------------------
   13. BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.badge-green {
  color: var(--success-ink);
  background: var(--success-bg);
  border-color: var(--brand-200);
}
.badge-yellow {
  color: var(--warning-ink);
  background: var(--warning-bg);
  border-color: #f4dcab;
}
.badge-red {
  color: var(--danger-ink);
  background: var(--danger-bg);
  border-color: #f4c5ca;
}

/* --------------------------------------------------------------------------
   14. FILTERS & TABLES
   -------------------------------------------------------------------------- */
.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.filters-grid .form-label {
  margin-bottom: 5px;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-500);
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 520px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-600);
  background: var(--ink-50);
  padding: var(--sp-3) var(--sp-3);
  white-space: nowrap;
  border-bottom: 1.5px solid var(--border);
}

tbody td {
  padding: var(--sp-3) var(--sp-3);
  color: var(--ink-800);
  border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
  vertical-align: middle;
}
tbody tr:nth-child(even) { background: var(--ink-25, #fafcfb); }
tbody tr:nth-child(even) { background: #fafdfb; }
tbody tr:hover { background: var(--brand-25); }
tbody tr:last-child td { border-bottom: none; }

/* numeric emphasis on amount-ish trailing columns */
tbody td:last-child {
  font-weight: 700;
  color: var(--ink-900);
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.pagination-controls .text-muted {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-600);
}

/* canvas / charts breathe inside cards */
canvas { margin-top: var(--sp-2); }

/* --------------------------------------------------------------------------
   15. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-4);
  color: var(--ink-500);
  font-size: var(--fs-sm);
}
.empty-state::before {
  content: "\f07b";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 30px;
  color: var(--ink-300);
  margin-bottom: var(--sp-1);
}
.empty-state strong,
.empty-state b {
  color: var(--ink-700);
  font-size: var(--fs-md);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   16. PROFILE & SUBSCRIPTION
   -------------------------------------------------------------------------- */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  background:
    radial-gradient(120% 120% at 0% 0%, var(--brand-50) 0%, transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}

.profile-info { min-width: 0; }
.profile-info h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-info p {
  font-size: var(--fs-sm);
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 2px;
}

.subscription-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  margin: var(--sp-2) 0 var(--sp-4);
  background: linear-gradient(150deg, var(--brand-25), var(--white));
  border: 1px solid var(--brand-200);
  border-radius: var(--r-md);
}

.plan-info { min-width: 0; }
.plan-name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--brand-700);
}
.plan-details {
  font-size: var(--fs-xs);
  color: var(--ink-600);
  font-weight: 500;
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   17. MODAL  (JS toggles inline display; .modal-overlay is full-screen)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  /* JS sets display:flex/none inline. Provide visible-state styling: */
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: rgba(8, 24, 18, .5);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  animation: overlay-in var(--dur-2) var(--ease) both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  width: 100%;
  max-width: 380px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  border: 1px solid rgba(255, 255, 255, .6);
  overflow: hidden;
  animation: modal-pop var(--dur-3) var(--ease-out) both;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--ink-150);
}
.modal-header h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -.01em;
}

.modal-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-500);
  background: var(--ink-100);
  border: none;
  border-radius: 50%;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.modal-close:hover { background: var(--ink-200); color: var(--ink-900); }
.modal-close:focus-visible { outline: none; box-shadow: var(--ring); }

.modal-body {
  padding: var(--sp-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.plans-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Plan cards inside modal */
.plan-card {
  position: relative;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
              transform var(--dur-2) var(--ease);
}
.plan-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.plan-card.popular {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(22, 150, 92, .12), var(--sh-md);
  background: linear-gradient(165deg, var(--brand-25), var(--white));
}
.plan-card.popular::before {
  content: "Most popular";
  position: absolute;
  top: -11px;
  right: var(--sp-4);
  padding: 4px 12px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--white);
  background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
  border-radius: var(--r-pill);
  box-shadow: var(--sh-sm);
}

.plan-header { margin-bottom: var(--sp-3); }
.plan-card .plan-name {
  font-size: var(--fs-lg);
  color: var(--ink-900);
}
.plan-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--brand-700);
  letter-spacing: -.02em;
  margin-top: 2px;
}
.plan-price span {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-500);
}
.plan-duration {
  font-size: var(--fs-xs);
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 4px;
}

.plan-features {
  list-style: none;
  margin: var(--sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: var(--fs-sm);
  color: var(--ink-700);
  font-weight: 500;
}
/* the JS prefixes each feature with "✓ " — recolor that tick subtly */
.plan-features li { padding-left: 0; }

.plan-action { margin-top: var(--sp-4); }
.plan-action .btn { width: 100%; }

/* --------------------------------------------------------------------------
   18. BOTTOM NAV
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 6px env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-top: 1px solid var(--ink-150);
  box-shadow: 0 -4px 24px rgba(12, 32, 24, .07);
}
.bottom-nav.hidden { display: none; }

.nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-500);
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.nav-item > div:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -.01em;
}

.nav-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  transition: background var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
/* CRITICAL: nav icon must be visible — explicit color, never bg-matched */
.nav-icon i {
  font-size: 17px;
  color: var(--ink-400);
  line-height: 1;
  transition: color var(--dur-2) var(--ease);
}

.nav-item:hover { color: var(--ink-700); }
.nav-item:hover .nav-icon i { color: var(--brand-500); }

.nav-item.active { color: var(--brand-700); }
.nav-item.active .nav-icon {
  background: linear-gradient(150deg, var(--brand-50), var(--brand-100));
  transform: translateY(-1px);
}
.nav-item.active .nav-icon i { color: var(--brand-600); }
.nav-item.active::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 18px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--brand-500);
}
.nav-item:active { transform: scale(.95); }

/* --------------------------------------------------------------------------
   19. OFFLINE INDICATOR  (JS injects its own rules; provide safe base + polish)
   -------------------------------------------------------------------------- */
#offline-indicator,
.offline-indicator {
  z-index: 1000;
  font-family: var(--font);
}
.offline-indicator .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.offline-indicator.offline .status-dot { background: var(--danger); }
.offline-indicator.syncing .status-dot { background: var(--warning); }
.offline-indicator .status-text,
.offline-indicator .sync-text { font-size: var(--fs-xs); font-weight: 600; }
.offline-indicator .pending-count {
  font-size: var(--fs-2xs);
  color: var(--warning-ink);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   20. UTILITIES & FINE TUNING
   -------------------------------------------------------------------------- */
.main-scroll > .card-list:last-child,
.screen-inner > div:last-child { margin-bottom: 0; }

/* spacing between consecutive stacked buttons in cards */
.card-list .btn-full + .btn-full { margin-top: var(--sp-2); }

/* Make the search/filter sub-grids align nicely */
.filters-grid + .filters-grid { margin-top: 0; }

/* Generic id-targeted dynamic list containers get a touch of rhythm */
#dl-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-2); }
#dl-list > * {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xs);
}

/* --------------------------------------------------------------------------
   21. FOCUS VISIBILITY (a11y) — global fallback
   -------------------------------------------------------------------------- */
a:focus-visible,
.action-pill:focus-visible,
.nav-item:focus-visible,
.link-small:focus-visible,
[data-goto]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

input:focus-visible,
select:focus-visible { outline: none; }

/* --------------------------------------------------------------------------
   22. RESPONSIVE — small phones & large phones
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  :root { --fs-hero: 30px; }
  .quick-actions { gap: 6px; }
  .action-pill { padding: var(--sp-2) 2px; font-size: var(--fs-2xs); }
  .action-pill-icon { width: 40px; height: 40px; }
  .main-scroll,
  .screen-inner { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* On larger viewports inside the framed shell, keep it crisp */
@media (min-width: 768px) {
  .main-scroll,
  .screen-inner { scrollbar-gutter: stable; }
  .screen-inner { min-height: 0; height: 100%; overflow-y: auto; }
}

/* --------------------------------------------------------------------------
   23. PREFERS-REDUCED-MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .loader { animation: spin 1.2s linear infinite !important; }
}

/* --------------------------------------------------------------------------
   24. PRINT (graceful)
   -------------------------------------------------------------------------- */
@media print {
  body { background: #fff; }
  .bottom-nav,
  #loadingOverlay,
  .offline-indicator,
  .top-right { display: none !important; }
  .phone-shell { box-shadow: none; max-width: 100%; }
}

/* ===== final polish overrides ===== */
.action-pill-icon{ background:#ffffff; border:1px solid var(--brand-100,#dcfce7); }
.action-pill-icon i{ color:#0b7a43 !important; font-size:20px !important; }
.action-pill:hover .action-pill-icon i{ color:#075c32 !important; }
.nav-icon i{ color:inherit; }

/* ===== premium branded login (owner) ===== */
#screen-auth .auth-root{
  min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:30px 24px;position:relative;overflow:hidden;
  background:
    radial-gradient(1100px 480px at 50% -10%, rgba(60,192,124,.30), transparent 60%),
    radial-gradient(820px 560px at 115% 115%, rgba(15,138,77,.22), transparent 55%),
    linear-gradient(160deg,#0a6338 0%,#063a21 100%);
}
#screen-auth .auth-root::before{content:"";position:absolute;inset:0;background-image:radial-gradient(rgba(255,255,255,.06) 1px,transparent 1px);background-size:22px 22px;opacity:.5;-webkit-mask-image:radial-gradient(ellipse 80% 70% at 50% 30%,#000,transparent);mask-image:radial-gradient(ellipse 80% 70% at 50% 30%,#000,transparent);}
#screen-auth .auth-logo,#screen-auth .auth-title,#screen-auth .auth-subtitle,#screen-auth .auth-card{position:relative;z-index:1}
#screen-auth .auth-logo{animation:authrise .5s ease both;filter:drop-shadow(0 16px 34px rgba(0,0,0,.35))}
#screen-auth .auth-title{color:#fff;letter-spacing:-.02em}
#screen-auth .auth-subtitle{color:rgba(255,255,255,.82)}
#screen-auth .auth-card{box-shadow:0 32px 64px -22px rgba(0,0,0,.5),0 0 0 1px rgba(255,255,255,.6) inset;animation:authrise .58s ease both}
@keyframes authrise{from{opacity:0;transform:translateY(16px) scale(.985)}to{opacity:1;transform:none}}
