:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #14171f;
  --surface-alt: #1b1f29;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f3f5;
  --text-muted: rgba(242, 243, 245, 0.6);
  --accent: #6366f1;
  --danger: #ef4444;
  --positive: #22c55e;
  --mobile-width: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #05060a;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* Mobile-only: the app never grows past phone width, even on a desktop browser. */
.app-shell, .signin-screen {
  width: 100%;
  max-width: var(--mobile-width);
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; letter-spacing: 0.5px; }

.page {
  flex: 1;
  padding: 16px 20px 96px;
  overflow-y: auto;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.nav-item {
  flex: 1;
  padding: 14px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.nav-item.active { color: var(--accent); }

.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.hero h2, .page-header h2 { margin: 0 0 12px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label { font-size: 11px; color: var(--text-muted); }
.metric-value { font-size: 14px; font-weight: 700; }

.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.surface-card h3 { margin: 0 0 10px; font-size: 14px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.record-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  text-align: left;
  color: var(--text);
}

.record-row:last-child { border-bottom: none; }
.record-row.deleted { opacity: 0.5; }

.record-main { display: flex; flex-direction: column; gap: 2px; }
.record-label { font-weight: 600; font-size: 14px; }
.record-sub { font-size: 12px; color: var(--text-muted); }
.record-amount { font-weight: 700; font-size: 13px; }
.record-amount.positive { color: var(--positive); }

.summary-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.summary-line:last-child { border-bottom: none; }

.empty-state { color: var(--text-muted); font-size: 13px; margin: 8px 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip-button {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
}
.chip-button.active { border-color: var(--accent); color: var(--accent); }

.month-input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.primary-button, .secondary-button, .danger-button, .small-button {
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
}
.primary-button { background: var(--accent); color: white; }
.secondary-button { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.danger-button { background: transparent; color: var(--danger); border-color: var(--danger); }
.small-button { background: var(--surface-alt); color: var(--accent); border-color: var(--border); padding: 6px 12px; }

.icon-button, .icon-only {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

/* Sign-in screen */
.signin-screen { align-items: center; justify-content: center; }
.signin-card { text-align: center; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.signin-card h1 { margin: 0; }
.subcopy { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.drawer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--mobile-width);
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 18px 20px 28px;
  z-index: 11;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); }
.form-grid input, .form-grid select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}

.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Above phone width: still render as a centered "phone" card - this app is mobile-only by
   design, not a responsive desktop layout. */
@media (min-width: 560px) {
  #app { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border-radius: 24px; border: 1px solid var(--border); overflow: hidden; }
}
