/* Finance OS — Dark theme, clean, professional */
:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3348;
  --text: #e8eaf0;
  --text-muted: #7b82a0;
  --accent: #4f8ef7;
  --accent-hover: #6ba3ff;
  --green: #2ecc71;
  --red: #e74c3c;
  --yellow: #f39c12;
  --orange: #e67e22;
  --purple: #9b59b6;
  --teal: #1abc9c;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-logo h1 { font-size: 1.2rem; color: var(--accent); font-weight: 700; }
.sidebar-logo span { font-size: 0.75rem; color: var(--text-muted); }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 0.9rem;
  user-select: none;
}

.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(79,142,247,0.08); }
.nav-item .icon { font-size: 1.1rem; width: 1.2rem; text-align: center; }

.main-content {
  margin-left: 220px;
  padding: 2rem;
  flex: 1;
  max-width: 1400px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .value { font-size: 1.9rem; font-weight: 700; margin-top: 0.25rem; }
.stat-card .sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

.val-green { color: var(--green); }
.val-red { color: var(--red); }
.val-yellow { color: var(--yellow); }
.val-blue { color: var(--accent); }
.val-teal { color: var(--teal); }
.val-purple { color: var(--purple); }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 0.65rem 0.75rem;
  vertical-align: middle;
}

/* Section headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-header h2 { font-size: 1.3rem; font-weight: 600; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { filter: brightness(1.1); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label { font-size: 0.8rem; color: var(--text-muted); }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group select option { background: var(--bg3); }

/* Payoff comparison */
.payoff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .payoff-grid { grid-template-columns: 1fr; } }

.payoff-method {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.payoff-method h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.payoff-metric { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.payoff-metric:last-child { border-bottom: none; }
.payoff-metric .pm-label { color: var(--text-muted); }

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-debt { background: rgba(231,76,60,0.2); color: var(--red); }
.badge-asset { background: rgba(46,204,113,0.2); color: var(--green); }
.badge-warn { background: rgba(243,156,18,0.2); color: var(--yellow); }
.badge-info { background: rgba(79,142,247,0.15); color: var(--accent); }

/* Alert */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border-left: 3px solid;
}
.alert-warn { background: rgba(243,156,18,0.1); border-color: var(--yellow); color: var(--yellow); }
.alert-info { background: rgba(79,142,247,0.1); border-color: var(--accent); color: var(--accent); }
.alert-danger { background: rgba(231,76,60,0.1); border-color: var(--red); color: var(--red); }

/* Progress bar */
.progress { background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-bar.green { background: var(--green); }
.progress-bar.red { background: var(--red); }
.progress-bar.yellow { background: var(--yellow); }

/* Utils */
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.loading { color: var(--text-muted); font-style: italic; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%; max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h3 { font-size: 1.1rem; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 1.4rem; line-height: 1; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo span, .nav-item span { display: none; }
  .main-content { margin-left: 60px; padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Attention needed badge */
.attention-row { background: rgba(243,156,18,0.05) !important; }
.attention-row:hover { background: rgba(243,156,18,0.08) !important; }
