:root {
  --sidebar-width: 264px;
  --sidebar-bg: #0f1629;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.05);
  --sidebar-bg-active: rgba(59, 111, 237, 0.16);
  --sidebar-text: #94a0c2;
  --sidebar-text-active: #ffffff;
  --brand-accent: #3b6fed;
  --brand-accent-dark: #2c53c4;
  --topnav-height: 64px;
  --page-bg: #f5f7fb;
  --card-border: #e7eaf3;
  --heading-color: #1a2141;
  --body-color: #3d4665;
  --card-radius: 0.75rem;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--page-bg);
  color: var(--body-color);
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.925rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--heading-color);
  font-weight: 600;
}

a {
  color: var(--brand-accent);
  text-decoration: none;
}

a:hover {
  color: var(--brand-accent-dark);
}

.btn-primary {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--brand-accent-dark);
  border-color: var(--brand-accent-dark);
}

/* ---------- App shell / sidebar ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
  z-index: 1030;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 0.6rem;
  /* White plate so the crest's colours read correctly on the dark sidebar. */
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  flex-shrink: 0;
  padding: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-title {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: #6d7aa0;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--sidebar-text);
  padding: 0.6rem 0.9rem;
  border-radius: 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active i {
  color: var(--brand-accent);
}

.nav-section-label {
  text-transform: uppercase;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: #545f82;
  padding: 1.05rem 0.9rem 0.4rem;
}

.sidebar-footer {
  padding: 0.9rem 1.25rem;
  font-size: 0.72rem;
  color: #545f82;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* ---------- Content area ---------- */

.app-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topnav {
  height: var(--topnav-height);
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #495066;
}

.topnav-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #7a84a5;
  font-size: 0.85rem;
}

.topnav-user .btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 0.65rem;
  padding: 0.35rem 0.75rem;
}

.topnav-user .btn::after {
  color: #97a0bd;
}

.notification-bell {
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 0.65rem;
  padding: 0.4rem 0.7rem;
  color: #495066;
  line-height: 1;
}

.notification-bell:hover {
  background: #f7f9fd;
  color: var(--brand-accent);
}

.notification-bell i {
  font-size: 1.1rem;
}

.notification-badge {
  top: 0.15rem;
  left: 82%;
  font-size: 0.65rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-accent-dark));
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.app-main {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.35rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0;
}

.page-subtitle {
  color: #7a84a5;
  font-size: 0.875rem;
  margin: 0.15rem 0 0;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  /* The system's full name is long, so on a narrow window the two halves stack
     instead of the name wrapping around the copyright line. */
  flex-wrap: wrap;
  gap: 0.15rem 1.5rem;
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--card-border);
  color: #97a0bd;
  font-size: 0.8rem;
  background: #fff;
}

/* ---------- Cards / widgets ---------- */

.card {
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: 0 1px 2px rgba(20, 25, 50, 0.04);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  color: var(--heading-color);
  padding: 0.9rem 1.25rem;
}

.stat-card {
  border-radius: var(--card-radius);
  padding: 1.3rem 1.45rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 8px 20px -6px rgba(20, 25, 50, 0.28);
}

.stat-card .stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.stat-card .stat-icon {
  font-size: 2.1rem;
  opacity: 0.55;
}

.stat-card.bg-blue { background: linear-gradient(135deg, #3b6fed, #2c53c4); }
.stat-card.bg-green { background: linear-gradient(135deg, #2fb380, #1f8a63); }
.stat-card.bg-amber { background: linear-gradient(135deg, #f3a53c, #d9821c); }
.stat-card.bg-red { background: linear-gradient(135deg, #e2564f, #b93b35); }

/* ---------- Tables ---------- */

.table {
  color: var(--body-color);
  font-size: 0.885rem;
}

.table thead th {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #7a84a5;
  border-bottom-width: 1px;
  padding: 0.8rem 1rem;
  white-space: nowrap;
  background: #fafbfe;
}

.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.table tfoot td {
  padding: 0.8rem 1rem;
}

.card > .table-responsive > .table {
  margin-bottom: 0;
}

.card > .table-responsive:last-child {
  border-bottom-left-radius: var(--card-radius);
  border-bottom-right-radius: var(--card-radius);
  overflow: hidden;
}

/* ---------- Reports ---------- */

.report-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  color: var(--body-color);
}

.report-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px -8px rgba(20, 25, 50, 0.18);
  border-color: var(--brand-accent);
}

.report-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.bg-blue-soft { background: #e8effd; color: #3b6fed; }
.bg-green-soft { background: #e3f6ee; color: #1f8a63; }
.bg-amber-soft { background: #fdf1de; color: #d9821c; }
.bg-purple-soft { background: #efe9fb; color: #7048c9; }
.bg-red-soft { background: #fdeae9; color: #b93b35; }
.bg-teal-soft { background: #e2f4f4; color: #12787d; }

.report-print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Checklists ---------- */

.checklist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #f0f2f8;
}

.checklist-row:last-child {
  border-bottom: none;
}

.checklist-question {
  flex: 1;
  font-size: 0.9rem;
}

.checklist-answer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  width: 46%;
}

.checklist-answer .btn-group {
  flex-shrink: 0;
}

.checklist-remark {
  min-width: 0;
}

@media (max-width: 767.98px) {
  .checklist-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .checklist-answer {
    width: 100%;
  }
}

/* ---------- Auth page ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #22315e, #0d1224 70%);
  font-family: "Inter", "Segoe UI", sans-serif;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: #fff;
  border-radius: 1rem;
  padding: 2.4rem 2.2rem;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.45);
}

.auth-card .auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--heading-color);
  margin-bottom: 0.4rem;
}

.auth-card .auth-brand i {
  font-size: 1.65rem;
  color: var(--brand-accent);
}

/* Official crest above the sign-in form; scales down on short screens. */
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.1rem;
}

.auth-logo img {
  width: auto;
  height: 96px;
  max-width: 100%;
  object-fit: contain;
}

@media (max-height: 700px) {
  .auth-logo img {
    height: 68px;
  }
}

/* ---------- Print styles ---------- */

/* Letterhead is hidden on screen and only laid out when printing. */
.print-letterhead {
  display: none;
}

@media print {
  .app-sidebar, .app-topnav, .app-footer, .sidebar-toggle {
    display: none !important;
  }

  .print-letterhead.d-print-flex {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.9rem;
    border-bottom: 2px solid #1a2141;
  }

  .print-logo {
    height: 52px;
    width: auto;
    object-fit: contain;
  }

  .print-org {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a2141;
    line-height: 1.2;
  }

  .print-doc-title {
    font-size: 0.85rem;
    color: #3d4665;
  }

  .app-content {
    margin-left: 0;
  }

  .app-main {
    padding: 0;
  }

  body {
    background: #fff;
  }

  .card {
    border: none;
    box-shadow: none;
  }

  .table thead th {
    background: #fff !important;
  }

  a {
    color: inherit !important;
    text-decoration: none !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }

  .app-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .app-main {
    padding: 1.15rem;
  }
}

/* Inspectorate report tiles — the existing card, with a hover cue that it is a link. */
.report-tile {
  transition: transform .12s ease, box-shadow .12s ease;
}

.report-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 .5rem 1rem rgba(16, 24, 40, .08);
}

/* Keeps the workspace tab strip on one line on narrow screens. */
.inspection-context .nav-tabs .nav-link {
  white-space: nowrap;
  font-size: .875rem;
}

/* A top-level nav item that is not part of a labelled group (Parastatals) —
   given the same breathing room a group label would provide. */
.nav-link-standalone {
  margin-top: .75rem;
}

/* ---------------------------------------------------------------------------
   Per-table search bar, inserted above every data table by table-search.js.
   Sits flush inside a card so it reads as part of the table, not as a filter
   panel of its own, and disappears from printed output.
   --------------------------------------------------------------------------- */
.table-search {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .6rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  background: var(--table-search-bg, rgba(20, 25, 50, 0.015));
}

/* A table standing on its own (no card) still needs the bar to sit tight to it. */
.table-search:first-child {
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
}

.table-search-input {
  max-width: 22rem;
  flex: 1 1 14rem;
}

.table-search .input-group-text {
  background: #fff;
  border-right: 0;
  color: var(--bs-secondary-color, #6c757d);
}

.table-search .form-control {
  border-left: 0;
}

.table-search .form-control:focus {
  box-shadow: none;
  border-color: var(--bs-border-color, #dee2e6);
}

.table-search-count {
  white-space: nowrap;
}

/* A card header immediately followed by the search bar would double the rule. */
.card-header + .table-search {
  border-top: 0;
}
