:root {
  --primary: #6d28d9;         /* purple-700 */
  --primary-dark: #4c1d95;    /* purple-900 */
  --primary-light: #8b5cf6;   /* purple-500 */
  --accent: #ec4899;          /* pink accent */
  --bg: #f6f4fb;
  --surface: #ffffff;
  --surface-2: #f3effa;
  --border: #e4ddf2;
  --text: #241b36;
  --muted: #6b6480;
  --success: #15803d;
  --danger: #b91c1c;
  --warning: #b45309;
  /* Header + nav gradient */
  --header-bg: linear-gradient(100deg, #4c1d95 0%, #6d28d9 55%, #7c3aed 100%);
  --nav-bg: #ffffff;
  --header-text: #ffffff;
  --row-hover: #faf7ff;
}

/* ---- Dark theme (purple) ---- */
[data-theme="dark"] {
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --primary-light: #c4b5fd;
  --accent: #f472b6;
  --bg: #15111f;
  --surface: #1f1830;
  --surface-2: #2a2140;
  --border: #3a2f55;
  --text: #ece8f6;
  --muted: #a99fc4;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
  --header-bg: linear-gradient(100deg, #2a1259 0%, #3b1d7a 55%, #4c1d95 100%);
  --nav-bg: #1f1830;
  --header-text: #f3eefc;
  --row-hover: #281f3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 24px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 18px rgba(76, 29, 149, 0.28);
  position: relative;
  z-index: 20;
}
.app-header .brand { display: flex; align-items: center; gap: 14px; }
.app-header .brand h1 { font-size: 19px; margin: 0; letter-spacing: 0.6px; font-weight: 700; }
.app-header .brand .sub { font-size: 11px; opacity: 0.85; }
.app-header .brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; letter-spacing: 1px;
  color: #fff;
}

.header-actions { display: flex; align-items: center; gap: 16px; }

/* Theme dropdown */
.theme-select select {
  width: auto;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-text);
  font-size: 13px;
  cursor: pointer;
}
.theme-select select option { color: #1f2937; }

/* User profile block (clear, high-contrast) */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
}
.user-profile .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.user-profile .user-meta { line-height: 1.25; }
.user-profile .user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--header-text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-profile .user-sub {
  font-size: 11px;
  color: var(--header-text);
  opacity: 0.8;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-header .role-badge {
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Top navigation bar ---- */
.topnav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(76, 29, 149, 0.06);
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  max-width: 1400px;
  margin: 0 auto;
}
.topnav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;        /* take the left space so the user menu sits at the right */
}

/* ---- Combined user menu (right-aligned in nav row) ---- */
.nav-user { position: relative; flex: 0 0 auto; margin-left: auto; }
.nav-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
}
.nav-user-btn:hover { background: var(--border); }
.nav-user-btn .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--header-bg); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: 0 0 auto;
}
.nav-user-btn .nav-user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-btn .caret { font-size: 10px; transition: transform 0.15s ease; }
.nav-user.open .nav-user-btn .caret { transform: rotate(180deg); }

.nav-user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(76, 29, 149, 0.2);
  padding: 12px;
  z-index: 40;
}
.nav-user.open .nav-user-menu { display: block; }
.nav-user-head { display: flex; align-items: center; gap: 12px; }
.nav-user-head .avatar.lg {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--header-bg); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex: 0 0 auto;
}
.nav-user-head .user-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.nav-user-head .user-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nav-user-divider { height: 1px; background: var(--border); margin: 10px 0; }
.nav-user-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav-user-row select { width: auto; padding: 6px 10px; font-size: 13px; }
.nav-user-logout {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 8px 6px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
.nav-user-logout:hover { background: rgba(185, 28, 28, 0.1); }
.nav-user-head .role-badge {
  background: var(--accent); color: #fff; padding: 2px 8px;
  border-radius: 10px; font-size: 10px; font-weight: 700;
}
.topnav-links a {
  display: inline-block;
  padding: 9px 15px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.topnav-links a:hover {
  background: var(--surface-2);
  color: var(--primary);
  text-decoration: none;
}
.topnav-links a.active {
  background: var(--header-bg);
  color: #fff;
  box-shadow: 0 3px 10px rgba(109, 40, 217, 0.35);
}

/* ---- Admin dropdown in top nav ---- */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-dropdown-btn:hover { background: var(--surface-2); color: var(--primary); }
.nav-dropdown-btn.active {
  background: var(--header-bg);
  color: #fff;
  box-shadow: 0 3px 10px rgba(109, 40, 217, 0.35);
}
.nav-dropdown-btn .caret { font-size: 10px; transition: transform 0.15s ease; }
.nav-dropdown.open .nav-dropdown-btn .caret { transform: rotate(180deg); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(76, 29, 149, 0.18);
  padding: 6px;
  z-index: 30;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: var(--surface-2); color: var(--primary); text-decoration: none; }
.nav-dropdown-menu a.active { background: var(--header-bg); color: #fff; }

.topnav-toggle {
  display: none;
  margin: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.content {
  padding: 26px 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Responsive: collapse the top nav into a toggle on small screens */
@media (max-width: 860px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .app-header .brand .sub { display: none; }
  .topnav { flex-wrap: wrap; }
  .topnav-toggle { display: inline-block; order: 1; }
  .nav-user { order: 2; margin-left: auto; }
  .topnav-links {
    order: 3;
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px 0 4px;
  }
  .topnav-links.open { display: flex; }
  .topnav-links a { border-radius: 8px; }
  .nav-user-name { display: none; }  /* compact avatar-only button on mobile */

  /* Admin dropdown becomes an inline, always-expanded group on mobile */
  .nav-dropdown { display: block; width: 100%; }
  .nav-dropdown-btn { width: 100%; justify-content: space-between; border-radius: 8px; }
  .nav-dropdown-menu {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    padding: 2px 0 2px 14px;
    min-width: 0;
    background: transparent;
  }
}

/* ---- Cards & tables ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 17px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.4px; }
tr:hover td { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--muted); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 14px; }
.row > * { flex: 1; }

button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { background: #e5e7eb; color: var(--text); }
button.secondary:hover { background: #d1d5db; }
button.danger { background: var(--danger); }
button.success { background: var(--success); }
button.small { padding: 5px 10px; font-size: 12px; }

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge.DRAFT { background: #e5e7eb; color: #374151; }
.badge.SUBMITTED { background: #dbeafe; color: #1e40af; }
.badge.UNDER_SCRUTINY { background: #fef3c7; color: var(--warning); }
.badge.RETURNED { background: #fde68a; color: #92400e; }
.badge.SANCTIONED { background: #dcfce7; color: var(--success); }
.badge.REJECTED { background: #fee2e2; color: var(--danger); }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; }
.alert.error { background: #fee2e2; color: var(--danger); }
.alert.info { background: #dbeafe; color: #1e40af; }
.alert.success { background: #dcfce7; color: var(--success); }

.muted { color: var(--muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.total-amount { font-size: 22px; font-weight: 700; color: var(--primary); }

/* ---- SoR autocomplete dropdown ---- */
.sor-dropdown {
  position: absolute; z-index: 10; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; width: 100%; max-height: 220px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.sor-dropdown .opt { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.sor-dropdown .opt:hover { background: var(--surface-2); }

/* ---- Login (split: image half + form half) ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* Left half: PWD Headquarter image */
.login-hero {
  flex: 1 1 50%;
  position: relative;
  /* Tint, then the real photo (pwd-hq.jpg) if present, then the SVG placeholder.
     Drop a real photo at assets/pwd-hq.jpg and it will automatically be used. */
  background-image: linear-gradient(180deg, rgba(76, 29, 149, 0.25) 0%, rgba(76, 29, 149, 0.78) 100%),
    url('pwd-hq.jpg'),
    url('pwd-hq.svg');
  background-size: cover, cover, cover;
  background-position: center, top center, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  display: flex;
  align-items: flex-end;
  color: #fff;
}
/* Fallback caption / branding over the image */
.login-hero .hero-caption {
  padding: 36px;
}
.login-hero .hero-caption h2 { margin: 0 0 6px; font-size: 24px; }
.login-hero .hero-caption p { margin: 0; opacity: 0.9; font-size: 14px; max-width: 460px; }

/* Right half: centered form card */
.login-form-pane {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 36px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.login-card h1 { margin: 0 0 4px; color: var(--primary); font-size: 26px; }
.login-card .tagline { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card button { width: 100%; padding: 11px; margin-top: 6px; }
.dev-code { font-family: monospace; background: #fef3c7; color: #1f2937; padding: 8px; border-radius: 6px; text-align: center; margin-top: 10px; font-size: 15px; }

/* Stack on narrow screens: hide the image, keep the form usable */
@media (max-width: 860px) {
  .login-wrap { flex-direction: column; }
  .login-hero { flex-basis: 180px; min-height: 180px; }
  .login-hero .hero-caption { padding: 20px; }
  .login-hero .hero-caption h2 { font-size: 18px; }
  .login-hero .hero-caption p { display: none; }
  .login-form-pane { flex-basis: auto; }
}

/* ---- Staff structure tree ---- */
.staff-tree { margin-top: 8px; }
.staff-node { margin-bottom: 8px; position: relative; }
.staff-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
}
.staff-card .staff-main { display: flex; align-items: center; gap: 12px; }
.staff-badge {
  flex: 0 0 auto;
  min-width: 42px;
  text-align: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
}
.staff-name { font-weight: 600; font-size: 14px; }
.staff-desig { font-size: 12px; color: var(--muted); }
.staff-office { font-size: 12px; }
.staff-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Rank-based accent colours for the left border + badge */
.staff-card.role-PS { border-left-color: #6d28d9; }
.staff-card.role-PS .staff-badge { background: #6d28d9; }
.staff-card.role-CE { border-left-color: #b91c1c; }
.staff-card.role-CE .staff-badge { background: #b91c1c; }
.staff-card.role-SS { border-left-color: #9333ea; }
.staff-card.role-SS .staff-badge { background: #9333ea; }
.staff-card.role-DS { border-left-color: #c026d3; }
.staff-card.role-DS .staff-badge { background: #c026d3; }
.staff-card.role-SE { border-left-color: #b45309; }
.staff-card.role-SE .staff-badge { background: #b45309; }
.staff-card.role-EE { border-left-color: #0b5394; }
.staff-card.role-EE .staff-badge { background: #0b5394; }
.staff-card.role-AE { border-left-color: #15803d; }
.staff-card.role-AE .staff-badge { background: #15803d; }
.staff-card.role-JE { border-left-color: #6b7280; }
.staff-card.role-JE .staff-badge { background: #6b7280; }

/* ---- Staff table role badge ---- */
.badge-role {
  display: inline-block;
  min-width: 36px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}
.badge-role.role-PS { background: #6d28d9; }
.badge-role.role-CE { background: #b91c1c; }
.badge-role.role-SE { background: #b45309; }
.badge-role.role-EE { background: #0b5394; }
.badge-role.role-AE { background: #15803d; }
.badge-role.role-JE { background: #6b7280; }

/* ---- Office posts summary ---- */
.summary-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.summary-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.summary-card {
  flex: 1 1 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.summary-card .sc-num { font-size: 26px; font-weight: 700; color: var(--primary); }

/* ---- Modal popup ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 12, 36, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 100%; max-width: 480px; padding: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}
.modal-box dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 12px 0 0; }
.modal-box dt { color: var(--muted); font-size: 13px; }
.modal-box dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* =====================================================================
   Visual refresh: friendlier, more colourful look (overrides above).
   Pure CSS; no markup or behaviour changes.
   ===================================================================== */
:root {
  --c-blue: #2563eb;
  --c-teal: #0d9488;
  --c-amber: #f59e0b;
  --c-rose: #e11d48;
  --c-green: #16a34a;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(76, 29, 149, 0.08), 0 1px 2px rgba(76, 29, 149, 0.06);
  --shadow-md: 0 6px 20px rgba(76, 29, 149, 0.12);
  --focus-ring: 0 0 0 3px rgba(139, 92, 246, 0.28);
  --th-bg: linear-gradient(90deg, #ede9fe 0%, #fce7f3 100%);
  --secondary-bg: #ede9fe;
  --secondary-hover: #ddd6fe;
}
[data-theme="dark"] {
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --th-bg: linear-gradient(90deg, #2e2250 0%, #3a2150 100%);
  --secondary-bg: #342a52;
  --secondary-hover: #433764;
}

body {
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(800px 380px at 100% 0%, rgba(236, 72, 153, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.45;
}

/* Header gets a colourful stripe */
.app-header { border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6, #2563eb) 1; }

/* Nav pills */
.topnav { border-radius: 0 0 var(--radius) var(--radius); }
.topnav-links a:hover, .nav-dropdown-btn:hover { transform: translateY(-1px); }
.nav-dropdown-menu { border-radius: var(--radius); box-shadow: var(--shadow-md); }
.nav-dropdown-menu a { transition: background 0.15s ease, padding-left 0.15s ease; }
.nav-dropdown-menu a:hover { padding-left: 16px; }

/* Cards: rounded, soft shadow, rainbow accent bar on top */
.card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary-light);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.content > .card:nth-of-type(4n+1) { border-top-color: #8b5cf6; }
.content > .card:nth-of-type(4n+2) { border-top-color: #ec4899; }
.content > .card:nth-of-type(4n+3) { border-top-color: #0d9488; }
.content > .card:nth-of-type(4n+4) { border-top-color: #f59e0b; }
.card h2 {
  font-size: 18px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--primary);
  display: inline-block;
}
.flex-between h2 { margin-bottom: 4px; }

/* Tables: colourful header, zebra rows, rounded corners */
table { border-radius: 10px; overflow: hidden; }
th { background: var(--th-bg); color: var(--primary-dark); border-bottom: 2px solid var(--primary-light); }
[data-theme="dark"] th { color: var(--primary-light); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody tr:hover td { background: var(--row-hover); }

/* Forms */
input, select, textarea { border-radius: 8px; border-width: 1.5px; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-light); box-shadow: var(--focus-ring); }
label { letter-spacing: 0.2px; }

/* Buttons: gradients, lift on hover, coloured variants */
button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(109, 40, 217, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
button:hover { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); transform: translateY(-1px); box-shadow: 0 5px 12px rgba(109, 40, 217, 0.35); }
button:active { transform: translateY(0); }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button.secondary { background: var(--secondary-bg); color: var(--primary-dark); box-shadow: none; }
[data-theme="dark"] button.secondary { color: var(--text); }
button.secondary:hover { background: var(--secondary-hover); box-shadow: none; }
button.success { background: linear-gradient(135deg, #15803d, #22c55e); box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3); }
button.success:hover { background: linear-gradient(135deg, #166534, #16a34a); }
button.danger { background: linear-gradient(135deg, #be123c, #f43f5e); box-shadow: 0 2px 6px rgba(225, 29, 72, 0.3); }
button.danger:hover { background: linear-gradient(135deg, #9f1239, #e11d48); }
button:disabled { transform: none; filter: grayscale(0.4); }
.topnav-toggle, .nav-user-btn, .nav-user-logout, .link-btn { box-shadow: none; transform: none; }
.link-btn { background: none; }
.link-btn:hover { background: none; box-shadow: none; transform: none; }
.nav-user-btn { background: var(--surface-2); }
.nav-user-btn:hover { background: var(--border); transform: none; box-shadow: none; }
.nav-user-logout { background: transparent; }
.nav-user-logout:hover { background: rgba(185, 28, 28, 0.1); transform: none; box-shadow: none; }

/* Status badges: vivid pills */
.badge { padding: 4px 11px; border-radius: 999px; }
.badge.DRAFT { background: #e0e7ff; color: #3730a3; }
.badge.SUBMITTED { background: #cffafe; color: #0e7490; }
.badge.UNDER_SCRUTINY { background: #fef3c7; color: #b45309; }
.badge.RETURNED { background: #ffedd5; color: #c2410c; }
.badge.SANCTIONED { background: #dcfce7; color: #15803d; }
.badge.REJECTED { background: #ffe4e6; color: #be123c; }

/* Alerts: left accent bar */
.alert { border-radius: 10px; border-left: 4px solid currentColor; box-shadow: var(--shadow-sm); }

/* Summary / dashboard cards */
.summary-box { border-radius: var(--radius); }
.summary-card { border-radius: var(--radius); border-top: 4px solid var(--primary-light); box-shadow: var(--shadow-sm); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.summary-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.summary-card:nth-child(5n+1) { border-top-color: #8b5cf6; }
.summary-card:nth-child(5n+2) { border-top-color: #ec4899; }
.summary-card:nth-child(5n+3) { border-top-color: #0d9488; }
.summary-card:nth-child(5n+4) { border-top-color: #f59e0b; }
.summary-card:nth-child(5n+5) { border-top-color: #2563eb; }
.summary-card .sc-num { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* Staff tree cards */
.staff-card { border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.staff-card:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.badge-role, .staff-badge { border-radius: 999px; }

/* Modal */
.modal-box { border-radius: 16px; border-top: 5px solid var(--accent); animation: modal-pop 0.18s ease-out; }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }

/* Links in tables */
.link-btn { font-weight: 600; }

/* Nicer scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--primary-light) transparent; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Horizontal line between the items in each dropdown list */
.nav-dropdown-menu a:not(:last-child) {
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}

/* Compact Officer Details box (Office Structure) */
.sp-compact { padding: 12px 14px; }
.sp-compact h2 { font-size: 15px; margin-bottom: 4px; }
.sp-compact p, .sp-compact table, .sp-compact input, .sp-compact .badge-role { font-size: 12px; }
.sp-compact th, .sp-compact td { padding: 4px 8px; }
.sp-compact th { font-size: 10.5px; }
.sp-compact input { padding: 4px 7px; }
.sp-compact .sp-sanc, .sp-compact .sp-fill { width: 70px !important; }
.sp-compact button { padding: 5px 12px; font-size: 12px; }
.sp-compact .alert { padding: 6px 10px; font-size: 12px; margin-bottom: 8px; }

/* Profile menu: PIMS ID, Office Name and Officers Post stacked vertically */
.nav-user-info { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.nav-user-info > div { display: flex; flex-direction: column; gap: 1px; }
.nui-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.nui-value { font-weight: 600; word-break: break-word; }

/* Help page / quick-start popup */
.help-list { margin: 8px 0 0; padding-left: 20px; line-height: 1.6; }
.help-list li { margin-bottom: 6px; }

/* Illustrated help */
.help-path { display: inline-block; margin: 2px 0 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--primary); border: 1px solid var(--border); }
.help-steps { margin: 8px 0 14px; padding-left: 22px; line-height: 1.65; }
.help-steps li { margin-bottom: 6px; padding-left: 4px; }
.help-steps li::marker { color: var(--accent); font-weight: 700; }
.help-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-top: 6px; }
.help-fig { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.help-fig img { display: block; width: 100%; height: auto; cursor: zoom-in; border-bottom: 1px solid var(--border); }
.help-fig figcaption { padding: 8px 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.help-toc a { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }
.help-toc a:hover { background: var(--border); text-decoration: none; }
@media (max-width: 860px) { .help-figs { grid-template-columns: 1fr; } }

/* Compact shaded filter box (Search / Zone) used at the top of the Asset Section pages */
.filter-box {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 5px 10px; margin: 2px 0 10px; width: fit-content; max-width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); box-shadow: var(--shadow-sm);
  font-size: 12px;
}
.filter-box label { margin: 0; font-size: 12px; white-space: nowrap; }
.filter-box input, .filter-box select { width: auto; padding: 3px 7px; font-size: 12px; }
.filter-box input[type="search"], .filter-box input[type="text"], .filter-box input:not([type]) { width: 200px; }
.filter-box button { padding: 3px 10px; font-size: 12px; }

/* Filter box right-aligned on the title line (Asset Section pages) */
.top-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.top-tools .filter-box { margin: 0; }

/* Wide registers (Road Assets): compact text and horizontal scroll */
.wide-table { font-size: 12px; }
.wide-table th, .wide-table td { padding: 6px 8px; }
.wide-table th { white-space: nowrap; }

/* Road register fitted to an A4 landscape width (about 1060 px) without sideways scrolling */
.fit-a4 { table-layout: fixed; min-width: 1000px; font-size: 11px; }
.fit-a4 th, .fit-a4 td { padding: 4px 5px; white-space: normal; word-break: break-word; overflow-wrap: anywhere; vertical-align: top; }
.fit-a4 th { font-size: 10px; letter-spacing: 0; line-height: 1.2; }
.fit-a4 .col-action button { padding: 2px 6px; font-size: 10px; margin: 0 2px 2px 0; }

/* Pagination bar under a list */
.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; font-size: 12px; }
.pager label { margin: 0; font-size: 12px; }
.pager select { width: auto; padding: 3px 6px; font-size: 12px; }
.pager .pager-info { margin: 0 8px 0 4px; color: var(--muted); }
.pager .pager-gap { padding: 0 2px; color: var(--muted); }
.pager button.small { min-width: 28px; padding: 3px 8px; font-size: 12px; }

/* Estimate wizard (PRICE-style) */
.steps{display:flex;gap:6px;flex-wrap:wrap;margin:8px 0 12px}
.steps .step{padding:5px 12px;border-radius:14px;background:#eef1f6;color:#667;font-size:12px}
.steps .step.active{background:#2563eb;color:#fff;font-weight:600}
.steps .step.done{background:#d9f2e3;color:#116b3a}
.step-nav{display:flex;justify-content:space-between;align-items:center;margin-top:14px;padding-top:10px;border-top:1px solid #e3e7ee}
.item-card{border:1px solid #d5dbe6;border-radius:8px;background:#fafbfd;padding:8px 10px;margin-bottom:10px}
.item-head{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:6px;font-size:13px}
table.compact{font-size:12px}
table.compact input{padding:3px 5px;font-size:12px;width:100%;min-width:60px}

/* Item descriptions (DSR nomenclature) justified across the cell */
.desc { text-align: justify; text-justify: inter-word; hyphens: auto; }
