
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #151518;
  --panel2: #1b1b1f;
  --text: #f3f3f4;
  --muted: #9b9ba4;
  --line: #2a2a30;
  --accent: #ffffff;
  --danger: #ff6b6b;
  --good: #a8f0b0;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input, select { font: inherit; }
button { cursor: pointer; }

#app { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(110px + var(--safe-bottom)); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 10px;
}
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--muted); font-weight: 700; }
h1, h2 { margin: 0; }
h1 { font-size: 34px; line-height: 1; }
h2 { font-size: 22px; }
.headline-row { display: flex; align-items: center; gap: 10px; margin-top: 3px; }

.badge {
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  padding: 5px 7px; border-radius: 999px; background: #342b17; color: #ffd98a;
}

.icon-btn {
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text); font-size: 26px; line-height: 1;
}
.icon-btn.small { width: 36px; height: 36px; font-size: 22px; }

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: #111114; border: 1px solid var(--line); padding: 5px; border-radius: 14px;
  margin: 12px 0 18px;
}
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 10px 8px;
  border-radius: 10px; font-weight: 700;
}
.tab.active { background: var(--panel2); color: var(--text); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.summary-card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  margin-bottom: 14px;
}
.summary-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.net-worth { font-size: clamp(34px, 8vw, 52px); font-weight: 800; letter-spacing: -.04em; margin-top: 3px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.summary-number { font-size: 20px; font-weight: 750; margin-top: 3px; }

.date-wrap { min-width: 140px; }
.date-wrap label { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; margin-bottom: 6px; }
input[type="date"], input[type="text"], input[type="password"], select {
  width: 100%; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 12px; outline: none;
}
input:focus, select:focus { border-color: #666672; }

.group { margin: 18px 0 10px; }
.group-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; padding: 0 2px;
}
.group-title h3 { margin: 0; font-size: 13px; letter-spacing: .12em; }
.group-total { color: var(--muted); font-weight: 750; font-size: 13px; }
.rows {
  border: 1px solid var(--line); border-radius: 15px; overflow: hidden;
}
.row {
  display: grid; grid-template-columns: minmax(0,1fr) 148px 32px; align-items: center; gap: 8px;
  padding: 10px 10px 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-wrap { position: relative; }
.money-wrap::before { content: "$"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money-input {
  width: 100%; text-align: right; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 8px 9px 22px; outline: none;
  font-variant-numeric: tabular-nums;
}
.money-input:focus { border-color: #666672; }
.row-menu {
  width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 20px;
}

.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + var(--safe-bottom)); z-index: 20;
}
.save-bar > * { max-width: 728px; margin-left: auto; margin-right: auto; }
.primary, .secondary, .ghost {
  border-radius: 12px; padding: 12px 14px; font-weight: 800;
}
.primary { border: 0; background: var(--accent); color: #09090a; }
.secondary { border: 1px solid var(--line); background: var(--panel2); color: var(--text); text-align: center; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); }
.danger { color: var(--danger); }
.wide { width: 100%; display: block; }
.save-status { color: var(--muted); text-align: center; font-size: 11px; margin-top: 6px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 34px 0; text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.45; }
.stack { display: grid; gap: 9px; margin-top: 12px; }
.file-button input { display: none; }

.history-list { display: grid; gap: 7px; margin-top: 14px; }
.history-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 12px; padding: 11px 12px; text-align: left;
}
.history-item.selected { border-color: #777784; }
.history-date { color: var(--muted); font-size: 12px; }
.history-value { font-weight: 800; font-variant-numeric: tabular-nums; }

canvas { width: 100%; display: block; background: #111114; border: 1px solid var(--line); border-radius: 14px; }

dialog {
  width: min(92vw, 520px); border: 1px solid var(--line); border-radius: 18px;
  background: var(--panel); color: var(--text); padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
dialog form { padding: 16px; display: grid; gap: 12px; }
dialog label { color: var(--muted); font-size: 12px; font-weight: 700; display: grid; gap: 6px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

.lock-screen {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-items: center; padding: 22px;
}
.lock-card { width: min(420px,100%); text-align: center; }
.lock-card h1 { margin-top: 18px; }
.lock-card p { color: var(--muted); }
.lock-card input { margin: 14px 0 10px; text-align: center; font-size: 22px; letter-spacing: .2em; }
.lock-card .primary { width: 100%; }
.app-mark {
  width: 82px; height: 82px; display: grid; place-items: center; margin: 0 auto;
  border-radius: 22px; background: #f4f4f5; color: #09090a; font-weight: 900; font-size: 26px;
}

@media (max-width: 430px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .summary-top { display: block; }
  .date-wrap { margin-top: 14px; min-width: 0; }
  .row { grid-template-columns: minmax(0,1fr) 132px 28px; padding-left: 10px; }
  .row-name { font-size: 14px; }
}
