:root {
  --bg: #0b0e14;
  --card: #151a23;
  --card2: #1d2430;
  --text: #e8edf4;
  --muted: #7d8794;
  --green: #2ecc71;
  --red: #ff5c5c;
  --accent: #4c8dff;
  --accent2: #6c5ce7;
  --border: #222a36;
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.green { color: var(--green); }
.red { color: var(--red); }

button { font-family: inherit; cursor: pointer; }

/* ================= auth ================= */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 340px; text-align: center; }
.auth-logo { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 14px; }
.auth-box h1 { font-size: 34px; letter-spacing: .5px; }
.auth-box p { margin: 6px 0 22px; }
.auth-tabs {
  display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 16px;
}
.auth-tabs button {
  flex: 1; padding: 10px; border: none; border-radius: 9px; background: none;
  color: var(--muted); font-size: 15px; font-weight: 600;
}
.auth-tabs button.active { background: var(--accent); color: #fff; }
.auth-box input {
  width: 100%; padding: 14px 16px; margin-bottom: 10px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 16px;
}
.btn-primary {
  width: 100%; padding: 14px; border-radius: 12px; border: none; margin-top: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 16px; font-weight: 700;
}
.btn-danger {
  width: 100%; padding: 13px; border-radius: 12px; border: none;
  background: var(--red); color: #fff; font-size: 15px; font-weight: 600; margin-top: 14px;
}
.btn-ghost {
  width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--border);
  background: none; color: var(--muted); font-size: 15px; margin-top: 8px;
}
.error { color: var(--red); margin-top: 12px; font-size: 14px; }

/* ================= header ================= */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11,14,20,.93); backdrop-filter: blur(10px);
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
}
.header-row { display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 21px; font-weight: 800; letter-spacing: .5px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); font-size: 16px;
}
.header-right { display: flex; gap: 8px; align-items: center; }
.month-btn {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600;
}
.year-row { justify-content: center; margin: 12px 0; }
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.month-cell {
  padding: 13px 0; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); font-size: 14px;
}
.month-cell.active { background: var(--accent); border-color: var(--accent); font-weight: 700; }
.month-cell:disabled { opacity: .3; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 13.5px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ================= layout ================= */
.tab { padding: 16px 14px 150px; max-width: 640px; margin: 0 auto; }
section { margin-top: 22px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; padding: 0 2px; }
.sec-head h2 { font-size: 16px; font-weight: 700; }
.link { border: none; background: none; color: var(--accent); font-size: 13.5px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.card h3 { font-size: 14px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }

/* ================= hero ================= */
.hero {
  background: linear-gradient(135deg, #1b2c4f 0%, #232055 55%, #2a1a4a 100%);
  border-radius: 22px; padding: 22px 20px; border: 1px solid #2c3a5e;
}
.hero-label { font-size: 13px; color: #9fb0d0; }
.hero-value { display: block; font-size: 38px; font-weight: 800; margin: 6px 0 16px; letter-spacing: -.5px; }
.hero-row { display: flex; gap: 10px; }
.hero-pill {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07); border-radius: 14px; padding: 10px 12px;
}
.hero-pill span {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.hero-pill.green span { background: rgba(46,204,113,.2); color: var(--green); }
.hero-pill.red span { background: rgba(255,92,92,.2); color: var(--red); }
.hero-pill small { display: block; font-size: 11.5px; color: #9fb0d0; }
.hero-pill b { font-size: 15px; }

/* ================= category bars ================= */
.cat-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.cat-ico {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.cat-mid { flex: 1; min-width: 0; }
.cat-top { display: flex; justify-content: space-between; font-size: 14.5px; margin-bottom: 5px; }
.cat-top .amount { font-weight: 700; }
.bar { height: 5px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }

/* ================= transaction rows ================= */
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tx:last-child { border-bottom: none; }
.tx .cat-ico { width: 40px; height: 40px; }
.tx-mid { flex: 1; min-width: 0; }
.tx-name { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-amt { font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.day-head {
  display: flex; justify-content: space-between; padding: 14px 4px 6px;
  font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.search-wrap input {
  width: 100%; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px; margin-bottom: 10px;
}

/* trips */
.trip-card {
  background: linear-gradient(135deg, #15323a, #14283d); border: 1px solid #1f4250;
  border-radius: var(--radius); padding: 14px 16px; margin-top: 14px;
}
.trip-head { display: flex; justify-content: space-between; margin-bottom: 4px; font-weight: 700; }

/* ================= chat ================= */
#tab-chat { padding-bottom: 190px; }
#chat-log { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 16px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--card2); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--muted); }
#chat-suggestions { margin-top: 34px; display: flex; flex-direction: column; gap: 9px; align-items: center; }
#chat-suggestions p { margin-bottom: 6px; font-size: 14px; }
.sug {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 10px 16px; font-size: 14px;
}
#chat-bar {
  position: fixed; bottom: 64px; left: 0; right: 0; z-index: 15;
  display: flex; gap: 8px; padding: 10px 12px;
  background: rgba(11,14,20,.96); border-top: 1px solid var(--border);
  max-width: 640px; margin: 0 auto;
}
#chat-input {
  flex: 1; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px;
}
#chat-send { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 18px; }

/* ================= fab + nav ================= */
#fab {
  position: fixed; right: 18px; bottom: 84px; z-index: 15;
  width: 58px; height: 58px; border-radius: 18px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 30px; font-weight: 300;
  box-shadow: 0 8px 22px rgba(76,141,255,.35);
}
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; background: rgba(11,14,20,.97);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button { flex: 1; padding: 8px 0 10px; border: none; background: none; color: var(--muted); font-size: 11px; }
nav button span { display: block; font-size: 19px; margin-bottom: 2px; filter: grayscale(1) opacity(.6); }
nav button.active { color: var(--accent); }
nav button.active span { filter: none; }

/* ================= sheet & toast ================= */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet-body {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); text-align: center;
  max-height: 80vh; overflow-y: auto;
}
.sheet-body h3 { font-size: 20px; margin-bottom: 4px; }
.sheet-body.left { text-align: left; }
.sheet-input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); font-size: 17px; margin-bottom: 12px;
}
.action-btn {
  display: block; width: 100%; padding: 15px 14px; margin-top: 9px;
  border-radius: 13px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); font-size: 15px; text-align: left;
}
.check-row {
  display: flex; align-items: center; gap: 10px; margin: 12px 0;
  font-size: 14.5px; color: var(--muted);
}
.check-row input { width: 19px; height: 19px; accent-color: var(--accent); }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.cat-cell {
  display: flex; align-items: center; gap: 9px; padding: 12px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); font-size: 13.5px; text-align: left;
}
.tx-info-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tx-info-head .big { font-size: 17px; font-weight: 700; }

/* expandable category blocks */
.cat-block .cat-row { cursor: pointer; }
.cat-chev { color: var(--muted); font-size: 12px; transition: transform .2s; margin-left: 4px; }
.cat-block.open .cat-chev { transform: rotate(90deg); }
.cat-txs { padding-left: 6px; }
#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--card2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 20px; font-size: 14px; max-width: 90%;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

canvas { max-width: 100%; }
