/* ==========================================================================
   SERVANT WALLET — Daily Collections  ·  Field Collector PWA
   Design system: "Refined institutional fintech" (shared with Owner app)
   Mercury / Ramp / Stripe-grade — sophisticated neutrals + deep emerald.
   Tuned for a FAST, one-handed FIELD app: big tap targets, a delightful
   camera/scan experience, clear cash-vs-digital flow, prominent money inputs,
   a satisfying submit. Mobile-first (~402px) · AA contrast · a11y aware.
   Authored as a complete rewrite against fixed markup (HTML never changes).

   IMPORTANT behavioural contract (JS depends on these):
   - .screen{display:none}; .screen.active{display:block}; .hidden{display:none!important}
   - .tab-content{display:none}; .tab-content.active{display:block}
   - .bottom-nav.hidden{display:none}; .nav-item.active highlighted
   - Elements toggled inline by JS (camera-overlay, image-preview-container,
     up-sender-group, up-other-accounts-container, ai-loading,
     upload-preview-container, switch/capture buttons …) are NEVER display-forced.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS  (shared with Owner — single product family)
   -------------------------------------------------------------------------- */
: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;
  --info-ink: #1d4ea3;

  /* --- 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;
  --mono: "SF Mono", ui-monospace, "Roboto Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --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: 430px;
  /* matches servant phone-shell max-width */
  --nav-h: 72px;
  /* 6-item field nav → a touch taller */
}

/* --------------------------------------------------------------------------
   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;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

img,
canvas,
svg,
video {
  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: 100dvh;
  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;
  height: 100%;
  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(900px, 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;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  animation: screen-in var(--dur-3) var(--ease-out) both;
}

/* Screens that own their own scroll/chrome become column flex */
#screen-dashboard.active,
#screen-upload.active,
#screen-cash.active,
#screen-summary.active,
#screen-history.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;
}

/* generic fade used by auth/content swaps */
.fade {
  animation: fadeIn var(--dur-3) var(--ease-out) both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   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 — onboarding + login
   The HTML ships inline styles for #onboardingScreen / #loginScreen and
   their controls; we harmonise tokens here without fighting those toggles.
   -------------------------------------------------------------------------- */
#screen-auth.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.auth-root {
  min-height: 100%;
  background:
    radial-gradient(120% 80% at 50% -20%, var(--brand-50) 0%, transparent 60%),
    var(--app-bg);
}

/* Onboarding ring + illustration refinement (works with inline display:flex) */
.illustration-container {
  background: linear-gradient(160deg, var(--white), var(--brand-25)) !important;
  box-shadow: var(--sh-lg) !important;
}

.illustration-container::before {
  border-color: var(--brand-300) !important;
  opacity: .35 !important;
}

.info-title {
  color: var(--brand-800) !important;
  letter-spacing: -.02em;
}

.info-desc {
  color: var(--ink-500) !important;
}

.steps-row {
  justify-content: center;
}

.dot {
  background: var(--ink-200);
}

.dot.active {
  background: var(--brand-500);
}

.btn-onboard {
  background: linear-gradient(160deg, var(--brand-500), var(--brand-600)) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 10px 22px rgba(15, 125, 76, .30), inset 0 1px 0 rgba(255, 255, 255, .2) !important;
  font-family: var(--font);
  letter-spacing: .01em;
}

/* Login */
.login-title {
  color: var(--brand-800) !important;
  letter-spacing: -.01em;
}

.login-logo img {
  filter: drop-shadow(0 6px 14px rgba(12, 32, 24, .12));
}

.input-group {
  margin-bottom: var(--sp-5);
}

.input-label {
  color: var(--ink-700) !important;
  font-size: var(--fs-xs);
  letter-spacing: .01em;
}

.phone-input-wrapper {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  background: var(--white) !important;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.phone-input-wrapper:focus-within {
  border-color: var(--brand-500) !important;
  box-shadow: var(--ring) !important;
}

.country-code {
  color: var(--brand-700) !important;
  background: var(--brand-25) !important;
  border-right: 1px solid var(--border) !important;
  font-weight: 700;
}

.input-field {
  color: var(--ink-900);
}

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

.password-field {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  background: var(--white) !important;
}

.password-field:focus {
  border-color: var(--brand-500) !important;
  box-shadow: var(--ring) !important;
}

.login-btn {
  background: linear-gradient(160deg, var(--brand-500), var(--brand-600)) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: 0 8px 18px rgba(15, 125, 76, .28), inset 0 1px 0 rgba(255, 255, 255, .18) !important;
  letter-spacing: .01em;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.login-btn:hover {
  background: linear-gradient(160deg, var(--brand-600), var(--brand-700)) !important;
}

.login-btn:active {
  transform: translateY(1px) scale(.99);
}

.powered {
  color: var(--ink-500);
}

.powered strong {
  color: var(--brand-700) !important;
}

/* --------------------------------------------------------------------------
   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.select,
select.input,
input.input,
textarea.input {
  width: 100%;
  height: 48px;
  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;
  min-height: 110px;
  padding: var(--sp-3) var(--sp-4);
  line-height: 1.55;
  resize: vertical;
}

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

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

.input:focus,
.select:focus,
select:focus,
textarea.input: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;
}

/* Field-app money inputs: big, confident, tabular figures */
input[type="number"].input,
#up-main,
#up-paid,
#up-tip,
#cash-amount {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  height: 54px;
}

/* strip number spinners for a clean POS feel */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* 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;
}

.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 — field tap targets are a touch larger
   -------------------------------------------------------------------------- */
.btn {
  --btn-h: 50px;
  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: 40px;
  height: var(--btn-h);
  padding: 0 var(--sp-4);
  font-size: var(--fs-sm);
  border-radius: var(--r-xs);
}

.btn-xs {
  --btn-h: 34px;
  height: var(--btn-h);
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--r-xs);
}

/* The big money-submit buttons (save deposit, add cash, submit total) */
#btn-up-save,
#btn-cash-add,
#btn-sum-submit {
  --btn-h: 56px;
  font-size: var(--fs-lg);
  font-weight: 700;
  border-radius: var(--r-md);
  box-shadow: 0 10px 22px rgba(15, 125, 76, .30), inset 0 1px 0 rgba(255, 255, 255, .2);
}

#btn-up-save:hover,
#btn-cash-add:hover,
#btn-sum-submit:hover {
  box-shadow: 0 14px 28px rgba(15, 125, 76, .36), inset 0 1px 0 rgba(255, 255, 255, .2);
}

#btn-up-save::before {
  content: "\f0c7";
}

/* floppy/save */
#btn-cash-add::before {
  content: "\f067";
}

/* plus */
#btn-sum-submit::before {
  content: "\f00c";
}

/* check */
#btn-up-save::before,
#btn-cash-add::before,
#btn-sum-submit::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: var(--fs-md);
  margin-right: 2px;
}

/* Circle buttons (camera capture / switch) */
.btn-circle {
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(160deg, var(--brand-500), var(--brand-700));
  box-shadow: var(--sh-md), inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.btn-circle:active {
  transform: scale(.93);
}

.btn-circle i {
  color: var(--white);
  line-height: 1;
}

.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: 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: 42px;
  height: 42px;
  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-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.avatar-circle {
  width: 42px;
  height: 42px;
  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);
}

/* Scrollable content region for dashboard */
.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 screens — these also scroll under the nav */
.screen-inner {
  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));
}

.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);
  display: block;
}

.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 + quick actions
   -------------------------------------------------------------------------- */
.balance-card {
  position: relative;
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5);
  margin-bottom: 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;
  font-variant-numeric: tabular-nums;
  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: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--white);
  border: 1px solid var(--brand-100);
}

/* CRITICAL: icon high-contrast accent on the light tile (never bg-matched) */
.action-pill-icon i {
  font-size: 20px;
  color: var(--brand-600);
  line-height: 1;
}

.action-pill:hover .action-pill-icon {
  background: linear-gradient(150deg, var(--brand-50), var(--brand-100));
}

.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);
}

.label-soft.label-soft {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   12. DYNAMIC ROWS (today entries, cash rows, summary rows)
   -------------------------------------------------------------------------- */
.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);
}

/* The upload-screen amount inputs row uses .row inline flex — keep it clean */
#screen-upload .row {
  border-bottom: none;
  padding: 0;
  align-items: stretch;
}

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

.row-avatar {
  width: 42px;
  height: 42px;
  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-avatar i {
  color: var(--brand-600);
}

.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),
.row-meta .text-muted {
  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;
  font-variant-numeric: tabular-nums;
}

.row-amount .label-soft {
  font-size: var(--fs-2xs);
  color: var(--ink-500);
  justify-content: flex-end;
}

/* Summary overall total — make the last row stand out as the grand total */
#screen-summary .card-list .row:last-child {
  margin-top: var(--sp-1);
  padding-top: var(--sp-3);
  border-top: 1.5px solid var(--brand-100);
}

#screen-summary .card-list .row:last-child .row-meta>span:first-child {
  color: var(--brand-800);
  font-weight: 700;
}

#screen-summary .card-list .row:last-child .row-amount strong {
  font-size: var(--fs-xl);
  color: var(--brand-700);
}

/* --------------------------------------------------------------------------
   13. BADGES  (status pills used in lists + history)
   -------------------------------------------------------------------------- */
.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,
.badge-success {
  color: var(--success-ink);
  background: var(--success-bg);
  border-color: var(--brand-200);
}

.badge-yellow,
.badge-warning,
.badge-pending {
  color: var(--warning-ink);
  background: var(--warning-bg);
  border-color: #f4dcab;
}

.badge-red,
.badge-danger,
.badge-rejected {
  color: var(--danger-ink);
  background: var(--danger-bg);
  border-color: #f4c5ca;
}

.badge-neutral {
  color: var(--ink-600);
  background: var(--ink-100);
  border-color: var(--ink-200);
}

.badge-blue,
.badge-info {
  color: var(--info-ink);
  background: var(--info-bg);
  border-color: #c5dafa;
}

/* --------------------------------------------------------------------------
   14. TABLES  (history)
   -------------------------------------------------------------------------- */
.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);
}

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: #fafdfb;
}

tbody tr:hover {
  background: var(--brand-25);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* numeric emphasis on the total column */
tbody td:nth-child(2) {
  font-weight: 700;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   15. EMPTY STATE  (dynamic list containers when empty)
   -------------------------------------------------------------------------- */
.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. TABS  (camera / upload / manual)  —  refined segmented control
   The HTML carries inline styles on .tabs / .tab; we elevate via higher
   specificity so it reads like a premium segmented control, not raw buttons.
   -------------------------------------------------------------------------- */
.tabs-container {
  margin-top: var(--sp-5);
}

.tabs-container .tabs {
  display: flex;
  gap: 4px !important;
  padding: 5px !important;
  background: var(--ink-100);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border) !important;
  border-radius: var(--r-md);
}

.tabs-container .tabs .tab {
  flex: 1;
  padding: 11px 8px !important;
  border: none !important;
  background: transparent !important;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600 !important;
  color: var(--ink-600);
  cursor: pointer;
  transition: background var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.tabs-container .tabs .tab:hover {
  color: var(--ink-900);
}

.tabs-container .tabs .tab.active {
  background: var(--white) !important;
  color: var(--brand-700);
  box-shadow: var(--sh-sm);
}

.tabs-container .tabs .tab:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Only the active tab-content is visible (JS contract) */
.tab-content-container {
  margin-top: var(--sp-4) !important;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tab-in var(--dur-2) var(--ease-out) both;
}

@keyframes tab-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   17. CAMERA / OCR SCAN EXPERIENCE
   The viewport, capture controls, preview, and an elegant AI "reading
   receipt" loading state. JS toggles inline display on:
     #camera-overlay #image-preview-container #switch-camera #capture-photo
     #upload-preview-container — we never display-force these.
   -------------------------------------------------------------------------- */

/* Viewport frame */
.camera-container {
  position: relative;
  width: 100%;
  height: 220px !important;
  overflow: hidden;
  border-radius: var(--r-md) !important;
  background: radial-gradient(120% 120% at 50% 0%, #1a2420, #050806) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06),
    inset 0 18px 40px rgba(0, 0, 0, .5),
    var(--sh-md);
  margin-bottom: var(--sp-3) !important;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05080699;
}

/* Scan reticle corners — drawn over the live preview */
.camera-container::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: var(--r-sm);
  pointer-events: none;
  background:
    linear-gradient(var(--brand-300), var(--brand-300)) left top / 26px 3px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) left top / 3px 26px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) right top / 26px 3px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) right top / 3px 26px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) left bottom / 26px 3px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) left bottom / 3px 26px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) right bottom / 26px 3px no-repeat,
    linear-gradient(var(--brand-300), var(--brand-300)) right bottom / 3px 26px no-repeat;
  opacity: .85;
  z-index: 2;
}

/* Camera overlay (JS sets inline display flex/none — we only theme it) */
#camera-overlay {
  background: radial-gradient(120% 120% at 50% 30%, rgba(7, 58, 39, .55), rgba(5, 8, 6, .82)) !important;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 3;
  gap: var(--sp-2);
}

#camera-overlay p {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .01em;
  color: rgba(255, 255, 255, .92);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

#camera-overlay p::before {
  content: "\f030";
  /* camera */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 30px;
  color: var(--brand-300);
}

/* Capture controls cluster */
.camera-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-5) !important;
  margin-top: var(--sp-2);
}

/* Themed circular controls — keep JS's inline display:none until shown */
#capture-photo.btn-circle {
  width: 60px !important;
  height: 60px !important;
  background: linear-gradient(160deg, var(--brand-500), var(--brand-700)) !important;
  box-shadow: 0 8px 18px rgba(15, 125, 76, .4), inset 0 0 0 4px rgba(255, 255, 255, .85),
    inset 0 0 0 5px rgba(15, 125, 76, .25) !important;
  color: var(--white) !important;
}

#capture-photo.btn-circle i {
  font-size: 22px;
  color: var(--white);
}

#switch-camera.btn-circle {
  width: 46px !important;
  height: 46px !important;
  background: rgba(12, 32, 24, .06) !important;
  color: var(--brand-700) !important;
  box-shadow: var(--sh-sm) !important;
  border: 1px solid var(--border) !important;
}

#switch-camera.btn-circle i {
  color: var(--brand-700);
  font-size: 17px;
}

#capture-photo.btn-circle:active,
#switch-camera.btn-circle:active {
  transform: scale(.92);
}

/* Captured / uploaded image preview */
#image-preview-container,
#upload-preview-container {
  margin-bottom: var(--sp-3);
}

#captured-image,
#upload-preview {
  width: 100%;
  border-radius: var(--r-md) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--sh-sm);
}

/* Upload dropzone (the dashed box in the Upload File tab) */
#upload-tab>div:first-child {
  border: 2px dashed var(--brand-200) !important;
  border-radius: var(--r-md) !important;
  padding: var(--sp-6) var(--sp-5) !important;
  background:
    radial-gradient(120% 120% at 50% 0%, var(--brand-25), transparent 70%),
    var(--ink-50) !important;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}

#upload-tab>div:first-child:hover {
  border-color: var(--brand-400) !important;
  background: var(--brand-25) !important;
}

#upload-tab label[for="file-input"] span {
  color: var(--brand-700) !important;
  font-weight: 600 !important;
  font-size: var(--fs-md);
}

#upload-tab label[for="file-input"] span::before {
  content: "\f0ee";
  /* upload cloud-ish arrow */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 26px;
  color: var(--brand-500);
  display: block;
  margin-bottom: var(--sp-2);
}

/* Manual / SMS textarea — terminal-style monospace */
#up-manual-input {
  font-family: var(--mono) !important;
  font-size: var(--fs-sm) !important;
  line-height: 1.6 !important;
  color: var(--ink-800);
  background: var(--ink-50) !important;
  border-radius: var(--r-sm) !important;
  padding: var(--sp-3) var(--sp-4) !important;
}

/* AI / OCR "reading receipt" loading state — delightful + on-brand
   (#ai-loading toggles via .hidden; we theme its visible form). */
#ai-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  text-align: center !important;
  color: var(--brand-700) !important;
  font-weight: 700 !important;
  font-size: var(--fs-sm);
  padding: var(--sp-4) !important;
  margin-bottom: var(--sp-3);
  border-radius: var(--r-md);
  background:
    linear-gradient(110deg, var(--brand-25), var(--brand-50), var(--brand-25));
  background-size: 220% 100%;
  border: 1px solid var(--brand-200);
  box-shadow: var(--sh-xs);
  animation: ai-shimmer 1.6s var(--ease) infinite;
}

#ai-loading.hidden {
  display: none !important;
}

#ai-loading i {
  color: var(--brand-600) !important;
  font-size: var(--fs-lg);
  animation: ai-pulse 1.2s var(--ease) infinite;
}

@keyframes ai-shimmer {
  from {
    background-position: 120% 0;
  }

  to {
    background-position: -120% 0;
  }
}

@keyframes ai-pulse {

  0%,
  100% {
    transform: scale(1) rotate(0deg);
    opacity: .9;
  }

  50% {
    transform: scale(1.18) rotate(8deg);
    opacity: 1;
  }
}

/* Upload status line (● Ready to save / saving / done) */
#upload-status-msg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-500);
}

/* Sender-account conditional group (JS toggles inline display) — gentle accent */
#up-sender-group {
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--info-bg);
  border: 1px solid #c5dafa;
}

#up-sender-group .form-label {
  color: var(--info-ink);
}

/* Other-accounts container (JS toggles inline display) */
#up-other-accounts-container {
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--ink-50);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   18. BOTTOM NAV  (6 field tabs)
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding: 7px 4px 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: 5px 1px;
  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: 32px;
  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 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. MODAL  (JS toggles inline display; .modal-overlay is full-screen)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  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,
.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;
}

/* --------------------------------------------------------------------------
   21. 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);
}

/* generic dynamic list containers get a touch of rhythm when empty/filled */
#dash-today-list:empty::after,
#up-today-list:empty::after,
#cash-today-list:empty::after,
#sum-list:empty::after {
  content: "No entries yet.";
  display: block;
  text-align: center;
  padding: var(--sp-5) var(--sp-3);
  color: var(--ink-400);
  font-size: var(--fs-sm);
  font-weight: 500;
}

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

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

/* --------------------------------------------------------------------------
   23. 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: 42px;
    height: 42px;
  }

  .main-scroll,
  .screen-inner {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }

  .nav-item>div:last-child {
    font-size: 9px;
  }

  .tabs-container .tabs .tab {
    padding: 10px 4px !important;
    font-size: var(--fs-xs);
  }
}

@media (min-width: 768px) {

  .main-scroll,
  .screen-inner {
    scrollbar-gutter: stable;
  }
}

/* --------------------------------------------------------------------------
   24. 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;
  }

  #ai-loading {
    animation: none !important;
  }

  #ai-loading i {
    animation: none !important;
  }
}

/* --------------------------------------------------------------------------
   25. PRINT (graceful)
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #fff;
  }

  .bottom-nav,
  #loadingOverlay,
  .offline-indicator,
  .camera-container,
  .camera-controls,
  .top-right {
    display: none !important;
  }

  .phone-shell {
    box-shadow: none;
    max-width: 100%;
  }
}

/* ===== premium branded login (servant) ===== */
#screen-auth.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#screen-auth .auth-root {
  flex: 1 1 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 24px 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 #onboardingScreen,
#screen-auth #loginScreen {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px
}

#screen-auth .info-title,
#screen-auth h2,
#screen-auth .login-logo+* {
  color: #fff
}

#screen-auth .info-desc {
  color: rgba(255, 255, 255, .82)
}

#screen-auth .login-logo {
  position: relative;
  z-index: 1;
  animation: authrise .5s ease both;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, .35))
}

#screen-auth #loginScreen .card-list,
#screen-auth #loginScreen form,
#screen-auth #content-box {
  background: #fff;
  border-radius: 20px;
  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
  }
}