/* ============================================================
   PERPI FUEL Pro — Government Budget Tracker Stylesheet
   ============================================================ */

:root {
  --navy:      #0a2540;
  --navy-mid:  #0d3060;
  --blue:      #1a56db;
  --blue-lt:   #e8f0fe;
  --cyan:      #17a2b8;
  --green:     #28a745;
  --amber:     #ffc107;
  --red:       #dc3545;
  --orange:    #fd7e14;
  --purple:    #6f42c1;
  --gray-100:  #f8f9fa;
  --gray-200:  #e9ecef;
  --gray-300:  #dee2e6;
  --gray-500:  #adb5bd;
  --gray-700:  #495057;
  --gray-900:  #212529;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius:    8px;
  --shadow:    0 1px 4px rgba(0,0,0,.10);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
}

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

/* ── Segoe UI everywhere (form elements don't inherit by default) */
html {
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
}

body {
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.5;
}

input, select, textarea, button, optgroup, option {
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
}

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

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left .25s;
}

.main-content {
  padding: 24px;
  flex: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  transition: transform .25s;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #fff;
}

.brand-name em {
  font-style: normal;
  color: var(--amber);
}

.brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(255,255,255,.4);
  padding: 14px 14px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 6px;
  font-size: 13px;
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.nav-item.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon i {
  font-size: 16px;
  line-height: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.35);
  font-size: 10px;
  line-height: 1.8;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 4px 6px;
  border-radius: 4px;
}

.sidebar-toggle:hover { background: var(--gray-100); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Notifications ───────────────────────────────────────────── */
.notif-wrapper { position: relative; }

.notif-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--gray-100);
  border-radius: 50%;
  text-decoration: none;
  font-size: 16px;
  position: relative;
  transition: background .15s;
}

.notif-btn:hover { background: var(--blue-lt); }

.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ── User menu ───────────────────────────────────────────────── */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}

.logout-btn {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}

.logout-btn:hover { color: var(--red); background: #fff0f0; }

/* ── Role chips ──────────────────────────────────────────────── */
.role-chip {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  color: #fff;
  letter-spacing: .3px;
}

.role-personnel   { background: var(--gray-700); }
.role-budget      { background: var(--green); }
.role-procurement { background: var(--purple); }
.role-admin       { background: var(--blue); }
.role-superadmin  { background: var(--navy); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-100);
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .2px;
}

.card-body { padding: 16px 18px; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent, var(--blue));
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}

.stat-card.green  { --accent: var(--green); }
.stat-card.blue   { --accent: var(--blue); }
.stat-card.amber  { --accent: var(--amber); }
.stat-card.red    { --accent: var(--red); }
.stat-card.cyan   { --accent: var(--cyan); }
.stat-card.purple { --accent: var(--purple); }
.stat-card.navy   { --accent: var(--navy); }

/* ── Progress bar ────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--blue);
  transition: width .5s ease;
}

.progress-bar-fill.green  { background: var(--green); }
.progress-bar-fill.amber  { background: var(--amber); }
.progress-bar-fill.red    { background: var(--red); }
.progress-bar-fill.cyan   { background: var(--cyan); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
  background: var(--navy);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--gray-200); }
tbody tr:hover { background: var(--blue-lt); }

td {
  padding: 9px 12px;
  color: var(--gray-700);
  vertical-align: middle;
}

td.mono {
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

td.num {
  text-align: right;
  font-family: 'Segoe UI', Segoe UI, system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}

tfoot td {
  background: var(--gray-100);
  font-weight: 700;
  border-top: 2px solid var(--navy);
}

/* ── Status badges ───────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .2px;
}

.phase-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--gray-700);
}

/* ── Utilization rating ──────────────────────────────────────── */
.rate-high   { color: var(--green);  font-weight: 700; }
.rate-medium { color: var(--amber);  font-weight: 700; }
.rate-low    { color: var(--red);    font-weight: 700; }

.rate-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.rate-badge.high   { background: var(--green); }
.rate-badge.medium { background: var(--amber); color: var(--gray-900); }
.rate-badge.low    { background: var(--red); }

/* ── CA Aging colors ─────────────────────────────────────────── */
.aging-ok       { color: var(--green);  font-weight: 700; }
.aging-warn     { color: var(--amber);  font-weight: 700; }
.aging-critical { color: var(--orange); font-weight: 700; }
.aging-danger   { color: var(--red);    font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn:hover { opacity: .87; box-shadow: 0 2px 6px rgba(0,0,0,.15); }

.btn-primary   { background: var(--blue);   color: #fff; }
.btn-success   { background: var(--green);  color: #fff; }
.btn-danger    { background: var(--red);    color: #fff; }
.btn-warning   { background: var(--amber);  color: var(--gray-900); }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-navy      { background: var(--navy);   color: #fff; }
.btn-outline   { background: #fff; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-xs        { padding: 2px 7px; font-size: 11px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .3px;
}

input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=url], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}

textarea { resize: vertical; min-height: 70px; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--gray-200);
  margin-top: 10px;
}

.required::after { content: ' *'; color: var(--red); }

/* ── Filters bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  border-radius: var(--radius) var(--radius) 0 0;
}

.filter-bar select,
.filter-bar input[type=text],
.filter-bar input[type=date] {
  width: auto;
  min-width: 140px;
  padding: 6px 8px;
  font-size: 12px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}

.tab-btn.active, .tab-btn:hover {
  color: var(--navy);
  border-bottom-color: var(--blue);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Timeline (status history) ───────────────────────────────── */
.timeline { list-style: none; padding: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 0 0 20px 30px;
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: 6px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--blue);
  flex-shrink: 0;
}

.timeline-dot.done    { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-dot.pending { background: var(--gray-300); box-shadow: 0 0 0 2px var(--gray-300); }
.timeline-dot.overdue { background: var(--red); box-shadow: 0 0 0 2px var(--red); }

.timeline-content { flex: 1; }
.timeline-label    { font-weight: 700; font-size: 13px; color: var(--navy); }
.timeline-meta     { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.timeline-remark   { font-size: 12px; color: var(--gray-700); margin-top: 4px; font-style: italic; }

/* ── Milestone checklist ─────────────────────────────────────── */
.milestone-list { list-style: none; }
.milestone-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
}

.milestone-item:last-child { border-bottom: none; }

.milestone-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.milestone-check.done    { background: var(--green); border-color: var(--green); color: #fff; }
.milestone-check.overdue { background: var(--red);   border-color: var(--red);   color: #fff; }
.milestone-check.skipped { background: var(--gray-300); border-color: var(--gray-300); color: #fff; }

.milestone-label { font-size: 13px; font-weight: 600; color: var(--navy); flex: 1; }
.milestone-date  { font-size: 11px; color: var(--gray-500); white-space: nowrap; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 0;
}

.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  font-size: 12px;
  color: var(--gray-700);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.page-btn:hover, .page-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ── Alerts / Flash messages ─────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border-left: 4px solid transparent;
}

.alert-success { background: #d4edda; border-color: var(--green); color: #155724; }
.alert-danger  { background: #f8d7da; border-color: var(--red);   color: #721c24; }
.alert-warning { background: #fff3cd; border-color: var(--amber);  color: #856404; }
.alert-info    { background: var(--blue-lt); border-color: var(--blue); color: #004085; }

/* ── Breadcrumb ──────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 14px;
}

.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--gray-300); }

/* ── Section header ──────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.section-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── Document list ───────────────────────────────────────────── */
.doc-list { list-style: none; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
}

.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 16px; color: var(--blue); }
.doc-label { flex: 1; font-weight: 600; }
.doc-meta { font-size: 11px; color: var(--gray-500); }
.doc-version { font-size: 10px; background: var(--gray-200); padding: 1px 5px; border-radius: 4px; }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #1a3a6e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo img { width: 60px; height: 60px; object-fit: contain; }
.login-logo h1  { font-size: 20px; font-weight: 800; color: var(--navy); margin-top: 8px; }
.login-logo p   { font-size: 12px; color: var(--gray-500); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span2, .form-group.span3 { grid-column: 1; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--gray-500); }
.text-navy   { color: var(--navy); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.fw-700      { font-weight: 700; }
.fw-800      { font-weight: 800; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.d-flex  { display: flex; }
.gap-1   { gap: 8px; }
.gap-2   { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1  { flex: 1; }
.w-100   { width: 100%; }
.hidden  { display: none; }
