/* Expense Manager — blue fintech theme (light), Plus Jakarta Sans. */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/plus-jakarta-sans-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/plus-jakarta-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --brand: #2459e0;
  --brand-press: #1d4cc4;
  --brand-soft: #e0e9fc;
  --header-muted: #d6e2fb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --track: #e5e7eb;
  --sep: #eef0f3;
  --fill: #f1f3f6;
  --amber-bg: #fff1dc;
  --amber-text: #8a4b00;
  --dot: #fdba74;
  --income: #12925a;
  --income-soft: #ddf3e8;
  --expense: #d93b30;
  --expense-soft: #fde5e3;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 6px 18px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.12);
  --r-card: 18px;
  --r-tile: 16px;
  --r-btn: 16px;
  --pad: 20px;
  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
}
body.locked { overflow: hidden; }
input, textarea { -webkit-user-select: text; user-select: text; }
h1, h2, h3, h4, p, ol { margin: 0; }
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* The status bar sits on the blue header. */
.statusbar-bg { position: fixed; inset: 0 0 auto; height: var(--safe-top); background: var(--brand); z-index: 30; }

/* ---------- Layout ---------- */

#view {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 var(--pad) calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack:empty { display: none; }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.pos { color: var(--income); }
.neg { color: var(--expense); }

.i { width: 22px; height: 22px; flex: none; stroke-width: 1.8; }
.i.sm { width: 19px; height: 19px; }
.i.xs { width: 13px; height: 13px; stroke-width: 2.2; }
.i.lg { width: 46px; height: 46px; stroke-width: 1.4; }
.chev { color: var(--text-3); }

/* ---------- Blue header ---------- */

.hero {
  margin: 0 calc(-1 * var(--pad));
  padding: calc(var(--safe-top) + 14px) var(--pad) 24px;
  background: var(--brand);
  color: #fff;
  border-radius: 0 0 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; }
.hello { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hello-av {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 700; font-size: 18px;
}
.hello-text { display: flex; flex-direction: column; min-width: 0; }
.hello-text span { font-size: 13px; color: var(--header-muted); }
.hello-text b { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.hero-sub { font-size: 14px; color: var(--header-muted); margin-top: -12px; }

.ring-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
}
.ring-btn:active { background: rgba(255, 255, 255, 0.12); }
.ring-btn .dot {
  position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--dot); box-shadow: 0 0 0 2px var(--brand);
}

.hero-label { font-size: 14px; color: var(--header-muted); }
.hero-amount {
  font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.htile { background: rgba(255, 255, 255, 0.12); border-radius: var(--r-tile); padding: 12px 14px; min-width: 0; }
.htile small { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--header-muted); }
.htile b { display: block; margin-top: 4px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hbtn {
  height: 52px; border-radius: var(--r-btn); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 700;
}
.hbtn.solid { background: #fff; color: var(--brand); }
.hbtn.outline { border: 1.5px solid rgba(255, 255, 255, 0.7); color: #fff; }
.hbtn:active { opacity: 0.85; }

.hero-search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px;
  background: #fff; border-radius: 14px; color: var(--text-3);
}
.hero-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); -webkit-appearance: none; appearance: none; }
.hero-back { display: inline-flex; align-items: center; gap: 2px; color: #fff; font-weight: 600; font-size: 16px; }
.hero-back .i { width: 24px; height: 24px; }
.hero-link { color: #fff; font-weight: 600; font-size: 15px; }
.hero-person { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin-top: -6px; }
.hero-person h2 { font-size: 20px; font-weight: 700; margin-top: 6px; }
.hero-person .hero-amount { margin-top: 0; }
.hero-person .avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }

/* ---------- Section titles, links, buttons ---------- */

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.section-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.link { color: var(--brand); font-weight: 600; font-size: 15px; padding: 6px 0; display: inline-flex; align-items: center; }
.link.strong { font-weight: 700; }
.link:active { opacity: 0.6; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 14px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.white { background: #fff; color: var(--brand); }
.btn.tinted { background: var(--brand-soft); color: var(--brand); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:active { opacity: 0.8; }

.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--text-2); flex: none; }
.icon-btn:active { background: var(--fill); }

/* ---------- Cards & lists ---------- */

.card {
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; text-align: left; width: 100%;
}
.card h3 { font-size: 16px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
button.card:active { transform: scale(0.99); }

.list { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.sep > * + * {
  background-image: linear-gradient(var(--sep), var(--sep));
  background-repeat: no-repeat;
  background-position: right top;
  background-size: calc(100% - var(--inset, 16px)) 1px;
}
.group-label { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 4px; margin: 6px 0 -8px; }
.footnote { font-size: 13px; color: var(--text-2); padding: 0 4px; margin-top: -6px; line-height: 1.45; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 16px; }
.row-label { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; }
.row-label .i { color: var(--brand); }
.row > .seg { flex: 1; }
.row input:not([type="checkbox"]), .row textarea, .row select { border: 0; background: transparent; outline: none; min-width: 0; padding: 0; }
.row input { text-align: right; }
.row .plain { text-align: left; flex: 1; width: 100%; padding: 8px 0; }
.row textarea { resize: none; line-height: 1.45; }
.row input[type="date"] {
  -webkit-appearance: none; appearance: none;
  background: var(--fill); border-radius: 10px; padding: 7px 12px; min-height: 36px;
  text-align: center; color: var(--text); flex: none; font-weight: 600;
}
.row input[type="date"]::-webkit-date-and-time-value { text-align: center; }
.row-input { display: inline-flex; align-items: center; gap: 4px; max-width: 55%; }
.row-input input { width: 100%; font-weight: 600; }
.select-wrap { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); max-width: 62%; }
.select-wrap select { -webkit-appearance: none; appearance: none; color: var(--text-2); text-align: right; text-align-last: right; width: 100%; text-overflow: ellipsis; }

.row-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 52px; color: var(--brand); font-weight: 600; text-align: left; }
.row-btn.destructive { color: var(--expense); }
.row-btn.center { justify-content: center; }
.row-btn:not(:disabled):active, .entry:active, .person-row:active, .pick:active, .share-main:active { background-color: var(--fill); }

/* entries */
.entry, .person-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 16px; min-height: 66px; }
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.entry-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-share { font-size: 12.5px; color: var(--text-2); font-weight: 500; }

.cat-ic { width: var(--s); height: var(--s); border-radius: 12px; display: grid; place-items: center; flex: none; }
.cat-ic .i { width: calc(var(--s) * 0.5); height: calc(var(--s) * 0.5); }
.avatar {
  width: var(--s); height: var(--s); border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: calc(var(--s) * 0.38);
}

.tag { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; flex: none; white-space: nowrap; }
.entry-sub .tag { margin-left: 4px; padding: 1px 7px; font-size: 11px; }
.tag.warn { color: var(--amber-text); background: var(--amber-bg); }
.tag.ok { color: var(--income); background: var(--income-soft); }
.tag.blue { color: var(--brand); background: var(--brand-soft); }
.tag.plain { color: var(--text-2); background: none; padding: 0; font-weight: 600; }

/* ---------- Dashboard ---------- */

.month-switch { display: flex; align-items: center; justify-content: space-between; }
.month-switch h2 { font-size: 18px; font-weight: 700; }
.month-switch .icon-btn { color: var(--brand); background: var(--card); box-shadow: var(--shadow); }
.month-switch .icon-btn:disabled { opacity: 0.3; box-shadow: none; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border-radius: var(--r-tile); box-shadow: var(--shadow); padding: 13px 14px; min-width: 0; }
.tile small { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.tile b { display: block; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.prompt-card { flex-direction: row; align-items: center; color: var(--text-2); font-size: 14.5px; font-weight: 500; }
.prompt-card > .i:first-child { color: var(--brand); }
.prompt-card.warn { background: var(--amber-bg); color: var(--amber-text); box-shadow: none; }
.prompt-card.warn > .i:first-child { color: var(--amber-text); }
.prompt-card.warn .chev { color: var(--amber-text); opacity: 0.6; }
.owed { flex-direction: row; align-items: center; }
.owed b { font-size: 20px; font-weight: 800; }

.qi { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.qi.blue { color: var(--brand); background: var(--brand-soft); }
.qi.income { color: var(--income); background: var(--income-soft); }
.qi.warn { color: var(--amber-text); background: var(--amber-bg); }

.budget-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.budget-line b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.progress { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--brand)); transition: width 0.4s; }

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 14px; position: relative; }
.tl { display: grid; grid-template-columns: 52px 1fr; gap: 12px; position: relative; }
.tl::before { content: ""; position: absolute; left: 25px; top: 52px; bottom: -14px; width: 1.5px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl-date {
  width: 52px; height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); color: var(--text); position: relative; z-index: 1;
}
.tl-date span { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-2); }
.tl-date b { font-size: 17px; font-weight: 800; line-height: 1.1; }
.tl-date.dark { background: var(--text); border-color: var(--text); color: #fff; }
.tl-date.dark span { color: #c9ced8; }
.tl-card {
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; text-align: left; min-width: 0;
}
.tl-card:active { transform: scale(0.99); }
.tl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.tl-name { font-size: 13.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tl-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-amt { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tl-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); font-weight: 500; }
.tl-card .progress { margin-top: 4px; }
.timeline-fade { position: relative; }

.donut-wrap { position: relative; width: 190px; height: 190px; margin: 4px auto 2px; }
.donut { width: 100%; height: 100%; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.donut-center b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-direction: column; gap: 11px; font-size: 14.5px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 10px; align-items: center; font-weight: 500; }
.legend-row .dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-row .pct { color: var(--text-2); font-variant-numeric: tabular-nums; }
.legend-row .amt { min-width: 84px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.bars { width: 100%; height: auto; display: block; overflow: visible; }
.bars .grid { stroke: var(--sep); stroke-width: 1; }
.bars .axis { fill: var(--text-2); font-size: 11px; font-family: var(--font); font-weight: 500; }
.bar-income { fill: var(--brand); }
.bar-spent { fill: var(--dot); }
.key { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.banner { display: flex; gap: 12px; align-items: center; background: var(--brand-soft); color: var(--text); border-radius: var(--r-tile); padding: 12px 8px 12px 14px; font-size: 13.5px; line-height: 1.4; }
.banner > .i { color: var(--brand); }

/* ---------- Transactions ---------- */

.tx-controls { display: flex; flex-direction: column; gap: 12px; }
.tx-list { display: flex; flex-direction: column; gap: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 2px var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 4px 8px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #e9ecf1; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: background-color 0.15s, color 0.15s; }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12); font-weight: 700; }

.empty { text-align: center; padding: 44px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-2); }
.empty .i { color: var(--text-3); margin-bottom: 4px; }
.empty h3 { color: var(--text); font-size: 19px; font-weight: 700; }
.empty p { max-width: 280px; line-height: 1.45; font-size: 14.5px; }
.empty .btn { margin-top: 12px; }

/* ---------- Splits ---------- */

.share-row { display: flex; align-items: center; gap: 10px; padding-right: 12px; }
.share-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 0 12px 16px; text-align: left; min-height: 64px; }
.share-amt { font-weight: 700; white-space: nowrap; }
.struck { color: var(--text-3); text-decoration: line-through; font-weight: 500; }

/* ---------- Settings ---------- */

.install { gap: 10px; }
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.steps .i { vertical-align: -1px; color: var(--brand); }

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

.amount-row { display: flex; align-items: baseline; gap: 6px; padding: 10px 18px; }
.amount-cur { font-size: 28px; font-weight: 700; color: var(--text-3); }
.amount-row input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 0;
  font-size: 42px; font-weight: 800; letter-spacing: -0.03em; color: var(--text);
}
.amount-row.income input { color: var(--income); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 14px 4px; padding: 16px 8px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.cat .dot { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; transition: transform 0.15s; }
.cat:active .dot { transform: scale(0.92); }
.cat.on { color: var(--text); font-weight: 700; }

.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; min-height: 54px; text-align: left; font-weight: 500; }
.check { width: 24px; height: 24px; border-radius: 8px; border: 1.8px solid #cdd2da; display: grid; place-items: center; color: #fff; flex: none; }
.check.on { background: var(--brand); border-color: var(--brand); }
.check .i { width: 14px; height: 14px; stroke-width: 3; }
.custom-amt { width: 96px; flex: none; font-weight: 600; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #dfe3ea; border-radius: 999px; transition: background-color 0.2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(17, 24, 39, 0.2); transition: transform 0.22s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Overlays ---------- */

.overlay { position: fixed; inset: 0; z-index: 50; }
.overlay.closing { pointer-events: none; }
.backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.4); opacity: 0; transition: opacity 0.3s; }
.overlay.open .backdrop { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--safe-top) + 12px);
  max-width: 600px; margin: 0 auto; background: var(--bg);
  border-radius: 24px 24px 0 0; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(100%); transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.overlay.open .sheet { transform: none; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px var(--pad); min-height: 58px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 16px; font-weight: 700; }
.sheet-head > :last-child { justify-self: end; }
.sheet-head > :first-child { justify-self: start; }
.sheet-head .link.strong { background: var(--brand); color: #fff; padding: 8px 16px; border-radius: 12px; font-size: 14px; }
.sheet-head .link.strong:disabled { background: #c3d1f5; opacity: 1; }
.sheet-body > * { flex-shrink: 0; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 18px var(--pad) calc(var(--safe-bottom) + 40px); display: flex; flex-direction: column; gap: 14px; }

.notice { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; }
.notice b { display: block; font-size: 15px; }
.notice span.small { display: block; margin-top: 2px; line-height: 1.4; }

.action-sheet {
  position: absolute; left: 10px; right: 10px; bottom: calc(var(--safe-bottom) + 10px);
  max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px;
  transform: translateY(130%); transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
}
.overlay.open .action-sheet { transform: none; }
.as-group { background: var(--card); border-radius: var(--r-card); overflow: hidden; }
.as-head { padding: 16px 18px 12px; text-align: center; font-size: 13px; color: var(--text-2); line-height: 1.4; }
.as-title { font-weight: 700; color: var(--text); font-size: 14.5px; margin-bottom: 2px; }
.as-btn { width: 100%; min-height: 56px; font-size: 17px; font-weight: 600; color: var(--brand); }
.as-btn.destructive { color: var(--expense); }
.as-btn:active { background-color: var(--fill); }
.as-cancel { background: var(--card); border-radius: var(--r-card); font-weight: 700; color: var(--text); }

.dialog {
  position: absolute; top: 34%; left: 50%; width: min(310px, calc(100% - 48px));
  transform: translate(-50%, -50%) scale(1.06); opacity: 0; transition: transform 0.2s, opacity 0.2s;
  background: var(--card); border-radius: 22px; text-align: center; overflow: hidden; margin: 0; box-shadow: var(--shadow-lg);
}
.overlay.open .dialog { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.dialog-body { padding: 22px 20px 18px; display: flex; flex-direction: column; gap: 4px; }
.dialog h3 { font-size: 17px; font-weight: 800; }
.dialog input { margin-top: 12px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); outline: none; width: 100%; }
.dialog input:focus { border-color: var(--brand); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.dialog-actions button { min-height: 46px; border-radius: 14px; font-weight: 700; color: var(--brand); background: var(--brand-soft); }
.dialog-actions .primary, .dialog-actions [type="submit"] { background: var(--brand); color: #fff; }
.dialog-actions.single { grid-template-columns: 1fr; }
.dialog-actions button:active { opacity: 0.8; }
.dialog-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 10px; color: var(--amber-text); background: var(--amber-bg); }
.dialog-msg { font-size: 14px; line-height: 1.45; color: var(--text-2); margin-top: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; transition: transform 0.25s, opacity 0.25s; pointer-events: none;
  background: var(--text); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px max(8px, calc((100% - 600px) / 2)) calc(var(--safe-bottom) + 6px);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 2px 0 2px; }
.tab .i { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }

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