:root {
  color-scheme: dark;
  --bg: #070b14;
  --surface: #101827;
  --surface-2: #172338;
  --surface-3: #1d2b42;
  --line: rgba(148, 163, 184, .18);
  --text: #f8fafc;
  --muted: #a7b4c8;
  --blue: #2494ff;
  --blue-2: #0876df;
  --green: #20c878;
  --red: #ff5268;
  --purple: #a879ff;
  --gold: #f8c84e;
  --radius: 18px;
  --shadow: 0 10px 28px rgba(0,0,0,.22);
}
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html { background: var(--bg); }
body { margin: 0; background: radial-gradient(ellipse at 50% -15%, #17345c 0, var(--bg) 48%); color: var(--text); display: flex; flex-direction: column; height: 100dvh; min-height: 560px; overflow: hidden; font-size: 16px; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-header { flex: 0 0 auto; display:flex; align-items:center; justify-content:space-between; gap:12px; padding: max(14px, env(safe-area-inset-top)) 16px 12px; background:rgba(7,11,20,.88); border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:11px; min-width:0; }
.brand-icon { width:46px; height:46px; display:grid; place-items:center; flex:0 0 auto; border-radius:15px; font-size:25px; background:linear-gradient(145deg,#176bc0,#102d52); box-shadow:0 6px 18px rgba(22,119,220,.28); }
.brand-title { font-size:20px; line-height:1.15; font-weight:850; letter-spacing:.1px; }
.brand-title span { color:#f6c84c; }
.brand-subtitle { color:var(--muted); font-size:11px; margin-top:4px; }
.header-status { color:#7dd3fc; font-size:11px; white-space:nowrap; border:1px solid rgba(56,189,248,.25); background:rgba(14,116,144,.12); border-radius:99px; padding:7px 9px; }
.nav-tabs { flex:0 0 auto; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; padding:10px 12px; background:rgba(10,16,28,.96); border-bottom:1px solid var(--line); }
.nav-tab { min-width:0; min-height:54px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; padding:7px 3px; text-align:center; font-size:13px; font-weight:750; color:#aab6c8; cursor:pointer; border:1px solid transparent; border-radius:13px; background:transparent; }
.nav-tab.active { color:white; border-color:rgba(56,160,255,.42); background:linear-gradient(145deg,#1268bd,#16447d); box-shadow:0 5px 16px rgba(0,112,220,.2); }
#pageCalc, #pageSummary, .content-page { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#34445d transparent; }
#pageCalc { display:flex; flex-direction:column; overflow:hidden; }
.display-box { flex:0 0 auto; background:linear-gradient(135deg,#13243a,#101827 70%); padding:14px 16px; display:flex; justify-content:space-between; align-items:center; gap:14px; border-bottom:1px solid var(--line); }
.mic-btn { background:linear-gradient(145deg,#ff5369,#c91f48); border:2px solid rgba(255,255,255,.18); color:#fff; border-radius:18px; width:62px; height:62px; font-size:27px; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; box-shadow:0 7px 20px rgba(255,61,94,.25); }
.mic-btn.listening { background:#e11d48; border-color:#fda4af; animation:pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform:scale(1); } 50% { transform:scale(1.06); } }
.num-area { text-align:right; flex:1; min-width:0; overflow:hidden; padding-left:8px; }
.expr { font-size:13px; color:var(--muted); min-height:18px; }
.amount { font-size:clamp(30px,8vw,42px); font-weight:850; color:#ff7184; overflow-x:auto; white-space:nowrap; }
.controls { flex:0 0 auto; padding:12px; background:#0c1422; display:flex; flex-direction:column; gap:9px; }
.type-row, .input-row { display:flex; gap:9px; }
.type-btn { flex:1; min-height:48px; padding:10px; border:1px solid #34435a; border-radius:13px; font-size:17px; font-weight:800; cursor:pointer; background:#1b293d; color:#c3cede; }
.type-btn.active-exp { background:linear-gradient(135deg,#e9435b,#b91f3b); border-color:#ff7083; color:#fff; }
.type-btn.active-inc { background:linear-gradient(135deg,#19b978,#087a50); border-color:#41df9c; color:#fff; }
select, input { min-width:0; min-height:46px; padding:10px 12px; border-radius:12px; border:1px solid #34445d; background:#172338; color:#fff; font-size:15px; }
select { flex:1.2; }
input[type="date"] { flex:1; color-scheme:dark; }
input[type="text"] { width:100%; }
input::placeholder { color:#8493a9; }
.keypad { flex:0 0 auto; display:grid; grid-template-columns:repeat(4,1fr); gap:7px; padding:10px 12px; background:#080e19; }
.key { min-height:48px; padding:9px 0; font-size:21px; font-weight:800; border:1px solid #2b3b53; border-radius:13px; background:linear-gradient(180deg,#1d2b40,#152136); color:#fff; cursor:pointer; }
.key:active { transform:scale(.98); background:#2b4567; }
.key.op { background:#172d49; color:#6bc3ff; }
.key.clear { background:#3a1c2b; border-color:#713247; color:#ff8291; }
.key.save { grid-column:span 2; background:linear-gradient(135deg,#1689f5,#075dbb); border-color:#45aaff; color:#fff; font-size:16px; }
.list-section { flex:1 1 auto; min-height:90px; overflow-y:auto; padding:12px; background:#0b1320; border-top:1px solid var(--line); }
.section-title { display:flex; justify-content:space-between; align-items:center; gap:8px; margin:4px 0 9px; font-size:14px; color:#d6e0ef; font-weight:800; }
.refresh-btn { background:#17283e; border:1px solid #36506f; color:#7dccff; border-radius:9px; min-height:34px; padding:5px 10px; font-size:12px; font-weight:700; cursor:pointer; }
.item-card { display:flex; justify-content:space-between; align-items:center; gap:10px; background:linear-gradient(120deg,#17243a,#121d30); padding:11px 12px; border-radius:13px; margin-bottom:7px; font-size:14px; border:1px solid var(--line); border-left:4px solid var(--blue); }
.item-card.history { background:#111d2e; border-left-color:#50617b; }
.item-left { display:flex; flex-direction:column; gap:3px; min-width:0; }
.item-cat { font-weight:800; overflow-wrap:anywhere; }
.item-note { font-size:12px; color:#a8b6ca; overflow-wrap:anywhere; }
.item-right { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.del-btn { background:#3b1d2a; border:1px solid #693247; border-radius:9px; min-width:34px; min-height:34px; color:#ff7184; font-size:16px; cursor:pointer; }
.empty-msg { font-size:14px; color:#8d9bb0; text-align:center; padding:18px 8px; }
#pageSummary { padding:14px; background:transparent; }
.sum-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:13px; }
.sum-card, .chart-box, .card-panel { background:linear-gradient(145deg,#17253a,#101a2a); padding:15px; border-radius:var(--radius); border:1px solid var(--line); box-shadow:var(--shadow); }
.sum-card.full { grid-column:span 2; }
.sum-title { font-size:14px; color:#b4c1d3; margin-bottom:6px; }
.sum-num { font-size:clamp(21px,5vw,27px); font-weight:850; overflow-wrap:anywhere; }
.chart-box { padding:15px; }
.bar-row { margin-bottom:13px; }
.bar-label { display:flex; justify-content:space-between; gap:8px; font-size:14px; margin-bottom:6px; }
.bar-bg { background:#29384e; height:12px; border-radius:99px; overflow:hidden; }
.bar-fill { height:100%; background:linear-gradient(90deg,#168cf0,#64c8ff); border-radius:99px; }
.bottom-bar { flex:0 0 auto; padding:10px 13px max(10px,env(safe-area-inset-bottom)); background:rgba(9,15,26,.97); border-top:1px solid var(--line); display:flex; flex-direction:column; gap:8px; box-shadow:0 -8px 24px rgba(0,0,0,.18); }
.balance-row { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.balance-label { font-size:13px; color:#c4cfde; }
.balance-val { font-size:20px; font-weight:850; color:#58c5ff; }
.sync-btn { width:100%; min-height:48px; padding:11px; border:1px solid #39d99a; border-radius:13px; background:linear-gradient(135deg,#18b978,#08794f); color:#fff; font-size:15px; font-weight:850; cursor:pointer; }
.sync-btn:disabled { background:#263447; border-color:#39485d; color:#8290a4; }
.content-page { padding:13px; background:transparent; }
.card-panel { margin-bottom:12px; }
.card-panel h3 { margin:0 0 12px; font-size:18px; }
.card-panel label { display:block; color:#bac7d8; font-size:14px; font-weight:700; margin:12px 0 6px; }
.card-panel input, .card-panel select { width:100%; min-height:48px; }
.primary-btn { width:100%; min-height:50px; padding:12px; margin-top:14px; border:1px solid #45aaff; border-radius:13px; background:linear-gradient(135deg,#1689f5,#075dbb); color:white; font-weight:850; font-size:16px; }
.hint { color:#a3b1c5; font-size:13px; line-height:1.55; margin:5px 0 12px; }
.invest-fill { background:linear-gradient(90deg,#9866f5,#c4a5ff); }
.invest-amount { color:#c4a5ff; font-weight:850; }
.date-small { font-size:11px; color:#8c9bb0; }
.keyword-group { border-top:1px solid var(--line); padding:14px 0; }
.keyword-group h4 { margin:0 0 4px; color:#7dccff; font-size:16px; }
.keyword-add { display:flex; gap:8px; margin:10px 0; }
.keyword-add input { flex:1; min-width:0; }
.keyword-add button, .keyword-chip button { border:1px solid #45aaff; border-radius:10px; min-width:58px; min-height:42px; padding:8px 12px; background:#1269b9; color:white; font-weight:800; }
.keyword-list { display:flex; flex-wrap:wrap; gap:7px; }
.keyword-chip { display:inline-flex; align-items:center; gap:8px; background:#1b2a40; border:1px solid #354b68; border-radius:13px; padding:5px 6px 5px 11px; font-size:13px; }
.keyword-chip button { min-width:38px; min-height:32px; padding:4px 8px; border-color:#8a3a50; background:#63283b; font-size:12px; }
#pageInvest .card-panel:first-child { border-top:3px solid var(--purple); }
#pageOptions .card-panel { border-top:3px solid var(--blue); }
@media (min-width:700px) {
  body { max-width:760px; margin:0 auto; border-left:1px solid var(--line); border-right:1px solid var(--line); }
  .app-header { padding-left:22px; padding-right:22px; }
  .nav-tabs { padding-left:20px; padding-right:20px; }
  .controls, .keypad, .list-section { padding-left:20px; padding-right:20px; }
  .content-page, #pageSummary { padding:20px; }
}
@media (max-height:700px) and (max-width:480px) {
  .app-header { padding-top:8px; padding-bottom:8px; }
  .brand-icon { width:40px; height:40px; }
  .nav-tab { min-height:46px; }
  .display-box { padding-top:8px; padding-bottom:8px; }
  .mic-btn { width:52px; height:52px; }
  .key { min-height:42px; }
}

.category-manager { margin:10px 0 13px; padding:12px; border:1px solid var(--line); border-radius:13px; background:rgba(20,34,54,.72); }
.category-head { display:flex; align-items:center; flex-wrap:wrap; gap:7px; margin-bottom:8px; }
.category-head strong { flex:1 1 100%; color:#f8fafc; font-size:15px; overflow-wrap:anywhere; }
.danger-small { min-height:34px; padding:5px 9px; border:1px solid #754052; border-radius:9px; background:#402033; color:#ffb4c0; font-size:12px; font-weight:700; }
.category-manager .keyword-add { margin:8px 0; }
.category-manager .keyword-add button { min-width:68px; }
