/* PaisaVibe: the ballpoint hisaab notebook.
   Blue ballpoint ink on white paper, ruled lines, red pen only when you overspend.
   One family: Anek Latin (Ek Type, Mumbai). Amounts are set narrow and heavy. */
:root {
  --bg: #ffffff; /* paper */
  --text: #1f2a7a; /* ink: ballpoint blue, 12.6:1 */
  --muted: #5c6185; /* pencil: secondary text, 6:1 */
  --line: #e4e6f0; /* rule: notebook lines */
  --outline: #c9cce0; /* decoration only: chip borders */
  --edge: #8e92ae; /* edges that carry meaning (inputs, data bars, switch track): 3:1 */
  --soft: #f2f3f9;
  --pos: #0f7a3e; /* paisa aaya: money in */
  --danger: #c62828; /* red pen: over budget, delete */
  --on-text: #ffffff;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #10132e;
    --text: #eceef8;
    --muted: #a3a8c8;
    --line: #23274a;
    --outline: #353a63;
    --edge: #6a6f98;
    --soft: #191d40;
    --pos: #4ade80;
    --danger: #ff7a7a;
    --on-text: #10132e;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #10132e;
  --text: #eceef8;
  --muted: #a3a8c8;
  --line: #23274a;
  --outline: #353a63;
  --edge: #6a6f98;
  --soft: #191d40;
  --pos: #4ade80;
  --danger: #ff7a7a;
  --on-text: #10132e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Anek Latin', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
::selection { background: var(--text); color: var(--bg); }
input { caret-color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pos { color: var(--pos); }
.danger-text { color: var(--danger); }

/* ---------- Layout ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100%; }
.view { padding: 20px 24px calc(104px + env(safe-area-inset-bottom)); outline: none; }
.view.no-tabs { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.screen { display: flex; flex-direction: column; gap: 36px; }
.screen.tight { gap: 28px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }

/* ---------- Type ---------- */
.wordmark { font-weight: 700; font-size: 18px; font-stretch: 87.5%; letter-spacing: 0; }
.display { font-weight: 700; font-size: 48px; font-stretch: 75%; line-height: 1; letter-spacing: -0.01em; }
.title { font-weight: 700; font-size: 32px; font-stretch: 87.5%; letter-spacing: -0.01em; line-height: 1.1; }
.h2 { font-size: 15px; font-weight: 600; }
.label { font-size: 14px; font-weight: 500; color: var(--muted); }
/* Amounts: narrow and heavy, the one bold thing on each screen. */
.big { position: relative; display: inline-block; font-weight: 700; font-size: 64px; font-stretch: 75%; letter-spacing: -0.01em; line-height: 1; font-variant-numeric: tabular-nums; }
/* Over budget: the amount turns red-pen and gets one strike, like a teacher marking a mistake. */
.big.over { color: var(--danger); }
.big.over::after {
  content: ''; position: absolute; left: -6px; right: -6px; top: 54%; height: 4px; border-radius: 2px;
  background: var(--danger); transform: rotate(-4deg); transform-origin: left center;
}
.big.over.strike::after { animation: strike 0.55s cubic-bezier(0.23, 1, 0.32, 1) 0.25s both; }
@keyframes strike { from { transform: rotate(-4deg) scaleX(0); } to { transform: rotate(-4deg) scaleX(1); } }
.big-sm { font-weight: 700; font-size: 48px; font-stretch: 75%; letter-spacing: -0.01em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.num { font-weight: 700; font-size: 24px; font-stretch: 87.5%; font-variant-numeric: tabular-nums; }
.lead { font-size: 16px; line-height: 1.5; }

/* ---------- Controls ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; padding: 0 20px; border-radius: var(--radius); border: 1px solid var(--outline);
  background: var(--bg); font-weight: 600; font-size: 16px; text-decoration: none; color: var(--text);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--text); color: var(--on-text); border-color: var(--text); }
.btn.ghost { border-color: transparent; color: var(--muted); font-weight: 500; height: 48px; }
.btn.small { height: 40px; font-size: 14px; border-radius: 20px; padding: 0 16px; }
.btn.small.primary { background: var(--text); }
.btn.danger { color: var(--danger); }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: 22px; padding: 0;
}
.icon-btn.edge { margin-left: -12px; }
.link { background: none; border: 0; padding: 0; min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -24px; padding: 0 24px 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--outline);
  background: var(--bg); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background 0.15s ease, color 0.15s ease;
}
.chip.sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 18px; }
.chip[aria-pressed='true'] { background: var(--text); color: var(--on-text); border-color: var(--text); }

.text-tabs { display: flex; gap: 20px; }
.text-tabs button {
  height: 44px; padding: 0 2px; border: 0; background: transparent; color: var(--muted); font-weight: 500; font-size: 15px;
}
.text-tabs button[aria-pressed='true'] { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select {
  height: 48px; border: 0; border-bottom: 1px solid var(--edge); background: transparent; border-radius: 0;
  font-size: 17px; font-weight: 500; color: var(--text); padding: 0; width: 100%; min-width: 0;
}
.field input:focus, .field select:focus { outline: none; border-bottom-color: var(--text); }
.field input::placeholder, .big-input input::placeholder { color: var(--muted); font-weight: 400; }
.big-input { display: flex; align-items: baseline; gap: 2px; }
.big-input input { border: 0; background: transparent; padding: 0; width: 100%; min-width: 0; font-weight: 700; font-size: 56px; font-stretch: 75%; letter-spacing: -0.01em; line-height: 1.1; }
.big-input input:focus { outline: none; }
.big-input span { font-weight: 700; font-size: 56px; font-stretch: 75%; }
.inline-input[type='time'] { width: 148px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--text); }
.inline-input { height: 44px; border: 1px solid var(--edge); border-radius: 10px; background: var(--bg); padding: 0 10px; font-size: 15px; width: 120px; text-align: right; }

/* 44px tap area around a 32px track */
.switch { position: relative; width: 52px; height: 44px; border: 0; padding: 0; flex-shrink: 0; background: transparent; }
.switch::before { content: ''; position: absolute; left: 0; top: 6px; width: 52px; height: 32px; border-radius: 16px; background: var(--edge); transition: background 0.2s ease; }
.switch::after { content: ''; position: absolute; top: 9px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1); }
.switch[aria-checked='true']::before { background: var(--text); }
.switch[aria-checked='true']::after { transform: translateX(20px); background: var(--bg); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Data display ---------- */
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar.thin { height: 2px; border-radius: 0; }
.bar > i { display: block; height: 100%; background: var(--text); transition: width 0.4s ease; }
.bar > i.over { background: var(--danger); }

.split2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.split2 > * { padding: 16px 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.split2 > :first-child { border-right: 1px solid var(--line); padding-right: 16px; }
.split2 > :last-child { padding-left: 20px; }
.split2 button, .split2 a { border: 0; background: none; text-align: left; color: inherit; text-decoration: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 12px 0;
  border: 0; background: none; text-align: left; font-size: 15px;
}
button.list-row:active { opacity: 0.6; }
.list-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: 14px; color: var(--muted); }
.list-amt { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-value { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.list-value svg { width: 16px; height: 16px; }
.avatar { width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--outline); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; background: transparent; text-transform: uppercase; }
.avatar.lg { width: 56px; height: 56px; border-radius: 28px; font-size: 20px; }
.avatar.btn-like { width: 44px; height: 44px; border-radius: 22px; padding: 0; }

.cat-row { display: flex; flex-direction: column; gap: 8px; }
.cat-row .row-between { font-size: 14px; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; border-bottom: 1px solid var(--line); }
.chart > span { flex: 1; min-width: 3px; border-radius: 3px 3px 0 0; background: var(--edge); }
.chart > span.max { background: var(--text); }
.chart-labels { display: flex; gap: 6px; margin-top: -12px; }
.chart-labels > span { flex: 1; min-width: 3px; text-align: center; font-size: 12px; color: var(--muted); overflow: visible; white-space: nowrap; }

.callout { display: flex; flex-direction: column; gap: 6px; padding-left: 16px; border-left: 2px solid var(--text); }
.callout p { font-size: 14px; line-height: 1.5; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 12px 0; }
.note { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 10;
  display: flex; justify-content: space-around; align-items: center; height: calc(76px + env(safe-area-inset-bottom));
  padding: 0 8px env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; min-height: 52px; justify-content: center;
  border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500;
}
.tab[aria-current='page'] { color: var(--text); font-weight: 600; }
.add-btn { width: 52px; height: 52px; border-radius: 26px; border: 0; background: var(--text); color: var(--on-text); display: flex; align-items: center; justify-content: center; transition: transform 0.1s ease; }
.add-btn:active { transform: scale(0.94); }

/* ---------- Sheets ---------- */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 480px; margin: auto auto 0; max-height: 92vh;
  border-radius: 20px 20px 0 0; background: var(--bg); color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.4); }
.sheet[open] { animation: rise 0.22s cubic-bezier(0.23, 1, 0.32, 1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet.full { max-height: none; height: 100%; max-width: 480px; margin: 0 auto; border-radius: 0; }
.form { display: flex; flex-direction: column; gap: 20px; padding: 16px 24px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }

/* Add entry */
.add { display: flex; flex-direction: column; gap: 16px; min-height: 100%; padding: 12px 24px calc(20px + env(safe-area-inset-bottom)); }
.add-top { display: flex; align-items: center; justify-content: space-between; margin: 0 -12px; }
.amount-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 4px; }
/* Fixed 60px box; the font steps down for long amounts (set in app.js) so nothing overflows. */
.amount { font-weight: 700; font-size: 64px; font-stretch: 75%; letter-spacing: -0.01em; height: 64px; line-height: 64px; font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 100%; }
.date-chip input { border: 0; background: transparent; color: var(--muted); font-size: 13px; text-align: center; padding: 4px; }
.hint { font-size: 14px; color: var(--muted); margin-top: -8px; min-height: 18px; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: auto; }
.keypad button { height: 56px; border: 0; background: transparent; font-size: 24px; font-weight: 400; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.keypad svg { width: 24px; height: 24px; }
.keypad button:active { background: var(--soft); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--text); color: var(--on-text); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 100; max-width: calc(100% - 48px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Welcome */
.welcome { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); padding-top: 44px; gap: 0; }
.welcome .display { margin-top: 96px; }
.welcome .lead { margin-top: 16px; color: var(--muted); }
.welcome .list { margin-top: 56px; border-top: 1px solid var(--line); }
.welcome .list-row { gap: 14px; }
.welcome .bottom { margin-top: auto; padding-top: 32px; display: flex; flex-direction: column; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) {
  .view { padding-left: 16px; padding-right: 16px; }
  .chips.scroll { margin: 0 -16px; padding: 0 16px 2px; }
  .display { font-size: 34px; }
  .big { font-size: 44px; }
}
