:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-elevated: #1e222b;
  --border: #2a2f3a;
  --text: #e9ebef;
  --text-dim: #9aa1af;
  --accent: #e8622c;
  --accent-dim: #b9481c;
  --green: #34c77b;
  --red: #e5484d;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 72px;
}

#app { max-width: 720px; margin: 0 auto; padding: 12px; }

.hidden { display: none !important; }

/* Login */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-box h1 { margin: 0 0 4px; font-size: 28px; }
.login-box .subtitle { color: var(--text-dim); margin-bottom: 24px; font-size: 14px; }

input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  margin-bottom: 10px;
}
label { font-size: 13px; color: var(--text-dim); display: block; margin: 6px 0 4px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:active { background: var(--accent-dim); }
button.secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--red); }
button.full { width: 100%; }
button.small { padding: 8px 10px; font-size: 13px; }

.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* Header */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 16px;
}
header.topbar h2 { margin: 0; font-size: 20px; }
header.topbar .logo { display: flex; align-items: center; gap: 8px; }
header.topbar .logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* Bottom nav */
nav.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}
nav.bottom-nav button {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-radius: 8px;
}
nav.bottom-nav button.active { color: var(--accent); background: rgba(232,98,44,0.1); }
nav.bottom-nav button .icon { font-size: 18px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg-elevated); border-radius: 10px; padding: 12px 8px; text-align: center; }
.stat .val { font-size: 18px; font-weight: 700; }
.stat .lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.stat.income .val { color: var(--green); }
.stat.expense .val { color: var(--red); }
.stat.margin .val { color: var(--accent); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  gap: 8px;
}
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 14px; }
.list-item .sub { font-size: 12px; color: var(--text-dim); }
.list-item .amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.list-item .amount.income { color: var(--green); }
.list-item .amount.expense { color: var(--red); }
.list-item .actions { display: flex; gap: 4px; }
.list-item .actions button { padding: 4px 8px; font-size: 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button {
  background: var(--bg-elevated); color: var(--text-dim); white-space: nowrap;
  padding: 8px 12px; font-size: 13px;
}
.tabs button.active { background: var(--accent); color: #fff; }

.empty-state { text-align: center; color: var(--text-dim); padding: 24px 8px; font-size: 14px; }

.chip { display: inline-block; background: var(--bg-elevated); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text-dim); }

.fab {
  position: fixed; right: 16px; bottom: 84px;
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  z-index: 15;
}

dialog {
  border: none; border-radius: var(--radius); padding: 0;
  background: var(--bg-card); color: var(--text);
  width: 92%; max-width: 420px;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-inner { padding: 18px; }
.dialog-inner h3 { margin-top: 0; }
.dialog-actions { display: flex; gap: 8px; margin-top: 12px; }

.checkbox-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 10px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.checkbox-row input { width: auto; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
table th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; }

.badge-ok { color: var(--green); }
.badge-fail { color: var(--red); }

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
