/* ===== Base ===== */
:root {
  --left-w: 240px;
  --left-w-collapsed: 56px;
  --right-w: 260px;
  --right-w-collapsed: 0px;
  --card-bg: #333;
  --text: #f0f0f0;
  --accent: #ffb347;   /* yellow/orange accent */
  --blue-accent: #76a8ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, #232526 0%, #414345 100%);
  color: var(--text);
}

/* ===== Sidebars ===== */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--left-w);
  background: #232526;
  color: #fff;
  padding: 1rem;
  overflow-y: auto;
  border-right: 2px solid #444;
  z-index: 900;
}
.sidebar.right {
  right: 0;
  left: auto;
  width: var(--right-w);
  border-right: none;
  border-left: 2px solid #444;
}
#left-sidebar.collapsed  { width: var(--left-w-collapsed); }
#right-sidebar.collapsed { width: var(--right-w-collapsed); }

.sidebar h3, .sidebar h4 { color: var(--accent); margin: 0 0 .5rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: .35rem 0; }
.sidebar a {
  color: #fff; text-decoration: none;
  display: block; padding: 6px 10px; border-radius: 6px;
}
.sidebar a:hover { background: var(--accent); color: #232526; }

/* Toggle buttons */
.sidebar-toggle {
  position: fixed; top: 10px;
  z-index: 1000;
  background: #101522; color: #ffd769;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; padding: 6px 10px;
  cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.sidebar-toggle.left { left: 80px; }
.sidebar-toggle.right { right: 10px; }

/* ===== Dashboard grid (exactly 2 columns) ===== */
.dashboard {
  margin-left: var(--left-w);
  margin-right: var(--right-w);
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
body.left-collapsed  .dashboard { margin-left:  var(--left-w-collapsed); }
body.right-collapsed .dashboard { margin-right: var(--right-w-collapsed); }

/* Mobile: 1 column, hide sidebars */
@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; margin: 0; padding: 1rem; }
  #left-sidebar, #right-sidebar { width: 0; }
}

/* ===== Widgets ===== */
.widget {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  padding: 1rem;
  transition: box-shadow .2s, transform .2s;
}
.widget:hover { box-shadow: 0 4px 16px #ffb34799; transform: translateY(-2px) scale(1.01); }
h4 { color: var(--accent); margin: 0 0 .6rem; }

/* Tables inside widgets */
.widget table {
  width: 100%; border-collapse: collapse; background: #232526; color: #fff;
}
.widget th, .widget td { border: 1px solid #444; padding: 8px; text-align: center; }
.widget th { background: var(--accent); color: #232526; font-weight: 700; }
.widget tr:nth-child(even) { background: #2c2c2c; }
.widget tr:hover { background: #444; }

/* Special headers/cards */
#retirement-widget, #surplus-widget{
  background: #013A63; color: #FFD700; text-align: center;
}
#retirement-widget h4, #surplus-widget h4, #bank_savings-widget h4 { color: #FFD700; }

/* ===== Calendar ===== */
#cal-widget { box-shadow: 0 4px 16px #ffb34799; border-radius: 12px; }
.calendar-widget iframe {
  width: 100%; height: 600px; border: 0; border-radius: 8px;
  filter: invert(1) hue-rotate(180deg);
}

/* ===== Mileage widget ===== */
.widget.widget-mileage {
  background: #0b1020; color: #e8f0ff;
  border: 1px solid rgba(255,255,255,.08); border-radius: 14px;
  padding: 16px; box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.widget-mileage .widget-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 12px;
}
.widget-mileage .widget-title { font-weight: 700; font-size: 1.1rem; color: var(--blue-accent); }
.widget-mileage .widget-subtitle { font-size: .9rem; color: #ffe880; }
.widget-mileage .widget-body { display: grid; gap: 16px; }

.mileage-stats {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px;
}
.stat-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 12px; }
.stat-label { font-size: .85rem; opacity: .85; margin-bottom: 6px; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: #e8f0ff; }
.stat-sub { font-size: .9rem; margin-top: 4px; color: #cde0ff; }

.progress-bar { height: 10px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin-top: 8px; border: 1px solid rgba(255,255,255,.08); }
.progress-bar .bar { height: 100%; width: 0%; transition: width 300ms ease; background: linear-gradient(90deg, #6ea8ff, #ffe26a); }
.progress-bar .bar.under { box-shadow: inset 0 0 0 100vmax rgba(60,210,120,.25); }
.progress-bar .bar.over  { box-shadow: inset 0 0 0 100vmax rgba(230,80,80,.25); }

.mileage-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; align-items: end;
}
.mileage-form .form-row { display: flex; flex-direction: column; gap: 6px; }
.mileage-form label { font-size: .85rem; color: #cde0ff; }
.mileage-form input[type="date"], .mileage-form input[type="number"] {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: #e8f0ff; border-radius: 10px; padding: 8px 10px; outline: none;
}
.mileage-form input::placeholder { color: rgba(255,255,255,.5); }
.btn-primary {
  background: linear-gradient(90deg, #6ea8ff, #ffe26a); border: none; color: #0b1020;
  font-weight: 800; padding: 10px 14px; border-radius: 999px; cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.03); }
.mw-submit { grid-column: 1 / -1; justify-self: end; }
.status { grid-column: 1 / 2; align-self: center; color: #ffe26a; }
.good { color: #46d28a; } .bad { color: #ff7a7a; }

@media (max-width: 700px) {
  .mileage-form { grid-template-columns: 1fr; }
  .mw-submit { grid-column: 1; justify-self: stretch; text-align: center; }
  .status { grid-column: 1; margin-top: 6px; }
}

/* ===== Global indices widget ===== */
/* Market Widget Table */
.market-widget table {
  width: 100%;
  border-collapse: collapse;
}

.market-widget th,
.market-widget td {
  padding: 6px 10px;
}

.market-widget th {
  background: var(--accent-bg, #f4a742); /* or your theme accent */
  color: #000;
  text-align: left;
}

.market-widget th.num,
.market-widget td.num {
  text-align: right; /* line up prices and changes */
}

.market-widget th.trend,
.market-widget td.trend-cell {
  text-align: center;
  width: 110px;
}

/* Direction colours */
.market-widget td.up    { color: #4caf50; font-weight: 600; }
.market-widget td.down  { color: #f44336; font-weight: 600; }
.market-widget td.neutral { color: #999; }

/* Sparkline styling */
.market-widget .trend-cell svg {
  display: inline-block;
}
.market-widget .spark-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.market-widget .spark-area {
  fill: currentColor;
  opacity: 0.12; /* soft background fill */
  stroke: none;
}
 .status-pill{
  display:inline-flex; align-items:center; gap:8px;
  background:#1b2437; color:#e2e8f0;
  border:1px solid rgba(148,163,184,.25);
  border-radius:999px; padding:6px 10px;
  font-weight:600; font-size:.85rem; cursor:pointer; user-select:none;
}
.status-pill .dot{ width:10px; height:10px; border-radius:50%; background:#64748b; }
.status-pill.minor  { border-color:#f59e0b66; }
.status-pill.major  { border-color:#f9731666; }
.status-pill.critical { border-color:#ef444466; }
.status-pill.none   { border-color:#22c55e66; }
.status-pill.none .dot{ background:#22c55e; }
.status-pill.minor .dot{ background:#f59e0b; }
.status-pill.major .dot{ background:#f97316; }
.status-pill.critical .dot{ background:#ef4444; }

.ins-widget .ins-table { width:100%; border-collapse: collapse; }
.ins-widget .ins-table th, .ins-widget .ins-table td { padding:.6rem .75rem; border-bottom:1px solid rgba(255,255,255,.08); }
.ins-widget .ins-table thead th { opacity:.9; font-weight:600; }
.ins-widget .ins-upload { margin-top: .8rem; display:flex; gap:.5rem; flex-wrap:wrap; }
.ins-widget select, .ins-widget input[type="number"], .ins-widget input[type="file"], .ins-widget button {
  background: #24364D; color:#fff; border:1px solid #1b2a3f; border-radius:.5rem; padding:.45rem .6rem;
}
.ins-widget button { cursor:pointer; }
.ins-widget .ins-table td:nth-child(2) { font-variant-numeric: tabular-nums; }