/* Wallet Manager: dark purple glass look, mobile first. */
:root {
  --bg1: #0f0c29; --bg2: #302b63; --bg3: #24243e;
  --a1: #ff6ec4; --a2: #7873f5; --a3: #4ade80; --danger: #fb7185;
  --glass: rgba(255,255,255,.08); --line: rgba(255,255,255,.18);
  --muted: rgba(255,255,255,.68);
  --tab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: #fff; line-height: 1.4; overflow-x: hidden;
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3)) fixed;
  min-height: 100vh;
}
.orb { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .35; z-index: 0; pointer-events: none; }
.orb.one { width: 300px; height: 300px; background: var(--a1); top: -90px; left: -90px; }
.orb.two { width: 340px; height: 340px; background: var(--a2); bottom: -120px; right: -100px; }

.view {
  position: relative; z-index: 1; max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--tab-h) + 96px + env(safe-area-inset-bottom));
}
h1 { font-size: 1.4rem; margin: 4px 0 14px; background: linear-gradient(90deg, var(--a1), var(--a2), var(--a3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 1rem; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.muted { color: var(--muted); }
small, .small { font-size: .82rem; }
.up { color: var(--a3); } .down { color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 22px 0; }

.card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 20px; padding: 16px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.18);
  margin-bottom: 14px;
}
.big { font-size: 2.1rem; font-weight: 700; letter-spacing: -.5px; word-break: break-word; }
.label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 44px; padding: 6px 14px; border-radius: 14px; background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.chip b { display: block; font-size: .95rem; }
.chip small { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

/* buttons and inputs */
button { font: inherit; color: #fff; cursor: pointer; }
.btn {
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 14px; font-weight: 600;
  background: linear-gradient(90deg, var(--a1), var(--a2));
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: rgba(255,255,255,.1); border: 1px solid var(--line); }
.btn.danger { background: rgba(251,113,133,.18); border: 1px solid var(--danger); color: var(--danger); }
.btn.small { min-height: 44px; padding: 0 12px; font-size: .85rem; }
.iconbtn { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 1.1rem; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--a3); outline-offset: 2px;
}
label.f, div.f { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  font: inherit; color: #fff; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.08); border: 1px solid var(--line); outline: none;
}
select option { color: #111; }
input::placeholder, textarea::placeholder { color: rgba(255,255,255,.4); }
input[type="color"] { padding: 4px; }
.search { margin-bottom: 8px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

/* segmented toggle */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: rgba(255,255,255,.08); border-radius: 14px; margin-bottom: 12px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { color: #fff; background: linear-gradient(90deg, var(--a1), var(--a2)); }

/* transaction rows */
.day { display: flex; justify-content: space-between; margin: 16px 2px 6px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; }
.tx { background: var(--glass); border: 1px solid transparent; border-radius: 16px; margin-bottom: 8px; overflow: hidden; }
.tx:hover { border-color: var(--line); }
.tx-main { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; background: none; border: 0; text-align: left; }
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: 0 0 auto; }
.tx-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.amt { font-weight: 700; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: .72rem; background: rgba(120,115,245,.35); border: 1px solid var(--a2); }
.dots { display: inline-flex; }
.dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #2a2660; margin-left: -4px; }
.dots i:first-child { margin-left: 0; }
.items { padding: 4px 12px 12px 64px; display: grid; gap: 6px; border-top: 1px solid rgba(255,255,255,.08); }
.item { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.item .grow small { color: var(--muted); display: block; }

/* bars */
.bar { height: 10px; border-radius: 10px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: 10px; }
.cat-row { display: block; width: 100%; text-align: left; min-height: 56px; padding: 8px 4px; background: none; border: 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.cat-row[aria-expanded="true"] { background: rgba(255,255,255,.05); }
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-nav select { flex: 1; }

/* list in settings */
.list-row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.list-row:last-child { border-bottom: 0; }

/* fab + tab bar */
.fab {
  position: fixed; z-index: 20; right: 18px; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0; font-size: 2rem; line-height: 1;
  background: linear-gradient(135deg, var(--a1), var(--a2)); box-shadow: 0 10px 28px rgba(120,115,245,.6);
}
.tabbar {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20,17,50,.88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button { background: none; border: 0; display: grid; place-items: center; align-content: center; gap: 0; color: var(--muted); min-height: 48px; }
.tabbar button span { font-size: 1.3rem; line-height: 1.2; }
.tabbar button b { font-size: .7rem; font-weight: 600; }
.tabbar button[aria-current="page"] { color: #fff; }
.tabbar button[aria-current="page"] b { background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* sheet (full-screen modal) */
.sheet, .modal { position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3)); animation: slide .22s ease-out; }
.modal { z-index: 60; background: rgba(10,8,30,.82); display: grid; align-items: end; }
.modal[hidden], .sheet[hidden], .toast[hidden] { display: none; }
.modal .panel { background: linear-gradient(160deg, #2a2660, #1b1840); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 640px; width: 100%; margin: 0 auto; max-height: 92vh; overflow-y: auto; }
.sheet-in { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 0; background: rgba(20,17,50,.9); backdrop-filter: blur(10px); }
.sheet-head h1 { margin: 0; flex: 1; font-size: 1.15rem; }
.total-input { font-size: 2.2rem; font-weight: 700; text-align: center; min-height: 64px; }
.item-row { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; }
.item-row .row > * { min-width: 0; }
.remaining { position: sticky; bottom: 0; padding: 10px 12px; border-radius: 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; backdrop-filter: blur(10px); }
.remaining.ok { background: rgba(74,222,128,.18); border: 1px solid var(--a3); color: var(--a3); }
.remaining.bad { background: rgba(251,113,133,.18); border: 1px solid var(--danger); color: var(--danger); }
.savebar { display: grid; gap: 10px; margin-top: 10px; }
.err { color: var(--danger); font-size: .85rem; min-height: 1.2em; }

.toast { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 90vw; padding: 10px 16px; border-radius: 14px; background: #1b1840; border: 1px solid var(--a2); box-shadow: 0 8px 24px rgba(0,0,0,.5); }

@keyframes slide { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (min-width: 700px) { .filters { grid-template-columns: repeat(4, 1fr); } }

/* Category organizing (Settings) */
.cat-org { gap: 6px; }
.cat-org.sub { padding-left: calc(var(--depth, 1) * 16px + 4px); position: relative; }
.cat-org.sub::before { content: ''; position: absolute; left: calc(var(--depth, 1) * 16px - 10px); top: 0; bottom: 50%; width: 10px; border-left: 2px solid rgba(255,255,255,.18); border-bottom: 2px solid rgba(255,255,255,.18); border-bottom-left-radius: 6px; }
.cat-org .grow { min-width: 0; }
.cat-org.sub .ico { width: 30px; height: 30px; font-size: .95rem; flex: none; }
.cat-org .iconbtn { min-width: 40px; }
.cat-org .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn:disabled { opacity: .3; }
details.merge { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); }
details.merge summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }

.subsum { margin: 6px 0 4px 12px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-size: .9rem; }
.subsum .row { min-height: 32px; }

/* Category manager */
.cm-head { display: flex; align-items: center; gap: 10px; }
.cm-head h1 { margin: 4px 0 14px; }
.cm-head .btn { margin-bottom: 10px; }
.cm-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cm-tools .btn { padding: 0 12px; }
.btn.ghost[aria-pressed="true"] { background: linear-gradient(90deg, var(--a1), var(--a2)); border-color: transparent; }
.cm-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; column-gap: 4px; min-height: 52px; padding: 4px 0 4px calc(var(--depth, 0) * 14px); border-bottom: 1px solid rgba(255,255,255,.08); border-radius: 10px; }
.cm-row.on { background: rgba(120,115,245,.22); }
.cm-row.dim { opacity: .6; }
.cm-lead { flex: 1 1 190px; min-width: 0; display: flex; align-items: center; gap: 4px; }
.cm-chev { flex: none; width: 40px; min-width: 40px; min-height: 44px; padding: 0; }
span.cm-chev { display: block; }
.cm-main { flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: default; }
label.cm-main { cursor: pointer; }
.cm-row.sub .ico { width: 32px; height: 32px; font-size: 1rem; }
.cm-main .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-main .grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-check { width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; flex: none; accent-color: var(--a2); }
.cm-act { flex: none; display: flex; gap: 2px; }
.cm-act .iconbtn { min-width: 40px; min-height: 44px; padding: 0; }
.cm-bar { position: fixed; z-index: 16; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 640px; margin: 0 auto; padding: 8px 10px; background: rgba(20,17,50,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
.cm-bar[hidden] { display: none; }
.cm-bar .btn { flex: 1 1 70px; padding: 0 6px; font-size: .8rem; }
.cm-count { flex: 1 1 100%; font-weight: 600; font-size: .85rem; }
.cm-dup { margin: 0 0 10px; }
.dup-pair { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.dup-side { min-width: 0; overflow-wrap: anywhere; }
.dup-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.dup-btn { flex: 1 1 auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-bottom: 12px; }
.pick { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.08); font-size: 1.25rem; padding: 0; }
.pick.swatch { border-color: rgba(255,255,255,.35); }

/* Category editor page */
.cat-edit .pick-grid { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.cat-edit .pick { min-height: 40px; font-size: 1.1rem; }
.cat-edit .pick.swatch { min-height: 32px; }
.cat-edit > .two:last-of-type { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 6px); z-index: 5; margin: 0 -8px; padding: 8px; border-radius: 16px; background: rgba(36,36,62,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* Category picker page and "choose" buttons */
.choose { width: 100%; justify-content: space-between; text-align: left; gap: 8px; }
.choose .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list { padding: 6px; }
.pick-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 6px 12px 6px calc(12px + var(--depth, 0) * 18px); border: 0; border-radius: 12px; background: none; color: inherit; text-align: left; font: inherit; }
.pick-row + .pick-row { border-top: 1px solid rgba(255,255,255,.06); }
.pick-row small { display: block; }
.pick-row.on { background: rgba(120,115,245,.22); }
.pick-row:active { background: rgba(255,255,255,.08); }

/* Merge page */
.merge-src { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.merge-src .grow { min-width: 0; }
.merge-src small, .pick-confirm small { display: block; }
.pick-confirm { border-color: rgba(120,115,245,.6); margin-bottom: 12px; }
.pick-confirm p { margin: 0 0 6px; }
.pick-confirm ul { margin: 0 0 12px; padding-left: 18px; }
.pick-hint { margin: 0 0 10px; }
