/* BudgeTrip — mobile-first, no build step, no framework. */

/* Palette borrowed from a US banknote: engraving-ink green on cotton paper,
   with the pale "greenback" green as the highlight. */
:root {
  --bg: #ece8da;          /* banknote paper */
  --surface: #faf8f0;
  --surface-2: #f2eee0;
  --text: #14251a;        /* engraving ink */
  --muted: #5e6f61;
  --border: #d8d2bd;
  --primary: #1c6b45;     /* treasury seal green */
  --primary-ink: #f7f5ea;
  --pos: #1c6b45;
  --pos-bg: #e6f0e6;
  --neg: #9c2b22;         /* serial-number red */
  --neg-bg: #f7e9e5;
  --hero-from: #123d29;
  --hero-to: #1f6b43;
  --hero-ink: #eef3e4;
  --greenback: #85bb65;   /* the famous dollar green */
  --shadow: 0 1px 2px rgba(20, 37, 26, .07), 0 8px 24px rgba(20, 37, 26, .08);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Panels sit at 65% so the backdrop shows through without hurting text. */
  --surface-a: rgba(250, 248, 240, .65);
  --surface-2a: rgba(242, 238, 224, .65);
  --backdrop-wash: linear-gradient(180deg, rgba(236, 232, 218, .12), rgba(236, 232, 218, .34));

  /* Data-mark colour, validated against this mode's surface. */
  --chart-mark: #146e44;
  --chart-grid: rgba(20, 37, 26, .12);
}

/* Dark palette. Applied when the phone asks for it, unless the user has
   explicitly chosen light — and always when they have explicitly chosen dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chart-mark: #44a06a;
    --chart-grid: rgba(233, 239, 228, .14);
    --surface-a: rgba(20, 31, 23, .65);
    --surface-2a: rgba(27, 41, 31, .65);
    --backdrop-wash: linear-gradient(180deg, rgba(12, 19, 14, .46), rgba(12, 19, 14, .68));
    --bg: #0c130e;
    --surface: #141f17;
    --surface-2: #1b291f;
    --text: #e9efe4;
    --muted: #92a396;
    --border: #26382c;
    --primary: #52ad7b;
    --primary-ink: #08150d;
    --pos: #6cc78f;
    --pos-bg: #0d2418;
    --neg: #e0796d;
    --neg-bg: #2a1512;
    --hero-from: #0f3325;
    --hero-to: #1b5c3c;
    --hero-ink: #e6f0dc;
    --greenback: #85bb65;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --chart-mark: #44a06a;
  --chart-grid: rgba(233, 239, 228, .14);
  --surface-a: rgba(20, 31, 23, .65);
  --surface-2a: rgba(27, 41, 31, .65);
  --backdrop-wash: linear-gradient(180deg, rgba(12, 19, 14, .46), rgba(12, 19, 14, .68));
  --bg: #0c130e;
  --surface: #141f17;
  --surface-2: #1b291f;
  --text: #e9efe4;
  --muted: #92a396;
  --border: #26382c;
  --primary: #52ad7b;
  --primary-ink: #08150d;
  --pos: #6cc78f;
  --pos-bg: #0d2418;
  --neg: #e0796d;
  --neg-bg: #2a1512;
  --hero-from: #0f3325;
  --hero-to: #1b5c3c;
  --hero-ink: #e6f0dc;
  --greenback: #85bb65;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

/* ---------------------------------------------------------------- */
/* Icons (Lucide, ISC licensed, inlined — see scripts/make-icon-set) */
/* ---------------------------------------------------------------- */

.icon {
  display: block;
  flex: none;
  stroke-width: 1.9;
}

/* Line icons read heavy at small sizes; thin them a touch. */
.chip .icon, .entry-icon .icon { stroke-width: 1.75; }

.type-icon { display: flex; color: var(--primary); }
.type-option[aria-checked="true"] .type-icon { color: var(--primary); }
.entry-icon .icon { color: var(--muted); }
.fab .icon { stroke-width: 2.2; }
.chips.wrap .chip { display: inline-flex; align-items: center; gap: 5px; }

/* Several elements below set an explicit `display`, which would otherwise
   defeat the `hidden` attribute the app uses to show and hide things. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.sheet-open { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }


/* ---------------------------------------------------------------- */
/* Backdrop                                                           */
/* ---------------------------------------------------------------- */

/* A fixed layer behind everything. The default is a drawn island; a photo
   uploaded in Settings overrides it via the --backdrop custom property. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--backdrop, url("/backdrop.svg"));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* A wash over the picture keeps text legible whatever photo is chosen. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--backdrop-wash);
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* Boot / loading                                                     */
/* ---------------------------------------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
  z-index: 50;
}

.boot-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--hero-from), var(--hero-to));
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: .45; transform: scale(.94); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .boot-mark { animation: none; } }

/* ---------------------------------------------------------------- */
/* Top bar                                                            */
/* ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.topbar h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.topbar-sub { font-size: 12.5px; color: var(--muted); }

.icon-btn {
  border: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  flex: none;
}

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

.topbar-actions { display: flex; gap: 8px; flex: none; }

.lang-btn {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .02em;
  width: auto;
  min-width: 38px;
  padding: 0 10px;
}

main { padding: 4px 16px calc(112px + var(--safe-bottom)); }

/* ---------------------------------------------------------------- */
/* Hero                                                               */
/* ---------------------------------------------------------------- */

.hero {
  background: linear-gradient(145deg, var(--hero-from), var(--hero-to));
  color: var(--hero-ink);
  border-radius: 22px;
  padding: 16px 18px 20px;
  box-shadow: var(--shadow);
}

.hero-label {
  font-size: 13px;
  opacity: .8;
  margin-top: 14px;
}

.hero-amount {
  font-size: clamp(34px, 11vw, 44px);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.hero-meta { font-size: 12.5px; opacity: .78; margin-top: 8px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }

.chip {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  background: rgba(255, 255, 255, .16);
  color: var(--hero-ink);
  opacity: .55;
  transition: background .15s ease;
}

.chip[aria-selected="true"] { background: var(--greenback); color: #10240f; }

/* Chips outside the hero (categories, settings) use surface colours. */
.chips.wrap .chip {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chips.wrap .chip[aria-selected="true"] {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

/* Filter rows over the dashboard photo: the hero's pale translucent pills
   vanish on a light backdrop, so these take opaque surface colours at full
   strength — and keep scrolling sideways. */
.chips.surface .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  opacity: 1;
}

.chips.surface .chip[aria-selected="true"] {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

/* ---------------------------------------------------------------- */
/* Personal spending                                                  */
/* ---------------------------------------------------------------- */

.personal { margin-top: 10px; }

.personal-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.personal-icon { display: flex; color: var(--muted); }
.personal-main { flex: 1; min-width: 0; }
.personal-label { font-size: 13px; color: var(--muted); }
.personal-note { font-size: 11.5px; color: var(--muted); opacity: .75; margin-top: 1px; }

.personal-amount {
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- */
/* Positions                                                          */
/* ---------------------------------------------------------------- */

.positions { margin-top: 16px; }

.position-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.position-card {
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.position-name {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.you-tag {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  color: var(--muted);
}

.position-amount {
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.position-amount.pos { color: var(--pos); }
.position-amount.neg { color: var(--neg); }
.position-note { font-size: 12px; color: var(--muted); margin-top: 1px; }

.settle-hint {
  margin-top: 10px;
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}

.settle-text { font-size: 13.5px; }
.settle-text strong { font-weight: 640; }

/* ---------------------------------------------------------------- */
/* Activity                                                           */
/* ---------------------------------------------------------------- */

.activity { margin-top: 22px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 2px 8px;
}

.section-head h2 { font-size: 15px; font-weight: 640; }
.section-meta { font-size: 12.5px; color: var(--muted); }
.section-tools { display: flex; align-items: baseline; gap: 12px; }
.section-action { font-size: 12.5px; padding: 0; cursor: pointer; }

.activity-list {
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Search + filter row above the list. */
.activity-controls { margin-bottom: 10px; display: grid; gap: 8px; }

.activity-search { position: relative; }
.activity-search-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
}
.activity-search-icon .icon { width: 16px; height: 16px; }
#activity-query {
  padding: 10px 14px;
  padding-inline-start: 36px;
  border-radius: 12px;
}
#activity-query::-webkit-search-cancel-button { -webkit-appearance: none; }

.day-head {
  padding: 9px 14px 5px;
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* Day headers double as collapse toggles. */
.day-head-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  cursor: pointer;
  text-align: start;
  padding-bottom: 9px;
}

.day-count {
  font-size: 10.5px;
  font-weight: 650;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 1.6;
}

.day-chevron {
  margin-inline-start: auto;
  display: flex;
  color: var(--muted);
  transition: transform .15s ease;
}
.day-head-btn[aria-expanded="false"] .day-chevron { transform: rotate(-90deg); }
[dir="rtl"] .day-head-btn[aria-expanded="false"] .day-chevron { transform: rotate(90deg); }

.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  text-align: start;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.entry:last-child { border-bottom: 0; }
.entry:active { background: var(--surface-2); }

.entry-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.entry-main { flex: 1; min-width: 0; }

.entry-title {
  font-size: 14.5px;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.entry-amounts {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.entry-amount {
  font-size: 14.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.entry-amount.pos { color: var(--pos); }
.entry-amount.neg { color: var(--neg); }
.entry-base { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}


/* ---------------------------------------------------------------- */
/* Buttons                                                            */
/* ---------------------------------------------------------------- */

.fab {
  position: fixed;
  inset-inline-end: 18px;
  bottom: calc(20px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border-radius: 20px;
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 45%, transparent);
  z-index: 25;
}

.fab:active { transform: scale(.93); }

.primary-btn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  cursor: pointer;
}

.primary-btn:disabled { opacity: .55; }
.primary-btn:active:not(:disabled) { transform: scale(.985); }

.ghost-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 13px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 550;
  color: var(--text);
  cursor: pointer;
  margin-top: 10px;
}

.danger-btn {
  border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent);
  background: var(--neg-bg);
  color: var(--neg);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 580;
  cursor: pointer;
}

.backdrop-row { display: flex; gap: 8px; }
.backdrop-row .ghost-btn { margin-top: 0; }

.currency-add {
  margin-top: 8px;
  font-weight: 520;
}

.currency-chip { display: inline-flex; align-items: center; gap: 4px; padding-inline-end: 6px; }

.chip-remove {
  border: 0;
  background: none;
  padding: 2px;
  display: flex;
  cursor: pointer;
  color: inherit;
  opacity: .65;
}

.chip-remove:active { opacity: 1; }

/* Sits inline with an input, e.g. the starting-balance field. */
.inline-btn {
  flex: none;
  width: 106px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.inline-btn:disabled { opacity: .6; }

.danger-zone {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.danger-btn.wide { width: 100%; margin-top: 10px; }

.link-btn {
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 550;
  padding: 6px 0 0;
  cursor: pointer;
}

.settle-btn {
  flex: none;
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  cursor: pointer;
}

/* ---------------------------------------------------------------- */
/* Sheets                                                             */
/* ---------------------------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 40; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 22, .45);
  animation: fade .18s ease;
}

@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  animation: rise .24s cubic-bezier(.32, .72, 0, 1);
}

@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .sheet-panel, .sheet-backdrop { animation: none; } }

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 8px auto 0;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 4px;
  flex: none;
}

.sheet-head h2 { font-size: 17px; font-weight: 640; }

.sheet-body {
  padding: 8px 16px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

/* ---------------------------------------------------------------- */
/* Form fields                                                        */
/* ---------------------------------------------------------------- */

.field { display: block; margin-top: 16px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
}

.optional { font-weight: 400; text-transform: none; opacity: .8; }
.field-help { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

input[type="text"], input[type="date"], input[type="search"], select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 13px;
  padding: 13px 14px;
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  appearance: none;
}

/* iOS renders date inputs with a system tint and centers the value oddly;
   pin the same look as the text fields. */
input[type="date"] { min-height: 50px; -webkit-appearance: none; text-align: start; }

input:focus, select:focus, .type-option:focus-visible, .seg-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* The two statistics tabs: whose money the sheet is slicing. */
.stats-tabs { margin-bottom: 10px; }
.stats-me-note { margin: -4px 0 10px; }

/* The four group types pair up; the personal one stands apart on its own row. */
.type-picker .type-option[data-type="personal_expense"] { grid-column: 1 / -1; }

.type-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer;
  text-align: start;
}

.type-option[aria-checked="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.type-icon { font-size: 19px; line-height: 1; }
.type-name { font-size: 13px; font-weight: 570; line-height: 1.25; }

.segmented {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 4px;
}

.seg-option {
  flex: 1;
  border: 0;
  background: none;
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-option[aria-checked="true"],
.seg-option[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

.amount-row { display: flex; gap: 8px; }

.amount-input {
  flex: 1;
  font-size: 26px !important;
  font-weight: 640;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  padding: 11px 14px !important;
}

.currency-select { width: 106px; flex: none; font-weight: 560; text-align: center; }

.rate-note {
  display: block;
  border: 0;
  background: none;
  padding: 8px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: start;
  cursor: pointer;
}

.rate-note u { text-decoration-style: dotted; text-underline-offset: 2px; }

.rate-editor {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}

.rate-row { display: flex; align-items: center; gap: 8px; }
.rate-row input { flex: 1; background: var(--surface); }
.rate-prefix, .rate-suffix { font-size: 13.5px; color: var(--muted); white-space: nowrap; }

.locked-value {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 16px;
  font-weight: 560;
}

.error-note {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--neg-bg);
  color: var(--neg);
  font-size: 13.5px;
  border: 1px solid color-mix(in srgb, var(--neg) 25%, transparent);
}

/* ---------------------------------------------------------------- */
/* Receipt                                                            */
/* ---------------------------------------------------------------- */

.source-busy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.receipt-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.receipt-thumb.expanded {
  width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
}

.receipt-thumb-btn {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: none;
}

.receipt-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-block-end: 14px;
}

.receipt-banner-main { flex: 1; min-width: 0; }

.receipt-banner-text { font-size: 13px; color: var(--text); }

.receipt-warnings {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.receipt-warnings li::before { content: "· "; }

.source-retry-row { display: flex; gap: 8px; }
.source-retry-row .ghost-btn { margin-top: 0; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---------------------------------------------------------------- */
/* Statistics                                                         */
/* ---------------------------------------------------------------- */

.stats-panel .sheet-body { padding-bottom: calc(24px + var(--safe-bottom)); }

.stats-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
}

.stat-tile-label { font-size: 11.5px; color: var(--muted); }

.stat-tile-value {
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -.01em;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Long sums step the font down rather than losing digits to the ellipsis —
   a truncated amount is worse than a small one. Set from tile(). */
.stat-tile-value[data-size="compact"] { font-size: 14px; }
.stat-tile-value[data-size="tiny"] { font-size: 12.5px; letter-spacing: -.02em; }

.chart-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 14px;
  margin-bottom: 12px;
}

.chart-title { font-size: 13px; font-weight: 640; color: var(--muted); margin: 0 0 10px; }

/* Daily columns: the SVG is drawn by app.js. Wide ranges scroll sideways
   inside the card rather than squeezing the columns to nothing. */
.chart-daily { overflow-x: auto; scrollbar-width: none; }
.chart-daily::-webkit-scrollbar { display: none; }
.chart-daily svg { display: block; }
.chart-daily .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-daily .axis-text { font-size: 10px; fill: var(--muted); }
.chart-daily .col { fill: var(--chart-mark); }
.chart-daily .col.dim { opacity: .45; }

/* Horizontal bar rows: label · track · value. Identity comes from the row
   label (and icon), so one validated hue carries every bar. */
.bar-rows { display: flex; flex-direction: column; gap: 9px; }

.bar-row { display: grid; grid-template-columns: 104px 1fr auto; gap: 8px; align-items: center; }

.bar-row-label {
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-row-label .icon { color: var(--muted); }

.bar-track { min-width: 0; }

.bar-fill {
  height: 14px;
  background: var(--chart-mark);
  border-start-end-radius: 4px;
  border-end-end-radius: 4px;
  min-width: 2px;
}

.bar-row-value {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-tip {
  position: fixed;
  z-index: 70;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  white-space: nowrap;
}

.chart-tip strong { display: block; font-size: 13px; }

.date-row { display: flex; align-items: center; gap: 8px; }
.date-row input[type="date"] { flex: 1; min-width: 0; }
.date-sep { color: var(--muted); flex: none; }

.trip-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
  padding: 3px 10px;
  margin-top: 8px;
}

/* ---------------------------------------------------------------- */
/* Right-to-left (Hebrew)                                             */
/* ---------------------------------------------------------------- */

/* Everything above uses logical properties, so the layout mirrors itself.
   Money is the exception: a figure like "−Rs 5,000" must keep reading
   left-to-right wherever it sits, or the minus sign and currency symbol end up
   on the wrong side of the digits. Isolating it also stops the surrounding
   Hebrew from reordering it. */
.hero-amount,
.position-amount,
.entry-amount,
.entry-base,
.amount-input,
.rate-row,
.rate-note,
.locked-value {
  direction: ltr;
  unicode-bidi: isolate;
}

/* Those figures are forced to LTR above, so their alignment has to be restored
   by hand — otherwise they drift to the wrong edge of a right-to-left card. */
[dir="rtl"] .hero-amount,
[dir="rtl"] .position-amount,
[dir="rtl"] .amount-input,
[dir="rtl"] .rate-note,
[dir="rtl"] .locked-value {
  text-align: right;
}

/* "1 USD = [320.50] LKR" is an equation, not a sentence: left to right in
   both languages. #fx-rate inherits this and needs no rule of its own. */
[dir="rtl"] .rate-row { direction: ltr; }

/* Numeric fields keep LTR digits, but the caret starts at the reading edge. */
[dir="rtl"] #starting-balance { direction: ltr; text-align: right; }

/* Hebrew has no uppercase, and letterspacing degrades its glyph shaping. */
[dir="rtl"] .day-head,
[dir="rtl"] .you-tag {
  letter-spacing: normal;
  text-transform: none;
}

/* The trip name is user-typed and likely Hebrew; negative tracking is a
   Latin display-type trick that just crowds Hebrew letters. */
[dir="rtl"] .topbar h1 { letter-spacing: normal; }

/* Gradient angles are physical and do not mirror with direction. */
[dir="rtl"] .hero,
[dir="rtl"] .boot-mark {
  background: linear-gradient(215deg, var(--hero-from), var(--hero-to));
}

/* ---------------------------------------------------------------- */
/* Toast                                                              */
/* ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 520;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .3);
  animation: fade .18s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------------------------------------------------------------- */
/* Cloud: login, trips list, admin                                    */
/* ---------------------------------------------------------------- */

.center-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.auth-card h1 { font-size: 21px; letter-spacing: -.01em; }
.auth-card .field { text-align: start; margin-top: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }

.boot-mark.small { width: 44px; height: 44px; border-radius: 14px; margin: 0 auto; animation: none; }

.code-input {
  font-size: 26px !important;
  letter-spacing: .35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.primary-btn.wide, .danger-btn.wide { width: 100%; }

.trips-list { display: flex; flex-direction: column; gap: 10px; }

.trip-card {
  display: flex;
  align-items: stretch;
  width: 100%;
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.trip-card-main {
  flex: 1;
  min-width: 0;
  display: block;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  padding-block: 14px;
  padding-inline: 16px 4px;
  border-radius: var(--radius);
}

.trip-card-main:active { transform: scale(.985); }

.trip-card-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.trip-card-name { font-size: 16px; font-weight: 640; min-width: 0; overflow-wrap: anywhere; }
.trip-card-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.trip-card-badge {
  flex: none; font-size: 11px; font-weight: 650; letter-spacing: .03em;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; color: var(--muted);
}

.trip-card-more {
  align-self: flex-start;
  margin-block-start: 12px;
  margin-inline-end: 10px;
  background: none;
  border: 0;
  color: var(--muted);
}

.trip-card-stats { display: flex; gap: 22px; margin-top: 10px; }
.trip-stat-label { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.trip-stat-value {
  font-size: 14.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.trip-stat-value.pos { color: var(--pos); }
.trip-stat-value.neg { color: var(--neg); }

.trips-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 26px 16px 6px;
}
.trips-hero h2 { font-size: 20px; font-weight: 700; margin-top: 10px; }
.trips-hero p { color: var(--muted); font-size: 14px; }

/* The topbar trip name doubles as the switcher trigger. */
.trip-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-align: start;
}
.trip-switch > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.switch-caret { display: inline-flex; flex: none; color: var(--muted); }

/* Rows shared by the switcher sheet and the per-trip actions sheet. */
.switcher-list, .switcher-static { display: flex; flex-direction: column; gap: 8px; }
.switcher-list:not(:empty) + .switcher-static {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14.5px;
  font-weight: 550;
  color: inherit;
  text-align: start;
  cursor: pointer;
}
.switcher-row:active { background: var(--surface); }
.switcher-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.switcher-icon { display: inline-flex; flex: none; color: var(--muted); }
.switcher-position {
  flex: none;
  font-size: 13.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.switcher-position.pos { color: var(--pos); }
.switcher-position.neg { color: var(--neg); }
.switcher-row.danger, .switcher-row.danger .switcher-icon { color: var(--neg); }

.card-block {
  background: var(--surface-a);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}

.section-title { font-size: 14px; font-weight: 640; margin: 0 0 4px; }
.card-block .primary-btn { margin-top: 12px; }
.currency-select.wide { width: 100%; text-align: start; }

.join-row { display: flex; gap: 8px; margin-top: 8px; }
.join-row input { flex: 1; text-transform: uppercase; }
.join-row .primary-btn { flex: none; width: auto; padding-inline: 18px; }

.share-row { display: flex; gap: 8px; }
.share-row .ghost-btn { margin-top: 0; }
.qr-wrap { display: flex; justify-content: center; margin-top: 10px; }
.share-qr {
  width: 180px; height: 180px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff;
}

.members-list { display: flex; flex-direction: column; gap: 6px; }

.member-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px; font-size: 14px;
}

.member-row .grow { flex: 1; min-width: 0; }
.member-kick {
  border: 0; background: none; color: var(--neg); font-size: 12.5px;
  font-weight: 600; cursor: pointer; padding: 4px;
}

.admin-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.admin-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-a); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; font-size: 13.5px;
}

.admin-row .grow { flex: 1; min-width: 140px; }
.admin-row .muted { color: var(--muted); font-size: 12px; }
.admin-action {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 9px;
  font-size: 12px; font-weight: 600; padding: 5px 10px; cursor: pointer;
}
.admin-action.danger { color: var(--neg); }

.back-btn { flex: none; }

/* Destination chip on the create-trip form */
.dest-chip {
  margin-top: 8px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  font-size: 14px;
}
.dest-chip.off { opacity: .45; filter: grayscale(1); }
