/* ============================================
   Personal Finance Dashboard — Style
   Color: Navy + Gold (matching MI-OS)
   ============================================ */

:root {
  --navy: #003A70;
  --navy-dark: #002347;
  --navy-light: #1a5a9e;
  --gold: #C5A258;
  --gold-light: #d4b97a;
  --bg: #F5F6FA;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6B7280;
  --red: #D32F2F;
  --green: #2E7D32;
  --orange: #EF6C00;
  --blue: #1565C0;
  --border: #E5E7EB;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- Navigation ---- */
nav {
  background: var(--navy);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

nav .logo {
  color: var(--gold);
  font-weight: 700;
  font-size: 18px;
  margin-right: 32px;
  white-space: nowrap;
}

nav .nav-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
}

nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
}

nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
nav a.active { background: rgba(197,162,88,0.2); color: var(--gold); font-weight: 600; }

.hamburger {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

/* ---- Main Layout ---- */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ---- KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--navy);
}

.kpi-card.gold { border-left-color: var(--gold); }
.kpi-card.green { border-left-color: var(--green); }
.kpi-card.red { border-left-color: var(--red); }
.kpi-card.blue { border-left-color: var(--blue); }

.kpi-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
}

.kpi-card .value.positive { color: var(--green); }
.kpi-card .value.negative { color: var(--red); }

.kpi-card .change {
  font-size: 13px;
  margin-top: 4px;
}

.kpi-card .change.up { color: var(--green); }
.kpi-card .change.down { color: var(--red); }

/* ---- Cards & Sections ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .badge {
  background: var(--gold);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 56px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: #f8f9ff; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.positive { color: var(--green); font-weight: 600; }
td.negative { color: var(--red); font-weight: 600; }

/* ---- Chart Container ---- */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-container.small { height: 200px; }

/* ---- Tags & Badges ---- */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tag-buy { background: #e8f5e9; color: var(--green); }
.tag-sell { background: #ffebee; color: var(--red); }
.tag-dividend { background: #fff3e0; color: var(--orange); }
.tag-interest { background: #e3f2fd; color: var(--blue); }
.tag-esot { background: #f3e5f5; color: #7B1FA2; }

/* ---- Progress Bar ---- */
.progress-bar {
  background: var(--bg);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease;
}

/* ---- Allocation Bar ---- */
.alloc-bar {
  display: flex;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  margin: 12px 0;
}

.alloc-bar .segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 30px;
  transition: width 0.5s;
}

/* ---- Tax Strategy Cards ---- */
.tax-tip {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.tax-tip .tip-title {
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 4px;
  font-size: 14px;
}

.tax-tip .tip-body {
  font-size: 13px;
  color: var(--text);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hamburger { display: block; }
  nav .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--navy-dark);
    flex-direction: column;
    padding: 12px;
  }
  nav .nav-links.open { display: flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  main { padding: 16px; }
  .kpi-card .value { font-size: 22px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ---- Utility ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--navy); }
.tab-btn.active {
  color: var(--navy);
  border-bottom-color: var(--gold);
  font-weight: 700;
}

/* ---- Toast/Alert ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-info { background: #e3f2fd; color: var(--blue); border: 1px solid #90caf9; }
.alert-warn { background: #fff3e0; color: var(--orange); border: 1px solid #ffcc80; }
.alert-success { background: #e8f5e9; color: var(--green); border: 1px solid #a5d6a7; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
