/* =========================================================================
   THEME TOKENS — light defaults; [data-theme="dark"] overrides below.
   Brand accent: NGT blue (#2EA3F2).
   ========================================================================= */
:root {
  /* Brand (NGT) */
  --primary: #2ea3f2;        /* NGT brand blue — buttons / accents */
  --brand: #2ea3f2;          /* brand mark */
  --brand-soft: #d6ecfd;     /* light blue tint */

  /* Surfaces & text */
  --bg: #f4f6f9;
  --card: #ffffff;
  --surface-2: #eef2f7;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --input-bg: #ffffff;

  --good: #047857;
  --warn: #b45309;
  --bad: #b91c1c;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #2ea3f2;
  --brand: #54b6f6;
  --brand-soft: rgba(46, 163, 242, .18);

  --bg: #0b1220;
  --card: #131d31;
  --surface-2: #1c2840;
  --text: #e6edf5;
  --muted: #93a4ba;
  --border: #28344a;
  --input-bg: #0f1a2c;

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;

  /* Sidebar (dark) */
  --side-bg: #0b1424;
  --side-bg-2: #091020;
  --side-fg: #c7d3e2;
  --side-muted: #6c809a;
  --side-hover: rgba(255, 255, 255, .07);
  --side-active-bg: #2ea3f2;
  --side-active-fg: #ffffff;
  --side-active-bar: #cfe8ff;
  --side-group-fg: #cdd9e7;
  --side-line: rgba(255, 255, 255, .08);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =========================
   NESTED COLLAPSIBLE SIDE NAV (NGT)
   ========================= */

:root {
  /* Sidebar (light defaults — dark values are in the [data-theme="dark"] block) */
  --side-w: 250px;
  --side-bg: #ffffff;
  --side-bg-2: #f8fafc;
  --side-fg: #334155;
  --side-muted: #94a3b8;
  --side-hover: #eef2f7;
  --side-active-bg: #2ea3f2;
  --side-active-fg: #ffffff;
  --side-active-bar: #cfe8ff;
  --side-group-fg: #475569;
  --side-line: #e5e7eb;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--side-w);
  background: var(--side-bg);
  color: var(--side-fg);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
  border-right: 1px solid var(--side-line);
  transition: transform .18s ease;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
  padding: 14px;
  background: var(--side-bg-2);
  border-bottom: 1px solid var(--side-line);
}

.nav-collapse {
  background: transparent;
  border: none;
  color: var(--side-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
}

.nav-collapse:hover { background: var(--side-hover); color: var(--side-fg); }

/* Bug / Feature quick-report buttons beside the brand */
.side-head-actions { display: inline-flex; align-items: center; gap: 4px; }
.brand-act { display: inline-flex; align-items: center; background: var(--side-hover); border: none; border-radius: 7px; padding: 5px; cursor: pointer; line-height: 1; }
.brand-act .nav-ico { width: 17px; height: 17px; }
#fbBug { color: #25a35a; }   /* green bug */
#fbIdea { color: #e6b800; }  /* yellow lightbulb */
.brand-act:hover { filter: brightness(1.18); }

.side-nav { flex: 1 1 auto; overflow-y: auto; padding: 8px 8px 14px; display: flex; flex-direction: column; }
/* Tickets sits at the bottom of the nav container, above the workspace break line. */
.side-pinned { margin-top: auto; }

/* Support-config: "Check all" header row */
.sc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

/* Audit Trail — sticky toolbar (title + back/export + filters/search) */
.audit-bar { position: sticky; top: 0; z-index: 30; background: var(--bg); padding: 10px 0; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.audit-bar-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.audit-bar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.audit-filters { gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.audit-filters input[type="search"] { min-width: 200px; flex: 1 1 220px; }
.audit-filters label { display: inline-flex; align-items: center; white-space: nowrap; }
.audit-filters input[type="date"], .audit-filters select { margin: 0; }
/* Saved-searches dropdown */
.audit-saved { position: relative; display: inline-block; }
.audit-saved > summary { list-style: none; cursor: pointer; }
.audit-saved > summary::-webkit-details-marker { display: none; }
.audit-saved-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 240px; max-width: 340px; max-height: 320px; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.25); padding: 6px; }
.saved-item { display: flex; align-items: center; gap: 4px; }
.saved-item form { margin: 0; display: inline; }
.saved-item .saved-apply { flex: 1; text-align: left; background: transparent; border: none; color: var(--text); cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.saved-item .saved-apply:hover { background: var(--surface-2); }
.saved-item .saved-exp { padding: 4px 6px; text-decoration: none; color: var(--muted); border-radius: 6px; }
.saved-item .saved-exp:hover { background: var(--surface-2); }
.saved-item .saved-del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; }
.saved-item .saved-del:hover { color: #c0392b; }

/* Generic clickable row (links + buttons) */
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--side-fg);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.side-link:hover { background: var(--side-hover); color: var(--side-fg); text-decoration: none; }
.side-link.active { background: var(--side-active-bg); color: var(--side-active-fg); box-shadow: inset 3px 0 0 var(--side-active-bar); }
.nav-ico { flex: 0 0 18px; opacity: .9; }
.side-label { overflow: hidden; flex: 0 1 auto; }

/* Accordion module group */
.nav-group { margin-top: 1px; }

.group-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #e2e8f0;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--side-group-fg);
}

.group-toggle:hover { background: var(--side-hover); color: var(--side-fg); }
.group-toggle .side-label { flex: 1 1 auto; }
.group-caret { flex: 0 0 14px; opacity: .7; transition: transform .18s ease; }
.nav-group.open > .group-toggle .group-caret { transform: rotate(180deg); }

/* Sub-items */
.subnav { display: none; position: relative; margin: 1px 0 6px; padding-left: 22px; }
.nav-group.open > .subnav { display: block; }
.subnav::before { content: ""; position: absolute; left: 18px; top: 2px; bottom: 6px; width: 1px; background: var(--side-line); }
.subnav .side-link { font-size: 13.5px; padding: 7px 10px; color: var(--side-muted); }
.subnav .side-link:hover { color: var(--side-fg); }
/* nested (level-2) groups, e.g. BCM > Risk Assessment */
.subnav .nav-group { margin-top: 0; }
.subnav .group-toggle { font-size: 11.5px; letter-spacing: .3px; padding: 8px 10px; color: var(--side-group-fg); }
.subnav .subnav { padding-left: 14px; }
.subnav .subnav::before { left: 10px; }

/* "Coming soon" — visible but inert */
.side-link.soon { color: var(--side-muted); cursor: default; }
.side-link.soon:hover { background: transparent; color: var(--side-muted); }
.soon-tag {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--side-muted);
  border: 1px solid var(--side-line);
  border-radius: 6px;
  padding: 1px 6px;
}
/* Paid-only module shown to a Free tenant: readable but visibly gated. */
.side-link.locked .side-label { color: var(--side-muted); }
.lock-tag { margin-left: auto; display: inline-flex; align-items: center; color: var(--side-muted); }
.lock-tag .nav-ico { width: 14px; height: 14px; }

/* Locked / not-enabled modules */
.side-locked { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--side-line); }
.side-section-label {
  font-size: 10px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--side-muted);
  padding: 6px 12px 8px;
}
.locked-item { display: flex; align-items: center; gap: 11px; padding: 8px 12px; color: var(--side-muted); font-size: 13.5px; cursor: default; }
.locked-item .nav-ico { opacity: .55; }

/* Pinned account/footer area */
.side-foot { padding: 8px; border-top: 1px solid var(--side-line); background: var(--side-bg-2); }
.tenant-switch { margin: 2px 0 6px; }
.tenant-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--side-muted); margin: 0 0 3px 4px; }
.tenant-switch select { width: 100%; margin: 0; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; font-size: 13px; }
.tenant-current { font-size: 13px; color: var(--side-fg); padding: 2px 4px 8px; }
.side-logout { margin: 0; }
.side-logout .side-link { color: var(--bad); }
.side-logout .side-link:hover { background: rgba(239, 68, 68, .14); color: var(--bad); }

/* Floating reopen / mobile-menu button + drawer backdrop */
.nav-fab {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  background: var(--side-bg);
  color: var(--side-fg);
  border: 1px solid var(--side-line);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.nav-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; border: none; }

/* Desktop: content sits right of the sidebar; collapse hides it entirely. */
@media (min-width: 900px) {
  body.has-side { padding-left: var(--side-w); transition: padding-left .18s ease; }
  html.nav-collapsed body.has-side { padding-left: 56px; }
  html.nav-collapsed .app-sidebar { transform: translateX(-100%); }
  html.nav-collapsed .nav-fab { display: inline-flex; }
}

/* Mobile: off-canvas drawer. */
@media (max-width: 899px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .45); }
  body.nav-open .app-sidebar { transform: translateX(0); }
  .nav-collapse { display: none; }
  .nav-fab { display: inline-flex; }
  body.has-side .container { margin-top: 64px; }
}

/* =========================
   LAYOUT
   ========================= */

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

/* =========================
   CARDS (KEY FIX)
   ========================= */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

/* =========================
   FORMS
   ========================= */

label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--input-bg);
  color: var(--text);
}

textarea {
  min-height: 90px;
}

/* =========================
   BUTTONS
   ========================= */

button,
.button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

.button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.button.danger,
button.danger {
  background: var(--bad);
}

/* compact delete button used in catalog rows */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* =========================
   MFA (two-factor auth)
   ========================= */

.mfa-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #713f12;
}

.mfa-banner.locked {
  background: #fee2e2;
  border-color: #fecaca;
  color: #7f1d1d;
}

.mfa-banner .button {
  white-space: nowrap;
}

.mfa-enroll {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.mfa-qr-col,
.mfa-confirm-col {
  flex: 1 1 240px;
  min-width: 220px;
}

.mfa-qr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  min-height: 140px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
}

.mfa-qr img,
.mfa-qr canvas {
  display: block;
}

.mfa-key {
  display: inline-block;
  font-family: "Courier New", monospace;
  font-size: 16px;
  letter-spacing: 2px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  user-select: all;
}

.otp-input {
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  font-family: "Courier New", monospace;
}

/* =========================
   ALERTS
   ========================= */

.alert {
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.alert.error {
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.alert.success {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

/* =========================
   TABLES
   ========================= */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

/* =========================
   BADGES / STATUS
   ========================= */

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: #e5e7eb;
}

.badge.high {
  background: #fee2e2;
  color: var(--bad);
}

.badge.medium {
  background: #fef3c7;
  color: var(--warn);
}

.badge.low {
  background: #dcfce7;
  color: var(--good);
}

/* Critical rating — darker/stronger than High. Added 2026-06-23. */
.badge.critical {
  background: #7f1d1d;
  color: #ffffff;
}

/* =========================
   UTILITIES
   ========================= */

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* =========================
   ACTION ITEM ENHANCEMENTS
   ========================= */

/* overdue items */
.item-overdue {
  border-left: 4px solid var(--bad);
}

/* high priority items */
.item-high {
  border-left: 4px solid var(--warn);
}

/* =========================
   LAYOUT HELPERS (added 2026-06-23)
   These classes were referenced by views but missing from the stylesheet,
   so dashboards/forms rendered unstyled. Defined here to match the app.
   ========================= */

/* Responsive metric-card grid (dashboard, risk summary). */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

/* Large number shown on a metric card. */
.metric {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

/* Two-column responsive layout (e.g. Risk Library, Profile). */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

/* Vertical form layout used by all create/edit forms. */
.form-grid {
  display: grid;
  gap: 4px;
}

/* Inline action group (small form sitting on one row). */
.actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.actions-row select,
.actions-row input {
  width: auto;
  margin-bottom: 0;
}

/* =========================
   FOOTER
   ========================= */

.footer {
  text-align: center;
  color: var(--muted);
  padding: 30px;
}

/* =========================
   REPORTS BUILDER
   ========================= */
.report-builder { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; margin-bottom: 20px; }
@media (max-width: 820px) { .report-builder { grid-template-columns: 1fr; } }

.scope-panel select[disabled] { background: #f3f4f6; color: var(--muted); }
.scope-list-label { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }
.scope-list { border: 1px solid var(--border); border-radius: 8px; height: 300px; overflow-y: auto; padding: 6px; background: #fff; }
.scope-item { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.scope-item:hover { background: #f3f4f6; }
.scope-item input { width: auto; margin: 0; }
.scope-actions { text-align: right; margin-top: 8px; font-size: 13px; }

.fmt-tabs { display: flex; align-items: flex-end; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 8px; flex-wrap: wrap; }
.fmt-tab { background: #fff; color: var(--primary); border: 1px solid var(--border); border-radius: 8px 8px 0 0; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.fmt-tab.active { background: #eef2ff; color: var(--text); }
.fmt-tabs .packets { margin-left: auto; }
.fmt-tabs .packets label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 400; }
.fmt-tabs .packets select { margin: 0; min-width: 240px; }

.builder-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
@media (max-width: 640px) { .builder-cols { grid-template-columns: 1fr; } }
.builder-cols h3 { margin: 0 0 8px; font-size: 14px; }
.report-pool, .report-selected { list-style: none; margin: 0; padding: 0; min-height: 150px; border: 1px dashed var(--border); border-radius: 8px; }
.report-selected { border-style: solid; background: #fafafa; }
.report-opt, .report-sel { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.report-opt:last-child, .report-sel:last-child { border-bottom: none; }
.report-opt:hover { background: #eef2ff; }
.report-sel { background: #fff; }
.report-sel:hover { background: #fee2e2; }
.add-hint { color: var(--primary); font-weight: 700; }
.rm-hint { color: var(--bad); }
.empty-hint { color: var(--muted); font-size: 13px; padding: 10px 4px; }

.builder-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.builder-foot-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
@media (max-width: 640px) { .builder-foot-grid { grid-template-columns: 1fr; } }
.builder-toggles { display: flex; gap: 20px; margin: 6px 0 12px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.chk input { width: auto; margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 14px; margin-bottom: 10px; }
.check-grid .chk { font-weight: 400; margin: 0; }

/* =========================
   RISK GOAL METER
   ========================= */
.rm-track { position: relative; height: 26px; background: #eef1f5; border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.rm-inherent { position: absolute; left: 0; top: 0; bottom: 0; background: #fde2e2; }
.rm-residual { position: absolute; left: 0; top: 0; bottom: 0; background: #9ca3af; transition: width .2s ease; }
.rm-residual.low { background: #16a34a; }
.rm-residual.medium { background: #d97706; }
.rm-residual.high { background: #dc2626; }
.rm-residual.critical { background: #7f1d1d; }
.rm-future { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #1d4ed8; }
.rm-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); }
.rm-sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.rm-sw-inherent { background: #fde2e2; border: 1px solid #f3b4b4; }
.rm-sw-residual { background: #16a34a; }
.rm-sw-future { background: #fff; border: 2px dashed #1d4ed8; }

/* =========================
   RISK LIBRARY MAPPINGS
   ========================= */
.lib-item { margin-bottom: 12px; }
.lib-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.map-line { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.map-chip { display: inline-flex; align-items: center; gap: 5px; background: #eef2ff; border: 1px solid #dbe3ff; border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.chip-x { background: none; border: none; color: var(--bad); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.map-add { margin-top: 8px; }
.map-add select { min-width: 160px; }
.map-add input[type="number"] { width: 70px; }

/* repository review/expiry date flags */
.date-warn { color: var(--warn); font-weight: 600; }
.date-overdue { color: var(--bad); font-weight: 700; }

/* =========================
   MODALS
   ========================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(17, 24, 39, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
  animation: modal-in .14s ease-out;
}
@keyframes modal-in { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-body .card { box-shadow: none; border: none; padding: 0; margin: 0; }

/* a heading row with an action button on the right */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0; }

/* =========================
   VENDOR LIST
   ========================= */
.vendor-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.vendor-tools { display: flex; gap: 18px; align-items: center; }
.vendor-tools a, .vlink { color: #16a34a; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; padding: 0; }
.vendor-tools a:hover, .vlink:hover { text-decoration: underline; }
.vlink-plus { color: var(--primary); font-size: 20px; vertical-align: middle; }
.vendor-search { display: flex; gap: 8px; margin: 10px 0 14px; }
.vendor-search input { margin: 0; }
.vendor-totals { display: flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.vendor-totals > div { flex: 1; padding: 12px 16px; border-right: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.vendor-totals > div:last-child { border-right: none; }
/* Clickable count cards (e.g. Inventory status filter, ticket #64). */
.vendor-totals > a { flex: 1; padding: 12px 16px; border-right: 1px solid var(--border); font-size: 13px; color: var(--muted); text-decoration: none; display: block; }
.vendor-totals > a:last-child { border-right: none; }
.vendor-totals > a:hover { background: var(--brand-soft); }
.vendor-totals > a.active { background: var(--brand-soft); box-shadow: inset 0 -3px 0 var(--primary); }
.vt-num { font-weight: 700; color: var(--text); font-size: 15px; margin-right: 6px; }

.vendor-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .03); }
@media (max-width: 760px) { .vendor-row { grid-template-columns: 1fr; } }
.vendor-id { display: flex; gap: 12px; align-items: flex-start; }
.vendor-dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 18px; margin-top: 2px; }
.vendor-dot.ok { background: #16a34a; }
.vendor-dot.off { background: #dc2626; }
.vendor-id strong { font-size: 15px; }

.vendor-meter { min-width: 190px; }
.vm-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.vm-bar { position: relative; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #16a34a 0%, #84cc16 30%, #eab308 55%, #f97316 78%, #dc2626 100%); }
.vm-rrs { position: absolute; top: -3px; bottom: -3px; width: 3px; background: #111827; border-radius: 2px; }
.vm-goal { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 2px dashed #111827; opacity: .6; }
.vm-bottom { font-size: 11px; color: var(--muted); margin-top: 4px; }

.vendor-actions { display: flex; gap: 6px; align-items: center; }
.vendor-actions form { margin: 0; }
.vbtn { width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; color: #fff; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.vbtn.view { background: #2563eb; }
.vbtn.ok { background: #16a34a; }
.vbtn.del { background: #dc2626; }
.vbtn:hover { opacity: .88; }

/* vendor risk-rating create page */
.vcreate-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .vcreate-cols { grid-template-columns: 1fr; } }
.vsec { font-size: 14px; border-bottom: 2px solid var(--border); padding-bottom: 6px; margin: 0 0 12px; color: var(--text); text-transform: uppercase; letter-spacing: .5px; }
.req { color: var(--bad); }

/* Health check */
.hc-card { padding: 4px 18px; }
.hc-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.hc-card .hc-row:last-child { border-bottom: none; }
.hc-count { min-width: 34px; text-align: center; flex: 0 0 auto; }
.hc-details { flex: 1; }
.hc-details summary { cursor: pointer; font-weight: 600; }
.hc-ok { color: var(--muted); padding-top: 1px; }
.hc-items { margin: 8px 0 4px; padding-left: 20px; }
.hc-items li { padding: 2px 0; font-size: 13.5px; }

/* Document Hub */
.doc-table td { vertical-align: top; }
.doc-table input, .doc-table select { margin-bottom: 4px; }

/* Bulk update panel (action items) */
.bulk-panel { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
.bulk-panel summary { cursor: pointer; font-weight: 600; }
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.bulk-bar select, .bulk-bar input { width: auto; margin: 0; }
.bulk-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 14px; max-height: 260px; overflow-y: auto; }
.bulk-list .chk { margin: 0; }

/* AI assistant (fenced, read-only chat) */
.ai-fab { position: fixed; right: 18px; bottom: 18px; z-index: 120; background: var(--primary); color: #fff; border: none; border-radius: 999px; padding: 11px 18px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.ai-fab:hover { filter: brightness(1.06); }
.ai-fab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255,255,255,.35); vertical-align: middle; margin-right: 2px; }
.fb-fab { position: fixed; left: 18px; bottom: 18px; z-index: 119; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 9px 16px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.fb-fab:hover { background: var(--surface-2); }
.ai-panel { position: fixed; right: 18px; bottom: 70px; z-index: 121; width: 360px; max-width: calc(100vw - 36px); height: 520px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.3); overflow: hidden; }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; }
.ai-x { background: none; border: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 88%; padding: 8px 11px; border-radius: 12px; font-size: 14px; line-height: 1.42; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.bot { background: var(--surface-2); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.ai-chip { background: transparent; border: 1px solid var(--border); color: var(--primary); border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.ai-chip:hover { background: var(--surface-2); }
.ai-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.ai-form input[type=text] { flex: 1; margin: 0; }
.ai-form button { margin: 0; }
.ai-master { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 4px; }
.ai-master.on { border-color: var(--primary); }
.ai-master .chk { margin: 0; display: flex; gap: 8px; align-items: flex-start; }
[hidden] { display: none !important; }

/* Reports hub — searchable/filterable report catalog */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.report-card { display: flex; flex-direction: column; gap: 6px; }
.report-card-top { display: flex; gap: 6px; }
.report-card h3 { margin: 4px 0 0; font-size: 15px; }
.report-card .button { margin-top: auto; align-self: flex-start; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-chip { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Hover/focus help tooltips — rendered by the help() helper */
.help { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1; cursor: help; position: relative; vertical-align: middle; margin-left: 5px; user-select: none; }
.help:hover, .help:focus { background: var(--primary); color: #fff; border-color: var(--primary); outline: none; }
.help::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; font-weight: 400; line-height: 1.45; width: max-content; max-width: 260px; white-space: normal; text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,.28); opacity: 0; visibility: hidden; transition: opacity .12s ease; z-index: 200; pointer-events: none; }
.help::before { content: ''; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #111827; opacity: 0; visibility: hidden; transition: opacity .12s ease; z-index: 200; }
.help--down::after { bottom: auto; top: calc(100% + 9px); }
.help--down::before { bottom: auto; top: calc(100% + 4px); border-top-color: transparent; border-bottom-color: #111827; }
.help:hover::after, .help:hover::before, .help:focus::after, .help:focus::before { opacity: 1; visibility: visible; }

/* Base link colour follows the brand in both themes. */
a { color: var(--primary); }

/* =========================================================================
   DARK-MODE OVERRIDES — for components that bake in light surface colours.
   ========================================================================= */
:root[data-theme="dark"] .vendor-totals,
:root[data-theme="dark"] .vendor-row,
:root[data-theme="dark"] .scope-list,
:root[data-theme="dark"] .report-sel,
:root[data-theme="dark"] .fmt-tab { background: var(--card); }

:root[data-theme="dark"] .report-selected,
:root[data-theme="dark"] .scope-item:hover,
:root[data-theme="dark"] .report-opt:hover,
:root[data-theme="dark"] .fmt-tab.active,
:root[data-theme="dark"] .map-chip,
:root[data-theme="dark"] .mfa-key,
:root[data-theme="dark"] .scope-panel select[disabled] { background: var(--surface-2); border-color: var(--border); color: var(--text); }

:root[data-theme="dark"] .report-sel:hover { background: rgba(248, 113, 113, .18); }

/* Risk meters: dark track + light markers so the line shows on dark. */
:root[data-theme="dark"] .rm-track { background: var(--surface-2); }
:root[data-theme="dark"] .rm-inherent { background: rgba(248, 113, 113, .22); }
:root[data-theme="dark"] .rm-sw-inherent { background: rgba(248, 113, 113, .22); border-color: rgba(248, 113, 113, .4); }
:root[data-theme="dark"] .vm-rrs { background: #e6edf5; }
:root[data-theme="dark"] .vm-goal { border-left-color: #e6edf5; }

/* Tinted status surfaces re-tinted for dark. */
:root[data-theme="dark"] .alert.error { background: rgba(248, 113, 113, .14); border-color: rgba(248, 113, 113, .35); color: #fecaca; }
:root[data-theme="dark"] .alert.success { background: rgba(52, 211, 153, .14); border-color: rgba(52, 211, 153, .35); color: #bbf7d0; }
:root[data-theme="dark"] .mfa-banner { background: rgba(250, 204, 21, .12); border-color: rgba(250, 204, 21, .3); color: #fde68a; }
:root[data-theme="dark"] .mfa-banner.locked { background: rgba(248, 113, 113, .14); border-color: rgba(248, 113, 113, .35); color: #fecaca; }

:root[data-theme="dark"] .badge { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .badge.high { background: rgba(248, 113, 113, .16); color: #fca5a5; }
:root[data-theme="dark"] .badge.medium { background: rgba(251, 191, 36, .16); color: #fcd34d; }
:root[data-theme="dark"] .badge.low { background: rgba(52, 211, 153, .16); color: #86efac; }

/* =========================================================================
   THEME TOGGLE control (in the sidebar footer)
   ========================================================================= */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--side-fg);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.theme-toggle:hover { background: var(--side-hover); }
.theme-toggle .theme-ico-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-ico-dark { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .theme-ico-light { display: none; }

/* Brand mark in the sidebar header / login */
.brand-mark { color: var(--brand); flex: 0 0 auto; display: inline-flex; }
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; font-weight: 800; font-size: 20px; letter-spacing: .2px; }
.auth-brand .brand-mark svg { width: 26px; height: 26px; }

/* Login: "Create a workspace" self-serve call-to-action */
.login-sep { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; color: var(--muted); font-size: 13px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-signup { display: block; width: 100%; text-align: center; box-sizing: border-box; }
.login-signup-note { text-align: center; margin-top: 8px; }

/* Legal pages (Privacy / Terms) */
.legal { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.legal h2 { margin-top: 24px; font-size: 18px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
.footer a { color: inherit; text-decoration: underline; }