:root {
  color-scheme: dark;
  --bg: #000000;
  --card-bg: #0a0a0c;
  --border: rgba(255, 255, 255, 0.12);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --accent-bg: #ffffff;
  --accent-text: #000000;
  --error-bg: #450a0a;
  --error-text: #fca5a5;
  --info-bg: #052e16;
  --info-text: #86efac;
  --radius: 16px;
  --radius-sm: 10px;
  --list-bg: #131316;
  --progress-fill: #fafafa;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

.screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  width: 100%;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.card--center {
  text-align: center;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

form {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #d4d4d8;
}

input,
select {
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #18181b;
  color: var(--text);
  padding: 0 12px;
  font-size: 1rem;
  outline: none;
  width: 100%;
}

input:focus,
select:focus {
  border-color: #fafafa;
}

button {
  height: 48px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary {
  margin-top: 8px;
  background: var(--accent-bg);
  color: var(--accent-text);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-secondary {
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: #d4d4d8;
  width: 100%;
  box-sizing: border-box;
}

.link-btn {
  margin-top: 16px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.message {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.875rem;
}

.message--error {
  background: var(--error-bg);
  color: var(--error-text);
}

.message--info {
  background: var(--info-bg);
  color: var(--info-text);
}

[hidden] {
  display: none !important;
}

.kv {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.kv-faint {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.actions {
  margin-top: 24px;
}

.nav-links {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
}

.list {
  list-style: none;
  margin: 20px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--list-bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.list-item-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.list-item-value {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.list-item-value--negative {
  color: #f87171;
}

.list-item-value--positive {
  color: #4ade80;
}

.list-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: fit-content;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 24px 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.form-actions button {
  flex: 1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 400;
  color: #d4d4d8;
}

.checkbox-label input {
  height: auto;
  width: auto;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.budget-item-input {
  width: 110px;
  height: 40px;
  flex: none;
}

.progress-track {
  margin-top: 6px;
  height: 6px;
  border-radius: 999px;
  background: #26262b;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 999px;
}

.list-item-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #131316;
}

.list-item-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.list-item-actions button {
  height: 40px;
  font-size: 0.875rem;
}

.inline-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* =========================================================================
   Night Gauge — dashboard/home only. Scoped to body.dash so every other
   screen keeps the original palette untouched; component classes above
   (.card, .list-item, .badge, .progress-*) are reused as-is and simply
   inherit these overridden custom properties.
   ========================================================================= */

body.dash {
  --bg: #12141b;
  --card-bg: #1c1f29;
  --list-bg: #21242f;
  --border: rgba(237, 234, 226, 0.1);
  --text: #edeae2;
  --text-muted: #a9a6a0;
  --text-faint: #726f68;
  --progress-fill: var(--accent-brass);
  --accent-brass: #c9a24b;
  --accent-sage: #6fa287;
  --accent-clay: #c76a5d;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  align-items: flex-start;
}

.dash-screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  width: 100%;
}

@media (min-width: 720px) {
  .dash-screen {
    max-width: 760px;
    padding: 40px 24px 56px;
  }
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dash-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dash-greeting {
  margin: 2px 0 0;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
}

.dash-icon-btn {
  height: 36px;
  width: auto;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
}

.gauge-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 20px 22px;
  text-align: center;
  margin-bottom: 16px;
}

.gauge-wrap {
  position: relative;
  max-width: 320px;
  margin: 0 auto;
}

.gauge-svg {
  width: 100%;
  height: auto;
  display: block;
}

.gauge-track {
  fill: none;
  stroke: rgba(237, 234, 226, 0.08);
  stroke-width: 16;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent-sage);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

@media (prefers-reduced-motion: no-preference) {
  .gauge-fill {
    transition:
      stroke-dashoffset 900ms cubic-bezier(0.16, 1, 0.3, 1),
      stroke 300ms ease;
  }
}

.gauge-fill--zero {
  stroke: var(--accent-clay);
}

.gauge-fill--unset {
  stroke: var(--text-faint);
}

.gauge-center {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-value {
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-size: 2.75rem;
  line-height: 1;
  color: var(--text);
}

.gauge-label {
  margin-top: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gauge-status {
  margin: 12px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-value {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.5rem;
  color: var(--text);
}

.stat-value--negative {
  color: var(--accent-clay);
}

.dash-sections-grid {
  display: flex;
  flex-direction: column;
}

@media (min-width: 720px) {
  .dash-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 20px;
  }
}

.dash-section {
  margin-bottom: 22px;
}

.dash-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dash-section-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.dash-section-link {
  font-size: 0.8125rem;
  color: var(--accent-brass);
  text-decoration: none;
}

.dash-section .list {
  margin: 0;
}

.dash-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}

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

.dash-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 44px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.2;
}
