:root {
  --bg: #0b0f17;
  --bg-elevated: #111827;
  --bg-card: #151e2e;
  --bg-input: #0f1624;
  --border: #243044;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #10b981;
  --primary-hover: #059669;
  --secondary: #1e293b;
  --secondary-hover: #293548;
  --positive: #34d399;
  --negative: #f87171;
  --warning: #fbbf24;
  --silas: #38bdf8;
  --isabella: #c084fc;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --radius: 14px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #059669;
  --primary-hover: #047857;
  --secondary: #e2e8f0;
  --secondary-hover: #cbd5e1;
  --positive: #059669;
  --negative: #dc2626;
  --warning: #d97706;
  --silas: #0284c7;
  --isabella: #9333ea;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Banner */
.banner {
  background: rgba(251, 191, 36, 0.14);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  padding: 10px 16px;
}
.banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}
.banner-actions { display: flex; gap: 8px; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}
.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.sync-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--positive);
  box-shadow: 0 0 8px var(--positive);
}
.sync-badge.offline .dot {
  background: var(--negative);
  box-shadow: none;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  color: var(--text);
  background: var(--secondary);
}
.btn:hover { background: var(--secondary-hover); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--secondary);
  border-color: var(--border);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--secondary);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--negative);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.icon-btn { padding: 8px 10px; min-width: 36px; }

/* Main Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-card);
  padding: 5px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.view-tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px;
}
.month-pill {
  background: transparent;
  border: 0;
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 5px 10px;
  cursor: pointer;
  min-width: 84px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.card-header p { margin: 2px 0 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--text);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card { display: flex; flex-direction: column; gap: 6px; }
.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}
.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.kpi-sub { font-size: 0.8rem; color: var(--text-muted); }

/* Couple Panel */
.couple-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.couple-card { border-color: rgba(56, 189, 248, 0.35); }
.proportion-bar {
  height: 14px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  margin: 8px 0 12px;
  border: 1px solid var(--border);
}
.prop-silas { background: var(--silas); transition: width 0.25s ease; }
.prop-isabella { background: var(--isabella); transition: width 0.25s ease; }
.couple-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  font-weight: 600;
}
.legend-item { display: flex; align-items: center; gap: 7px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-silas { background: var(--silas); }
.swatch-isabella { background: var(--isabella); }
.splits-body { font-size: 0.9rem; }
.settlement-highlight {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

/* Analytics & Budgets */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.donut-layout {
  display: flex;
  align-items: center;
  gap: 18px;
}
.donut-wrap {
  flex: 0 0 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bars-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
}
.bar-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.budgets-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.budget-ok { background: var(--positive); }
.budget-warn { background: var(--warning); }
.budget-over { background: var(--negative); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* Transactions Section */
.tx-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.tx-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tx-title-group h2 { margin: 0; font-size: 1rem; }
.tx-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}
.tx-filters input, .tx-filters select {
  width: auto;
  min-width: 135px;
  max-width: 220px;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}
.tx-item:hover { border-color: var(--primary); }
.tx-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tx-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.tx-desc {
  font-weight: 600;
  font-size: 0.94rem;
}
.tx-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.pill {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 600;
}
.tx-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.tx-amount {
  font-weight: 800;
  font-size: 0.98rem;
  text-align: right;
  white-space: nowrap;
}

/* Forms & Inputs */
input, select {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 8px 0 14px;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 0.88rem;
}
.checkbox-label input { width: auto; }
.form-error {
  color: var(--negative);
  font-size: 0.84rem;
  margin: 6px 0 10px;
}

/* Modals & Lock Overlay */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.modal-lg { max-width: 680px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-header h3 { margin: 0; font-size: 1.08rem; }
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.footer-right { display: flex; gap: 8px; margin-left: auto; }
.inline-confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.entity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.entity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lock-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.lock-icon { font-size: 2.4rem; margin-bottom: 8px; }
.lock-card h1 { margin: 0 0 8px; font-size: 1.25rem; }
.lock-card input {
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0.3em;
  margin: 14px 0 12px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}
.toast.error { border-left-color: var(--negative); }

/* Responsive */
@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .couple-grid, .analytics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 1.22rem; }
  .donut-layout { flex-direction: column; align-items: stretch; }
  .donut-wrap { flex: none; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .tx-filters { justify-content: stretch; }
  .tx-filters input, .tx-filters select { max-width: none; flex: 1 1 46%; }
  .tx-item { flex-direction: column; align-items: stretch; }
  .tx-right { justify-content: space-between; }
}
