:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --accent: #0ea5e9;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --teal: #0d9488;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(15,23,42,.08);
  --header-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

/* ===== SINGLE HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}
.brand-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .95rem; }
.brand-text small { font-size: .7rem; opacity: .75; font-weight: 400; }

.nav-toggle {
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 42px; height: 42px;
  border-radius: 10px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nav-toggle:active { background: rgba(255,255,255,.25); }

.app-nav {
  display: none;
  flex-direction: column;
  padding: 8px 12px 16px;
  background: #0f172a;
  max-width: 1100px;
  margin: 0 auto;
}
.app-nav.open { display: flex; }
.app-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: .95rem;
  transition: background .15s;
}
.app-nav .nav-link:hover,
.app-nav .nav-link.active {
  background: rgba(59,130,246,.35);
  color: #fff;
}
.app-nav .nav-link i { font-size: 1.15rem; width: 24px; text-align: center; }

/* Desktop nav */
@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .app-nav {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
    padding: 0 12px 10px;
    background: transparent;
  }
  .app-nav .nav-link {
    padding: 8px 12px;
    font-size: .85rem;
  }
  .header-inner { padding-bottom: 0; }
}

/* ===== MAIN ===== */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.page-sub {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 18px;
}

/* ===== CARDS ===== */
.card-ui {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15,23,42,.04);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-ui .card-hd {
  padding: 14px 16px;
  font-weight: 650;
  font-size: .95rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.card-ui .card-bd { padding: 16px; }

/* Dashboard stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 700px) {
  .stats { grid-template-columns: 1fr 1fr 1fr; }
}
.stat {
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: 100px;
}
.stat::after {
  content: '';
  position: absolute;
  right: -10px; bottom: -10px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.stat .stat-label { font-size: .78rem; opacity: .9; margin-bottom: 6px; }
.stat .stat-value { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.stat .stat-icon { font-size: 1.5rem; margin-bottom: 6px; opacity: .9; }
.stat-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-green  { background: linear-gradient(135deg, #10b981, #059669); }
.stat-red    { background: linear-gradient(135deg, #f87171, #dc2626); grid-column: 1 / -1; }
@media (min-width: 700px) {
  .stat-red { grid-column: auto; }
}

/* Menu grid */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 700px) {
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 88px;
  padding: 14px 10px;
  border-radius: 14px;
  text-decoration: none;
  color: #fff !important;
  font-weight: 650;
  font-size: .9rem;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  transition: transform .12s, box-shadow .12s;
  border: none;
}
.menu-btn:active { transform: scale(.97); }
.menu-btn i { font-size: 1.5rem; }
.menu-btn small { font-weight: 400; opacity: .85; font-size: .72rem; display: block; }
.m-orange { background: linear-gradient(135deg, #f59e0b, #b45309); }
.m-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.m-teal   { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.m-indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }
.m-purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.m-slate  { background: linear-gradient(135deg, #64748b, #334155); }
.m-green  { background: linear-gradient(135deg, #34d399, #059669); }

/* Forms */
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.form-control, .form-select {
  min-height: 48px;
  border-radius: 12px !important;
  border: 1.5px solid #e2e8f0 !important;
  font-size: 1rem !important;
  padding: 10px 14px !important;
  background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2) !important;
}

.btn-action {
  min-height: 50px;
  border-radius: 12px !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
  border: none !important;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-save { background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important; color: #fff !important; }
.btn-warn { background: linear-gradient(135deg, #f59e0b, #d97706) !important; color: #fff !important; }
.btn-teal { background: linear-gradient(135deg, #14b8a6, #0f766e) !important; color: #fff !important; }
.btn-purple { background: linear-gradient(135deg, #a78bfa, #7c3aed) !important; color: #fff !important; }
.btn-green { background: linear-gradient(135deg, #34d399, #059669) !important; color: #fff !important; }
.btn-danger-soft { background: linear-gradient(135deg, #f87171, #dc2626) !important; color: #fff !important; }
.btn-indigo { background: linear-gradient(135deg, #6366f1, #4338ca) !important; color: #fff !important; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-ui {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table-ui th {
  background: #f1f5f9;
  font-weight: 650;
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table-ui td {
  padding: 11px 12px;
  border-top: 1px solid #e2e8f0;
  vertical-align: middle;
}
.table-ui tr:hover td { background: #f8fafc; }
.badge-soft {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}
.btn-sm-ui {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid #cbd5e1;
  color: var(--primary);
  background: #fff;
}
.btn-sm-ui:hover { background: #eff6ff; }

/* Alert toast */
.alert-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: .9rem;
}
.alert-toast button {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #065f46;
  line-height: 1;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px 14px;
  color: var(--muted);
  font-size: .8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* Report cards */
.report-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #e2e8f0;
}
.report-item:last-child { border-bottom: none; }
.report-item h5 { font-size: 1rem; margin: 0; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: .9rem;
}

.row-gap { --bs-gutter-y: 0.85rem; }
