/* ===========================================================================
   MoneyApp — styles
   Mobile-first. Theme: light-gray canvas, blue actions + total, black text.
   =========================================================================== */

:root {
  /* Brand palette */
  --c-gray:       #eef1f5;   /* light gray — page background */
  --c-blue:       #2563eb;   /* base blue */
  --c-blue-light: #3b82f6;   /* lighter blue (gradient start) */
  --c-blue-dark:  #1d4ed8;   /* darker blue (gradient end, total) */
  --c-black:      #0b0f14;   /* near-black text */

  /* Semantic tokens */
  --bg:            var(--c-gray);
  --surface:       #ffffff;
  --surface-2:     #f4f6f9;          /* inputs / subtle hover */
  --surface-3:     #e7ecf2;
  --border:        rgba(11, 15, 20, 0.10);
  --border-strong: rgba(11, 15, 20, 0.20);

  --text:          #1a1f26;          /* body text (near-black) */
  --text-strong:   var(--c-black);   /* headings / amounts */
  --text-muted:    #5b636e;
  --text-dim:      #99a1ac;

  /* Blue action surfaces (buttons, FAB, brand mark, avatars) */
  --action:        var(--c-blue);
  --action-2:      var(--c-blue-dark);
  --on-action:     #ffffff;

  --accent:        var(--c-blue);
  --danger:        #c0392b;
  --danger-soft:   rgba(192, 57, 43, 0.10);

  /* Typography */
  --font-display: "Manrope", system-ui, sans-serif;
  --font-body:    "Manrope", system-ui, sans-serif;

  /* Shape & depth */
  --radius:    16px;
  --radius-sm: 11px;
  --radius-lg: 24px;
  --shadow:    0 14px 44px rgba(11, 15, 20, 0.14);
  --shadow-sm: 0 4px 16px rgba(11, 15, 20, 0.07);

  /* Layout */
  --maxw: 560px;
  --pad:  20px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  /* Soft atmospheric tint instead of a flat fill */
  background-image:
    radial-gradient(120% 80% at 85% -10%, rgba(37, 99, 235, 0.10), transparent 55%),
    radial-gradient(90% 60% at -5% 0%, rgba(37, 99, 235, 0.06), transparent 60%);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, button, textarea, select { font: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; }

.app { width: 100%; }
[hidden] { display: none !important; }

/* --- Screens -------------------------------------------------------------- */
.screen {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  min-height: 100dvh;
}

/* =====================  LOGIN  =========================================== */
.screen--login {
  display: grid;
  place-items: center;
  padding: calc(var(--pad) + var(--safe-top)) var(--pad) calc(var(--pad) + var(--safe-bottom));
}
.login {
  width: 100%;
  max-width: 380px;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.brand { text-align: center; margin-bottom: 36px; }
.brand__mark {
  display: inline-grid; place-items: center;
  width: 64px; height: 64px;
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700;
  color: var(--on-action);
  background: linear-gradient(150deg, var(--c-blue-light), var(--c-blue-dark));
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.brand__name {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1; color: var(--text-strong);
}
.brand__tagline { color: var(--text-muted); margin: 8px 0 0; font-size: 15px; }

/* =====================  FORM / FIELDS  =================================== */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field__label {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.01em;
}
.field__input,
.field__select {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font-size: 16px; /* >=16px avoids iOS zoom on focus */
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field__input::placeholder { color: var(--text-dim); }
.field__input:focus,
.field__select:focus {
  outline: none;
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.field__hint { font-size: 12px; color: var(--text-dim); }
.field__row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form__error {
  margin: 0; padding: 11px 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(192, 57, 43, 0.35);
  border-radius: var(--radius-sm);
  color: var(--danger); font-size: 14px; font-weight: 600;
}
.form__ok {
  margin: 0; padding: 11px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.40);
  border-radius: var(--radius-sm);
  color: #0d7a59; font-size: 14px; font-weight: 600;
}
.field__input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--surface-2);
}
.login__form { margin-top: 4px; }
.login__hint { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 22px; }

/* =====================  BUTTONS (blue)  ================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px;
  transition: transform 0.12s, background 0.18s, border-color 0.18s, opacity 0.18s, filter 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn--block { width: 100%; }
.btn--sm { padding: 9px 14px; font-size: 13px; font-weight: 600; }

/* Primary = blue action */
.btn--primary {
  background: linear-gradient(150deg, var(--c-blue-light), var(--c-blue-dark));
  color: var(--on-action);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}
.btn--primary:hover { filter: brightness(1.06); }

/* Ghost = light outline */
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--c-blue); color: var(--c-blue-dark); }

.btn--danger {
  background: var(--danger-soft);
  border-color: rgba(192, 57, 43, 0.4);
  color: var(--danger);
}
.btn--danger:hover { background: rgba(192, 57, 43, 0.18); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text); font-size: 15px; font-weight: 700;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn--close { font-weight: 500; font-size: 16px; color: var(--text-muted); }

/* =====================  TOPBAR / SUMMARY  =============================== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--pad) + var(--safe-top)) var(--pad) 22px;
  background: rgba(238, 241, 245, 0.86);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.topbar__row { display: flex; align-items: center; gap: 12px; }

.wallet-switch {
  flex: 1; min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: 10px;
  text-align: left;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, background 0.18s;
}
.wallet-switch:hover { border-color: var(--border-strong); }
.wallet-switch__label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-dim);
}
.wallet-switch__value {
  font-weight: 700; font-size: 16px; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wallet-switch__chevron { color: var(--text-muted); font-size: 12px; transition: transform 0.2s; }
.wallet-switch[aria-expanded="true"] .wallet-switch__chevron { transform: rotate(180deg); }

.summary { text-align: center; margin-top: 26px; }
.summary__caption {
  font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
}
.summary__amount {
  font-family: var(--font-display);
  font-size: clamp(44px, 14vw, 58px);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  margin: 8px 0 4px;
  color: var(--c-blue-dark);            /* total in blue */
  font-variant-numeric: tabular-nums;
  animation: rise 0.4s ease both;
}
.summary__meta { font-size: 13px; color: var(--text-muted); }

/* =====================  CONTENT / ENTRIES  ============================== */
.content {
  padding: 8px var(--pad) calc(120px + var(--safe-bottom));
}
.content__actions {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 2px 14px;
}
.content__title {
  font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}

.entries { display: grid; gap: 10px; }
.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, transform 0.12s, box-shadow 0.18s;
  animation: rise 0.35s ease both;
}
.entry:active { transform: scale(0.99); }
.entry:hover { border-color: var(--border-strong); }
.entry__desc { font-weight: 700; font-size: 16px; line-height: 1.3; color: var(--text-strong); }
.entry__amount {
  font-family: var(--font-display);
  font-weight: 800; font-size: 18px; white-space: nowrap;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.entry__meta {
  grid-column: 1 / 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.entry__sep { color: var(--text-dim); }
.entry__tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  background: rgba(37, 99, 235, 0.10);
  border: 1px solid rgba(37, 99, 235, 0.20);
  border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--c-blue-dark);
}

/* Empty state */
.empty {
  text-align: center; color: var(--text-dim);
  padding: 48px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty__icon { font-size: 30px; opacity: 0.5; }
.empty__text { margin-top: 10px; font-size: 15px; }

/* =====================  FAB (blue)  ===================================== */
.fab {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(22px + var(--safe-bottom));
  z-index: 20;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 300; line-height: 1;
  color: var(--on-action);
  background: linear-gradient(150deg, var(--c-blue-light), var(--c-blue-dark));
  border: none; border-radius: 50%;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.40);
  transition: transform 0.14s, filter 0.18s;
}
.fab:hover { filter: brightness(1.06); }
.fab:active { transform: translateX(-50%) scale(0.92); }

/* =====================  BOTTOM SHEET  ================================== */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(11, 15, 20, 0.40);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade 0.2s ease;
}
.sheet {
  width: 100%; max-width: var(--maxw);
  max-height: 92dvh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px var(--pad) calc(var(--pad) + var(--safe-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up 0.32s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}
.sheet__grip {
  width: 42px; height: 5px; border-radius: 999px;
  background: var(--border-strong);
  margin: 6px auto 10px;
}
.sheet__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.sheet__title { font-family: var(--font-display); font-size: 23px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-strong); }
.sheet__body { display: grid; gap: 16px; }
.sheet__footer { display: flex; gap: 12px; margin-top: 6px; }
.sheet__footer .btn { flex: 1; }
.sheet__divider { border: none; border-top: 1px solid var(--border); margin: 8px 0 2px; }

/* Wallet picker list */
.wallet-list { display: grid; gap: 8px; }
.wallet-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.18s, background 0.18s;
}
.wallet-option:hover { border-color: var(--border-strong); }
.wallet-option[aria-selected="true"] {
  border-color: var(--c-blue);
  background: rgba(37, 99, 235, 0.07);
}
.wallet-option__name { font-weight: 700; font-size: 16px; color: var(--text-strong); }
.wallet-option__check { color: var(--c-blue-dark); font-weight: 800; }

/* Tag manager */
.tag-rows { display: grid; gap: 8px; }
.tag-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tag-row__input {
  flex: 1; min-width: 0;
  background: transparent; border: none; color: var(--text-strong);
  font-size: 15px; font-weight: 600; padding: 6px 0;
}
.tag-row__input:focus { outline: none; }
.tag-row__del {
  flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px;
  display: grid; place-items: center;
}
.tag-row__del:hover { color: var(--danger); border-color: rgba(192, 57, 43, 0.4); }
.tag-add { display: flex; gap: 8px; }
.tag-add .field__input { flex: 1; }

/* Tag card with color palette (settings → tag manager) */
.tag-card {
  display: grid; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tag-card .tag-row { background: transparent; border: none; padding: 0; }
.tag-card__dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  transition: transform 0.12s, box-shadow 0.15s;
}
.swatch:active { transform: scale(0.9); }
.swatch.is-selected { box-shadow: 0 0 0 2px var(--text-strong); }

/* Wallet actions (settings) */
.wallet-actions { display: flex; gap: 8px; }
.wallet-actions .btn { flex: 1; }

/* Member selector (toggle list) */
.member-list { display: grid; gap: 8px; }
.member-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s, background 0.18s;
}
.member-row[aria-pressed="true"] { border-color: var(--c-blue); background: rgba(37, 99, 235, 0.06); }
.member-row:disabled { cursor: default; opacity: 0.9; }
.member-row__avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
}
.member-row__name { flex: 1; font-weight: 600; color: var(--text-strong); }
.member-row__check { color: var(--c-blue-dark); font-weight: 800; opacity: 0; }
.member-row[aria-pressed="true"] .member-row__check { opacity: 1; }

/* =====================  TAG FILTER (main)  ============================== */
.filter {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter::-webkit-scrollbar { display: none; }
.filter:empty { display: none; }
.filter-chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap;
  transition: transform 0.12s, filter 0.18s, background 0.18s, border-color 0.18s;
}
.filter-chip:active { transform: scale(0.95); }
.filter-chip__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.filter-chip.is-active-plain {
  background: var(--c-black); color: #fff; border-color: var(--c-black);
}

/* Account sheet */
.account-card { text-align: center; padding: 8px 0 4px; }
.account-card__avatar {
  width: 64px; height: 64px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--c-blue-light), var(--c-blue-dark));
  color: var(--on-action); font-weight: 800; font-size: 22px;
  font-family: var(--font-display);
}
.account-card__name { font-size: 19px; font-weight: 800; color: var(--text-strong); }
.account-card__detail { color: var(--text-muted); font-size: 14px; margin-top: 3px; }

/* =====================  SCROLLBARS  ==================================== */
/* Thin, themed, inset scrollbar so long sheets/pages don't show the chunky
   native bar at the edge. The transparent border + background-clip insets the
   thumb away from the rounded corner. */
html, .sheet {
  scrollbar-width: thin;                              /* Firefox */
  scrollbar-color: var(--border-strong) transparent;  /* Firefox: thumb / track */
}
html {
  /* Reserve the scrollbar space so opening a sheet (which locks body scroll)
     doesn't shift the layout sideways. */
  scrollbar-gutter: stable;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;       /* visual inset */
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
  background-clip: padding-box;
}

/* =====================  ANIMATIONS  ==================================== */
@keyframes rise   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 600px) {
  body { padding-block: 0; }
}
