/* Pension Tracker - styles */
:root {
  --bg: #0f1720;
  --panel: #1a2532;
  --panel-2: #22303f;
  --border: #2c3d4f;
  --text: #e8eef4;
  --muted: #93a4b5;
  --primary: #2f6feb;
  --primary-hover: #4880f5;
  --gain: #2ec26b;
  --loss: #f2585b;
  --danger: #d9433f;
  --danger-hover: #e85a56;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2 { font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.centre { text-align: center; }

/* Screens */
.screen { min-height: 100vh; }
#login-screen, #loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { margin: 8px 0 24px; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  color: var(--text);
  background: var(--panel-2);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); padding: 5px 10px; font-size: 0.85rem; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-link { background: transparent; border-color: var(--border); padding: 5px 10px; font-size: 0.85rem; }

/* Header */
.app-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.app-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 { font-size: 1.25rem; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 0.9rem; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel h2 { font-size: 1.05rem; margin-bottom: 16px; }
.panel-head h2 { margin-bottom: 0; }

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.summary-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.summary-label { color: var(--muted); font-size: 0.85rem; }
.summary-figure { font-size: 1.5rem; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: var(--panel-2); }
.num { text-align: right; }
td.num { font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }

.gain { color: var(--gain); }
.loss { color: var(--loss); }

/* Chart */
.chart-wrap { width: 100%; margin-bottom: 16px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.chart-area { fill: rgba(47,111,235,0.12); stroke: none; }
.chart-dot { fill: var(--primary); }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; }

/* Error */
.error {
  background: rgba(242,88,91,0.12);
  border: 1px solid var(--loss);
  color: var(--loss);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 18px; }
.modal-form .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.modal-form label { font-size: 0.85rem; color: var(--muted); }
.modal-form input, .modal-form select {
  font: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
}
.modal-form input:focus, .modal-form select:focus { outline: 2px solid var(--primary); outline-offset: 0; }
.modal-form input:disabled { opacity: 0.6; cursor: not-allowed; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Responsive */
@media (max-width: 720px) {
  .summary-cards { grid-template-columns: 1fr; }
  .summary-figure { font-size: 1.3rem; }
  .app-header h1 { font-size: 1.1rem; }
  .user-email { display: none; }
  .container { padding: 14px; }
  .panel { padding: 16px; }
}

/* Chart view toggle (All / Monthly / Yearly) */
.chart-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.btn-toggle {
  padding: 4px 12px;
  border: 1px solid var(--border, #ccc);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-toggle.active {
  background: var(--accent, #1f6feb);
  color: #fff;
  border-color: var(--accent, #1f6feb);
}
