/* ═══════════════════════════════════════════════════════════════
   AC27 Budget Dashboard — Bold Navy & Red
   Deep blues, classic reds, clean whites
   ═══════════════════════════════════════════════════════════════ */

:root {
  --sage-900: #0a1628;
  --sage-800: #12243d;
  --sage-700: #1a3352;
  --sage-600: #1e3a5f;
  --sage-500: #2a5a8f;
  --sage-400: #3d7abf;
  --sage-300: #6a9fd4;
  --sage-200: #a3c4e6;
  --sage-100: #dce8f5;
  --sage-50:  #eef3fa;

  --warm-900: #2a2a35;
  --warm-800: #3d3d4a;
  --warm-700: #5a5a68;
  --warm-600: #7a7a88;
  --warm-500: #9a9aa8;
  --warm-400: #b8b8c4;
  --warm-300: #d4d4dc;
  --warm-200: #e8e8ee;
  --warm-100: #f2f2f6;
  --warm-50:  #f8f8fb;

  --text: #1a1a2e;
  --text-secondary: #5a5a6e;
  --text-muted: #8888a0;
  --border: #d8d8e4;
  --bg: #f8f8fb;
  --card: #ffffff;
  --danger: #c41e2a;
  --danger-light: #fdedef;
  --warning: #d4a017;
  --warning-light: #fdf8e8;

  --sidebar-w: 220px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sage-900);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 24px;
}

.brand-icon {
  font-size: 24px;
  line-height: 1;
}

.brand-text {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

.nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.nav-link svg { opacity: 0.7; flex-shrink: 0; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link-small { font-size: 13px; padding: 8px 12px; }

.user-badge {
  padding: 8px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
}

.logout-link { color: rgba(255,255,255,0.35) !important; }
.logout-link:hover { color: rgba(255,255,255,0.7) !important; }

/* ── Main content ───────────────────────────────────────────── */

main {
  min-height: 100vh;
  padding: 32px 40px 60px;
}

main.has-sidebar {
  margin-left: var(--sidebar-w);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.page-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--sage-900);
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.sync-badge {
  display: inline-block;
  background: var(--sage-100);
  color: var(--sage-700);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  margin-left: 8px;
  font-weight: 500;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--sage-900);
  margin-bottom: 20px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header-row .card-title { margin-bottom: 0; }

/* ── Stat cards ─────────────────────────────────────────────── */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card-primary { border-left: 4px solid var(--sage-600); }
.stat-card-spent { border-left: 4px solid var(--warm-500); }
.stat-card-remaining { border-left: 4px solid var(--sage-400); }
.stat-card-danger { border-left: 4px solid var(--danger); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--sage-900);
  line-height: 1.2;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Grid layouts ───────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  main.has-sidebar { margin-left: 0; padding: 20px; }
  .sidebar { display: none; }
}

/* ── Charts ─────────────────────────────────────────────────── */

.chart-container { position: relative; height: 300px; }
.chart-container-wide { height: 400px; }
.empty-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.empty-chart a { color: var(--sage-600); }

/* ── Budget bars ────────────────────────────────────────────── */

.budget-bars { display: flex; flex-direction: column; gap: 14px; }

.budget-bar-row {
  display: grid;
  grid-template-columns: 260px 1fr 50px;
  align-items: center;
  gap: 16px;
}

.budget-bar-label { display: flex; justify-content: space-between; }
.budget-cat-name { font-weight: 500; font-size: 14px; }
.budget-amounts { font-size: 12px; color: var(--text-muted); font-family: 'DM Sans', monospace; }

.budget-bar-track {
  height: 10px;
  background: var(--warm-100);
  border-radius: 5px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: var(--sage-500);
  border-radius: 5px;
  transition: width 0.6s ease;
}

.budget-bar-fill.bar-warning { background: var(--warning); }
.budget-bar-fill.bar-danger { background: var(--danger); }

.budget-pct { font-size: 12px; color: var(--text-muted); text-align: right; font-weight: 500; }

/* ── Table ──────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--warm-100);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--warm-50); }

.text-right { text-align: right; }
.text-mono { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--sage-100);
  color: var(--sage-800);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.receipt-link {
  color: var(--sage-600);
  text-decoration: none;
  font-size: 12px;
}
.receipt-link:hover { text-decoration: underline; }

/* ── Status badges ──────────────────────────────────────────── */

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-ok { background: var(--sage-100); color: var(--sage-800); }
.status-warning { background: var(--warning-light); color: #8a6d00; }
.status-danger { background: var(--danger-light); color: var(--danger); }
.status-none { background: var(--warm-100); color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.btn-primary {
  background: var(--sage-700);
  color: #fff;
}

.btn-primary:hover { background: var(--sage-800); }

.btn-ghost {
  background: transparent;
  color: var(--sage-700);
  padding: 8px 14px;
}

.btn-ghost:hover { background: var(--sage-50); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn-danger-text { color: var(--danger) !important; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ──────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--warm-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--sage-500);
  box-shadow: 0 0 0 3px var(--sage-100);
  background: #fff;
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group-grow { grid-column: span 1; }

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.input-prefix-wrap {
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 15px;
}

.form-input-prefixed { padding-left: 32px; }

/* ── Upload workflow ────────────────────────────────────────── */

.workflow-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
  padding: 0 60px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.4s ease;
  background: var(--card);
}

.step-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.step.active .step-num {
  border-color: var(--sage-500);
  color: var(--sage-700);
  background: var(--sage-50);
}

.step.done .step-num {
  border-color: var(--sage-600);
  background: var(--sage-600);
  color: #fff;
}

.step.active .step-label { color: var(--text); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  margin-bottom: 22px;
}

.upload-form { max-width: 720px; margin: 0 auto; }

.upload-section { position: relative; }

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.section-number {
  width: 32px; height: 32px;
  background: var(--sage-100);
  color: var(--sage-700);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.section-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--sage-900);
}

.section-header p { margin-top: 2px; font-size: 13px; }

/* ── Dropzone ───────────────────────────────────────────────── */

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--warm-50);
}

.dropzone:hover {
  border-color: var(--sage-400);
  background: var(--sage-50);
}

.dropzone.dragover {
  border-color: var(--sage-500);
  background: var(--sage-100);
  transform: scale(1.01);
}

.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon { color: var(--sage-400); margin-bottom: 12px; }

.dropzone-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.dropzone-subtext {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dropzone-browse {
  color: var(--sage-600);
  font-weight: 600;
  text-decoration: underline;
}

.dropzone-preview {
  display: flex;
  justify-content: center;
}

.preview-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
}

.preview-file svg { color: var(--sage-600); }

.file-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.file-remove:hover { color: var(--danger); }

.upload-submit {
  text-align: center;
  padding: 20px 0;
}

.upload-submit p { margin-top: 12px; }

/* ── User management ────────────────────────────────────────── */

.user-list { display: flex; flex-direction: column; gap: 8px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--warm-50);
}

.user-row:hover { background: var(--warm-100); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sage-200);
  color: var(--sage-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 14px; }
.user-meta { font-size: 12px; color: var(--text-muted); }

.user-spend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.user-spend-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--warm-50);
  border-radius: var(--radius-sm);
}

.user-amount { font-size: 18px; font-weight: 700; font-family: 'Fraunces', serif; color: var(--sage-800); }

/* ── Login screen ───────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--sage-900);
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(74,124,89,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(168,198,143,0.1) 0%, transparent 50%);
}

.login-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  padding: 0 24px;
  animation: fadeUp 0.6s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-brand { text-align: center; margin-bottom: 36px; }

.login-icon {
  font-size: 42px;
  margin-bottom: 16px;
  display: block;
}

.login-brand h1 {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.login-brand p {
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  margin-top: 4px;
}

.login-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 36px 32px;
  backdrop-filter: blur(20px);
}

.login-card .form-group label { color: rgba(255,255,255,0.5); }

.login-card .form-input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: #fff;
}

.login-card .form-input:focus {
  border-color: var(--sage-400);
  box-shadow: 0 0 0 3px rgba(123,160,91,0.2);
  background: rgba(255,255,255,0.1);
}

.login-card .form-input::placeholder { color: rgba(255,255,255,0.3); }

.login-card .btn-primary {
  margin-top: 8px;
  padding: 13px;
  background: var(--sage-600);
}

.login-card .btn-primary:hover { background: var(--sage-500); }

.login-footer-text {
  text-align: center;
  color: rgba(255,255,255,0.25);
  font-size: 12px;
  margin-top: 24px;
}

/* ── Flash messages ─────────────────────────────────────────── */

.flash-container { margin-bottom: 20px; }

.flash {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 8px;
  transition: opacity 0.4s ease;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success { background: var(--sage-100); color: var(--sage-800); border: 1px solid var(--sage-200); }
.flash-error { background: var(--danger-light); color: var(--danger); border: 1px solid #f0d0cd; }
.flash-warning { background: var(--warning-light); color: #8a6d00; border: 1px solid #efe0b0; }
.flash-info { background: var(--warm-100); color: var(--warm-700); border: 1px solid var(--warm-300); }

.flash-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  padding: 0 4px;
}

.flash-close:hover { opacity: 1; }

/* ── Empty state ────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }

.empty-state h3 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--sage-900);
}

.empty-state p { color: var(--text-secondary); font-size: 14px; line-height: 1.7; }
.empty-state code { background: var(--warm-100); padding: 2px 8px; border-radius: 4px; font-size: 13px; }

/* ── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--sage-900);
}

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.modal-txn-summary {
  background: var(--warm-50);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
}

/* ── Reconciliation table ──────────────────────────────────── */

.txn-reconciled { opacity: 0.5; }
.txn-reconciled:hover { opacity: 0.8; }

.text-credit { color: var(--sage-700); }

.tag-personal {
  background: var(--warm-200);
  color: var(--warm-700);
}

/* ── Suggestion banner ─────────────────────────────────────── */

.suggestion-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sage-50);
  border: 1px solid var(--sage-200);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 16px;
}

.suggestion-icon { font-size: 20px; flex-shrink: 0; }

.suggestion-content { flex: 1; }

.suggestion-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sage-700);
  margin-bottom: 2px;
}

.suggestion-text { font-size: 13px; color: var(--text); }

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .budget-bar-row { grid-template-columns: 1fr; gap: 6px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .workflow-steps { padding: 0; }
  .step-label { font-size: 10px; }
  .modal-card { max-width: 100%; }
}
