:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111318;
  --muted: #6b7280;
  --border: #e6e8ec;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 1px 2px rgba(16,18,28,.04), 0 8px 24px rgba(16,18,28,.06);
  --radius: 18px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #0c0e13;
  --card: #151821;
  --text: #eef0f6;
  --muted: #8a91a2;
  --border: #232733;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  transition: background .25s, color .25s;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, #2f325a22, transparent), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--border); border-radius: 24px; padding: 34px 28px; box-shadow: var(--shadow); text-align: center; animation: rise .4s ease; }
.login-logo { font-size: 30px; margin-bottom: 6px; }
.login-card h1 { font-size: 22px; font-weight: 800; }
.login-card p { margin: 4px 0 22px; }
.login-card input { width: 100%; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font-size: 15px; margin-bottom: 10px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* APP */
.app { max-width: 720px; margin: 0 auto; padding-bottom: 90px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 18px 8px; }
.topbar h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.topbar h1 .wave { display: inline-block; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn { background: var(--card); border: 1px solid var(--border); border-radius: 12px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; color: var(--text); box-shadow: var(--shadow); }
.content { padding: 12px 18px 0; }

/* CARDS */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; transition: transform .18s ease, box-shadow .18s ease; }
.card:hover { transform: translateY(-2px); }

/* SUMMARY GRID */
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 4px 0 16px; }
.sum { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.sum .lab { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sum .val { font-size: 24px; font-weight: 800; margin-top: 4px; }
.sum .val.good { color: var(--green); }
.sum .val.bad { color: var(--red); }

/* STREAK HERO */
.streak-card { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-radius: 22px; padding: 24px; margin-bottom: 16px; box-shadow: 0 12px 32px rgba(99,102,241,.35); display: flex; align-items: center; justify-content: space-between; }
.streak-card .big { font-size: 46px; font-weight: 800; line-height: 1; }
.streak-card .lab { opacity: .9; font-size: 13px; }
.streak-card .milestone { font-size: 12.5px; opacity: .9; margin-top: 8px; background: rgba(255,255,255,.18); padding: 5px 10px; border-radius: 999px; display: inline-block; }

/* SECTION HEAD */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-head h2 { font-size: 17px; font-weight: 700; }

/* TASK ADD */
.task-add { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.task-add input[type=text] { flex: 1; min-width: 140px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-size: 15px; font-family: inherit; }
.task-add input[type=text]:focus { outline: none; border-color: var(--accent); }
.task-add select { padding: 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-size: 14px; font-family: inherit; }

.btn { border: none; border-radius: 12px; padding: 12px 18px; font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: transform .12s ease, opacity .12s ease; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* LIST (tasks / transactions) */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; }
.item .fill { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 15px; }
.item .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.pill.high { background: #ef44441a; color: var(--red); }
.pill.normal { background: var(--accent)1a; color: var(--accent); }
.pill.low { background: var(--green)1a; color: var(--green); }
.chk { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: transparent; color: transparent; font-size: 14px; }
.chk.on { background: var(--green); border-color: var(--green); color: #fff; }
.mini-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; cursor: pointer; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.mini-btn:hover { color: var(--text); border-color: var(--muted); }

/* MEALS */
.meals { display: flex; flex-direction: column; gap: 12px; }
.meal { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.meal .mhead { display: flex; justify-content: space-between; align-items: center; }
.meal .mname { font-weight: 700; font-size: 15px; }
.meal .mtime { font-size: 12px; color: var(--muted); }
.meal .mdesc { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.ratings { display: flex; gap: 6px; margin-top: 10px; }
.ratings button { flex: 1; font-size: 20px; padding: 8px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.ratings button.on { border-color: var(--accent); background: var(--accent)22; }

/* MONEY */
.money-ranges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.mr { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); text-align: center; }
.mr .lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mr .in { font-size: 18px; font-weight: 700; color: var(--green); }
.mr .out { font-size: 18px; font-weight: 700; color: var(--red); }
.tx-form { display: flex; flex-direction: column; gap: 10px; }
.tx-form input { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font-size: 15px; font-family: inherit; }
.tx-form input:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); font-family: inherit; }
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.tx.income { color: var(--green); font-weight: 700; }
.tx.expense { color: var(--red); font-weight: 700; }

/* GOALS */
.goals { display: grid; grid-template-columns: 1fr; gap: 16px; }
.gcol .gh { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.gitem { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.gitem .fill { flex: 1; }
.gitem.done .t { text-decoration: line-through; color: var(--muted); }

/* PROGRESS */
.progress { display: grid; grid-template-columns: 1fr; gap: 14px; }
.pcard { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.pcard .pl { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* CHAT */
.chat-wrap { display: flex; flex-direction: column; height: 60vh; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.bubble { max-width: 82%; padding: 11px 14px; border-radius: 16px; font-size: 14.5px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.hermes { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-size: 15px; font-family: inherit; }
.chat-input input:focus { outline: none; border-color: var(--accent); }

/* BOTTOM NAV */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(0,0,0,.06); max-width: 720px; margin: 0 auto; z-index: 50; }
.bottom-nav button { background: none; border: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-family: inherit; padding: 4px 8px; }
.bottom-nav button span { font-size: 10px; }
.bottom-nav button .i { font-size: 22px; }
.bottom-nav button.active { color: var(--accent); font-weight: 600; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (min-width: 720px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .goals { grid-template-columns: repeat(3, 1fr); }
  .progress { grid-template-columns: repeat(2, 1fr); }
}
