/* Municipal Budget Management System — Design System */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --navy:       #0A1628;
  --navy-mid:   #122040;
  --navy-light: #1A3060;
  --accent:     #C8A84B;
  --accent-lt:  #E8C96B;
  --teal:       #1B8B8B;
  --teal-lt:    #25BBBB;
  --crimson:    #B83232;
  --crimson-lt: #E04040;
  --sage:       #2E7D52;
  --amber:      #D48020;
  --surface:    #F4F2ED;
  --surface2:   #ECEAE3;
  --surface3:   #E2DFD6;
  --border:     #D0CBBE;
  --text-primary:   #1A1612;
  --text-secondary: #5C5448;
  --text-muted:     #8C8478;
  --white:      #FFFFFF;
  --shadow-sm:  0 1px 3px rgba(10,22,40,.10);
  --shadow-md:  0 4px 12px rgba(10,22,40,.14);
  --shadow-lg:  0 8px 30px rgba(10,22,40,.18);
  --radius:     6px;
  --radius-lg:  12px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-lt); text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .3s ease;
}
.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
  width: 42px; height: 42px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.brand-icon svg { width: 24px; height: 24px; color: var(--navy); }
.brand-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--white);
}
.brand-sub {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 2px;
}

.sidebar-section {
  padding: 16px 12px 4px;
}
.sidebar-section-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.3);
  padding: 0 10px;
  margin-bottom: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.72);
  font-size: .875rem;
  font-weight: 400;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: var(--white);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent);
  color: var(--navy);
  font-weight: 600;
}
.nav-item.active svg { color: var(--navy); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: rgba(255,255,255,.4);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600; color: white;
  flex-shrink: 0;
}
.user-info .user-name { font-size: .82rem; font-weight: 500; color: rgba(255,255,255,.85); }
.user-info .user-role { font-size: .7rem; color: rgba(255,255,255,.38); }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--navy);
}
.topbar-left p {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.fy-badge {
  background: var(--navy);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}

.page-body { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}
.card-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--navy);
}
.card-header .card-subtitle {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.card-body { padding: 20px; }

/* ── KPI Grid ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-card.accent::before  { background: var(--accent); }
.kpi-card.teal::before    { background: var(--teal); }
.kpi-card.crimson::before { background: var(--crimson); }
.kpi-card.sage::before    { background: var(--sage); }
.kpi-card.amber::before   { background: var(--amber); }
.kpi-card.navy::before    { background: var(--navy); }

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.kpi-icon.accent  { background: rgba(200,168,75,.12);  color: var(--accent); }
.kpi-icon.teal    { background: rgba(27,139,139,.12);  color: var(--teal); }
.kpi-icon.crimson { background: rgba(184,50,50,.1);    color: var(--crimson); }
.kpi-icon.sage    { background: rgba(46,125,82,.12);   color: var(--sage); }
.kpi-icon.amber   { background: rgba(212,128,32,.12);  color: var(--amber); }
.kpi-icon.navy    { background: rgba(10,22,40,.08);    color: var(--navy); }
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 1.65rem;
  color: var(--navy);
  line-height: 1;
}
.kpi-label {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--surface3);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
}
thead th {
  background: var(--navy);
  color: rgba(255,255,255,.85);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
tbody tr:hover { background: var(--surface); }
tbody td { padding: 11px 14px; vertical-align: middle; }
tfoot td {
  padding: 11px 14px;
  background: var(--surface2);
  font-weight: 600;
  font-size: .85rem;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.badge-draft      { background: #F0EDE4; color: #6E6050; }
.badge-submitted  { background: #FFF3DC; color: #996B00; }
.badge-approved   { background: #E0F4EC; color: #1A6B3C; }
.badge-paid       { background: #D4EEF4; color: #0A5870; }
.badge-cancelled  { background: #FDEAEA; color: #8B1A1A; }
.badge-ongoing    { background: #E8F0FF; color: #1A3A8B; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  font-family: var(--font-body);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--navy);    color: var(--white); }
.btn-primary:hover  { background: var(--navy-light); color: var(--white); }
.btn-accent    { background: var(--accent);  color: var(--navy); font-weight: 600; }
.btn-accent:hover  { background: var(--accent-lt); color: var(--navy); }
.btn-teal      { background: var(--teal);    color: var(--white); }
.btn-teal:hover    { background: var(--teal-lt); color: var(--white); }
.btn-sage      { background: var(--sage);    color: var(--white); }
.btn-danger    { background: var(--crimson); color: var(--white); }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-xs { padding: 3px 8px; font-size: .72rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
label .req { color: var(--crimson); margin-left: 2px; }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--text-primary);
  transition: border .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27,139,139,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #E0F4EC; color: #1A5C38; border: 1px solid #B0DEC6; }
.alert-error   { background: #FDEAEA; color: #7A1A1A; border: 1px solid #F0B0B0; }
.alert-warning { background: #FFF3DC; color: #7A4E00; border: 1px solid #F0D090; }
.alert-info    { background: #E0EEF8; color: #1A3A5C; border: 1px solid #A0C4E0; }

/* ── Progress ───────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--surface3);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--teal);
  transition: width .5s ease;
}
.progress-bar.danger { background: var(--crimson); }
.progress-bar.warning { background: var(--amber); }

/* ── Page Grid Layouts ──────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Utility ────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: .78rem; }
.text-mono  { font-family: var(--font-mono); }
.text-bold  { font-weight: 600; }
.text-accent  { color: var(--accent); }
.text-teal    { color: var(--teal); }
.text-crimson { color: var(--crimson); }
.text-sage    { color: var(--sage); }
.text-amber   { color: var(--amber); }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,22,40,.6);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all .2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-display); font-size: 1.05rem; color: var(--navy); }
.modal-close {
  width: 30px; height: 30px;
  border: none; background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--crimson); color: white; }
.modal-body { padding: 22px; }

/* ── Print Voucher ──────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-body { padding: 0; }
  .print-voucher {
    border: 2px solid #000;
    padding: 20px;
    font-family: Arial, sans-serif;
  }
}
.voucher-print-header {
  background: var(--navy);
  color: var(--white);
  padding: 16px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.voucher-print-header h2 { font-family: var(--font-display); color: var(--accent); }
.voucher-table { width: 100%; border-collapse: collapse; }
.voucher-table th, .voucher-table td { border: 1px solid var(--border); padding: 8px 12px; }
.voucher-table th { background: var(--surface); font-size: .78rem; text-transform: uppercase; color: var(--text-secondary); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}

/* ── Additional Utilities ────────────────────────────────────── */

/* Page header row with action button */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title    { font-family: var(--font-display); font-size: 1.5rem; color: var(--navy); margin: 0; }
.page-subtitle { font-size: .82rem; color: var(--text-muted); margin: 4px 0 0; }

/* Card title inside card-header */
.card-title { font-size: .95rem; font-weight: 700; color: var(--text); margin: 0; }

/* Table utilities */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table thead th {
  background: var(--bg-secondary);
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-secondary); }
.data-table tfoot td {
  padding: 10px 14px;
  border-top: 2px solid var(--border);
}

/* Filter row */
.filter-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.filter-row .form-group { margin-bottom: 0; min-width: 160px; }

/* Stats grid (for reports etc.) */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card  { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; color: var(--navy); font-weight: 700; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(200,168,75,.12) 0%, transparent 70%),
              radial-gradient(ellipse 40% 40% at 80% 80%, rgba(27,139,139,.1) 0%, transparent 60%);
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-mark {
  width: 56px; height: 56px;
  background: var(--navy);
  border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.login-logo .logo-mark svg { width: 30px; height: 30px; color: var(--accent); }
.login-logo h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--navy);
}
.login-logo p {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Form row (multi-column form layout) */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

/* Section divider inside modals */
.section-divider {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin: 16px 0 12px;
}

/* Spacing helpers */
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }

/* Text helpers */
.text-sm      { font-size: .8rem; }
.text-primary { color: var(--navy) !important; }
.text-danger  { color: var(--crimson) !important; }
.fw-600       { font-weight: 600; }

/* Button variants */
.btn-secondary       { background: var(--surface2); border: 1.5px solid var(--border); color: var(--text-primary); }
.btn-secondary:hover { border-color: var(--navy); color: var(--navy); }
.btn-ghost           { background: transparent; border: none; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover     { color: var(--navy); background: var(--surface2); }
.btn-danger-ghost       { background: transparent; border: none; color: var(--crimson); padding: 6px 10px; }
.btn-danger-ghost:hover { background: #fdeaea; }

/* Alert variants (add-on) */
.alert-danger { background: #FDEAEA; color: #7A1A1A; border: 1px solid #F0B0B0; }
