:root {
  --bg: #07090c;
  --bg-elev: rgba(0, 220, 255, 0.025);
  --bg-elev-2: rgba(0, 220, 255, 0.04);
  --bg-input: rgba(0, 220, 255, 0.03);
  --border: rgba(0, 220, 255, 0.12);
  --border-strong: rgba(0, 220, 255, 0.25);
  --border-active: #00dcff;
  --accent: #00dcff;
  --accent-soft: #6fdfff;
  --text: #d4f1f9;
  --text-muted: #7eb4c8;
  --text-dim: #5a8294;
  --text-bright: #f0fcff;
  --amber: #ffb74d;
  --amber-bright: #ffb300;
  --success: #00ff9d;
  --danger: #ff5470;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 30% 20%, rgba(0, 220, 255, 0.04), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 183, 77, 0.02), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#dashboard-root, #onboarding-root {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
  position: relative;
  z-index: 1;
}

.mono { font-family: var(--font-mono); }
.sans { font-family: var(--font-sans); }
.accent { color: var(--accent); }
.amber { color: var(--amber) !important; }
.success { color: var(--success) !important; }
.ok { color: var(--success); }

/* Boot screen */
.boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: var(--font-mono);
}
.boot-text { color: var(--accent); font-size: 13px; letter-spacing: 0.08em; }
.boot-line { opacity: 0; animation: bootIn 0.3s forwards; }
.boot-line[data-delay="200"] { animation-delay: 0.2s; }
.boot-line[data-delay="400"] { animation-delay: 0.4s; }
.boot-line[data-delay="650"] { animation-delay: 0.65s; }
.boot-line[data-delay="900"] { animation-delay: 0.9s; }
.boot-line.ok { color: var(--success); }
.boot-prompt { color: var(--text-dim); margin-right: 8px; }
.boot-dot { animation: blink 1s infinite; }
.boot-dot:nth-child(2) { animation-delay: 0.2s; }
.boot-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bootIn { to { opacity: 1; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* PIN gate */
.pin-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1.5rem;
}
.pin-box {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 1.75rem 1.5rem;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.pin-header { margin-bottom: 1rem; }
.pin-tag { font-size: 10px; letter-spacing: 0.14em; color: var(--accent); opacity: 0.7; }
.pin-box h2 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.16em;
  margin: 0 0 6px;
  color: var(--text-bright);
}
.pin-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 1.5rem; letter-spacing: 0.04em; }
.pin-box input {
  width: 100%;
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.5em;
  padding: 14px;
  margin-bottom: 1rem;
}
.pin-error {
  color: var(--danger);
  font-size: 11px;
  letter-spacing: 0.1em;
  margin: 0 0 1rem;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-meta { color: var(--text-dim); font-size: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-soft);
  font-weight: 500;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}
.dot.live { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Hero */
.hero {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 220, 255, 0.6), transparent);
  animation: scan 7s linear infinite;
  pointer-events: none;
}
@keyframes scan { 0% { transform: translateY(0); } 100% { transform: translateY(180px); } }
.hero-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 10px;
  opacity: 0.75;
}
.greeting {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-bright);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.greeting-sub {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font-mono);
  font-weight: 500;
  flex-shrink: 0;
  transition: color 0.2s;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:hover:not(.active) { color: var(--accent-soft); }

/* Panels */
.panel { display: none; }
.panel.active { display: block; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  position: relative;
  transition: border-color 0.2s;
}
.stat:hover { border-color: var(--border-strong); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--accent);
  margin: 0;
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 8px 0 0;
}
.live-dot {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s ease-in-out infinite;
}

/* Cycle strip */
.cycle {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.cycle-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.cycle-progress { color: var(--accent); }
.cycle-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.cycle-step {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.cycle-step.active {
  border-color: var(--accent);
  background: rgba(0, 220, 255, 0.08);
}
.cycle-step.done {
  border-color: rgba(0, 255, 157, 0.4);
  background: rgba(0, 255, 157, 0.04);
}
.cycle-num {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.cycle-step.active .cycle-num { color: var(--accent); }
.cycle-step.done .cycle-num { color: var(--success); }
.cycle-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.cycle-meta {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 12px;
}
.card-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 0;
  font-weight: 500;
}
.card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0;
}
.card-sub {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 14px;
  line-height: 1.5;
}

/* Rows */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: none; }
.row-check {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: transparent;
  transition: all 0.15s;
}
.row-check:hover { border-color: var(--accent); }
.row-check.done {
  background: rgba(0, 255, 157, 0.15);
  border-color: var(--success);
  color: var(--success);
}
.row-text {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}
.row-text.done {
  text-decoration: line-through;
  color: var(--text-dim);
}
.row-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
}
.row-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  font-family: var(--font-mono);
  line-height: 1;
}
.row-del:hover { color: var(--danger); }

/* Add row */
.add-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.add-row input { flex: 1; }

/* Form elements */
input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
  width: 100%;
  outline: none;
  letter-spacing: 0.04em;
  transition: border-color 0.15s;
}
input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.08em;
  font-size: 11px;
}
input:focus {
  border-color: var(--accent);
  background: rgba(0, 220, 255, 0.05);
}

button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover {
  background: rgba(0, 220, 255, 0.08);
  border-color: var(--accent);
}
button:active { transform: scale(0.98); }
button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { background: var(--accent-soft); }
button.ghost {
  color: var(--text-dim);
  border-color: var(--border);
  font-size: 10px;
  padding: 6px 12px;
}
button.ghost:hover { color: var(--accent); border-color: var(--border-strong); }
button.ghost.danger:hover { color: var(--danger); border-color: rgba(255, 84, 112, 0.4); }

/* Habit grid */
.habit-grid {
  display: grid;
  grid-template-columns: 1fr repeat(7, 32px);
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.h-head {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.1em;
}
.habit-row-label {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
}
.habit-streak {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-top: 2px;
}
.habit-cell {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: transparent;
  transition: all 0.15s;
}
.habit-cell:hover { border-color: var(--accent); }
.habit-cell.done {
  background: rgba(0, 255, 157, 0.15);
  border-color: var(--success);
  color: var(--success);
}
.habit-cell.today {
  box-shadow: 0 0 0 1px var(--accent);
}

/* Progress bars */
.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 220, 255, 0.08);
  border-radius: 0;
  overflow: hidden;
  margin: 6px 0;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}
.progress-fill.amber { background: var(--amber-bright); }
.progress-fill.success { background: var(--success); }

/* Debt cards */
.debt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  align-items: center;
}
.debt-row:last-child { border-bottom: none; }
.debt-name {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.debt-balance {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--amber);
}
.debt-balance .start {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
  letter-spacing: 0.04em;
}
.debt-bar-wrap { grid-column: 1 / -1; }
.debt-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.debt-actions input {
  flex: 1;
  font-size: 12px;
  padding: 7px 10px;
}
.debt-actions button {
  font-size: 10px;
  padding: 7px 12px;
}

/* Statusbar */
.statusbar {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

/* Onboarding */
.onb-shell {
  max-width: 560px;
  margin: 2rem auto 0;
  padding: 1rem;
}
.onb-frame {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}
.onb-frame::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 220, 255, 0.6), transparent);
  animation: scan 7s linear infinite;
}
.onb-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 12px;
}
.onb-title {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}
.onb-sub {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.6;
}
.onb-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 1.25rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.field .hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.onb-debt-field {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
  align-items: center;
}
.onb-debt-field label {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  letter-spacing: 0;
}
.onb-habit-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.onb-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
}
.onb-progress {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.onb-dot {
  width: 24px;
  height: 3px;
  border-radius: 0;
  background: var(--border);
}
.onb-dot.active { background: var(--accent); }
.onb-dot.done { background: var(--success); }
.onb-buttons { display: flex; gap: 8px; flex-shrink: 0; }

/* Mobile */
@media (max-width: 540px) {
  #dashboard-root, #onboarding-root { padding: 0.75rem 0.75rem 5rem; }
  .hero { padding: 1rem 1.1rem; }
  .greeting { font-size: 18px; }
  .stat-value { font-size: 22px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid .stat:first-child { grid-column: 1 / -1; }
  .cycle-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .cycle-step { padding: 6px 4px; }
  .cycle-name { font-size: 11px; }
  .topbar { font-size: 10px; }
  .topbar-meta { display: none; }
  .card { padding: 1rem; }
  .onb-debt-field { grid-template-columns: 1fr 110px; }
  .onb-nav { flex-direction: column-reverse; align-items: stretch; gap: 12px; }
  .onb-buttons { justify-content: flex-end; }
  .habit-grid { grid-template-columns: 1fr repeat(7, 28px); font-size: 11px; }
  .habit-cell { width: 26px; height: 26px; }
  .statusbar { font-size: 9px; }
}
