/* Security Awareness design system v3.
   This layer intentionally comes after the legacy component CSS: it provides
   one coherent visual contract while older templates are migrated gradually. */
:root {
  --sap-font-sans: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sap-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sap-font-size-body: .875rem;
  --sap-font-size-small: .8rem;
  --sap-primary: #2463eb;
  --sap-primary-dark: #1d4ed8;
  --sap-primary-darker: #1e3a8a;
  --sap-primary-light: #eef4ff;
  --sap-primary-lighter: #dce8ff;
  --sap-bg: #f8fafc;
  --sap-surface: #ffffff;
  --sap-surface-raised: #ffffff;
  --sap-surface-subtle: #f8fafc;
  --sap-surface-hover: #f3f6fb;
  --sap-border: #dfe5ee;
  --sap-border-light: #edf1f6;
  --sap-text: #172033;
  --sap-text-muted: #637086;
  --sap-text-dim: #526077;
  --sap-sidebar-bg: #0b1220;
  --sap-sidebar-hover: rgba(148, 163, 184, .10);
  --sap-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 5px rgba(15, 23, 42, .035);
  --sap-shadow-md: 0 8px 24px -12px rgba(15, 23, 42, .24), 0 2px 6px rgba(15, 23, 42, .05);
  --sap-shadow-lg: 0 20px 48px -20px rgba(15, 23, 42, .32), 0 8px 18px -12px rgba(15, 23, 42, .12);
  --sap-radius-sm: 7px;
  --sap-radius-md: 10px;
  --sap-radius-lg: 14px;
  --sap-radius-xl: 18px;
  --sap-content-max: 1560px;
}

:root[data-theme="dark"] {
  --sap-bg: #080d16;
  --sap-surface: #101725;
  --sap-surface-raised: #141d2d;
  --sap-surface-subtle: #0c1320;
  --sap-surface-hover: #182235;
  --sap-border: #263249;
  --sap-border-light: #202b3e;
  --sap-text: #f2f6fc;
  --sap-text-muted: #9aa8bd;
  --sap-text-dim: #aab5c6;
  --sap-primary-light: rgba(59, 130, 246, .14);
  --sap-primary-lighter: rgba(59, 130, 246, .22);
  --sap-shadow-sm: 0 1px 2px rgba(0, 0, 0, .24), 0 4px 12px rgba(0, 0, 0, .10);
  --sap-shadow-md: 0 12px 30px -15px rgba(0, 0, 0, .7), 0 3px 8px rgba(0, 0, 0, .20);
  --sap-shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .85);
}

html { background: var(--sap-bg); }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% -10%, rgba(37, 99, 235, .055), transparent 28rem),
    var(--sap-bg);
  font-family: var(--sap-font-sans);
  font-size: var(--sap-font-size-body);
  line-height: 1.5;
  letter-spacing: -.005em;
}
button, input, select, textarea, .form-control, .form-select, .btn,
.table, .dropdown-menu, .modal, .popover, .tooltip, .toast {
  font-family: var(--sap-font-sans) !important;
}
code, kbd, pre, samp, .mono-field { font-family: var(--sap-font-mono); }

/* Application shell */
.sap-sidebar {
  width: 244px;
  padding: 1rem .75rem .8rem;
  background: linear-gradient(180deg, #0f172a 0%, #0b1220 100%);
  border-right: 1px solid rgba(148, 163, 184, .10);
  box-shadow: 8px 0 32px rgba(2, 6, 23, .08);
}
.sap-sidebar-brand {
  min-height: 45px;
  padding: 0 .65rem .9rem;
  margin-bottom: .55rem;
  font-size: 1rem;
  letter-spacing: -.02em;
}
.sap-nav-section {
  padding: .85rem .65rem .32rem;
  font-size: .64rem;
  letter-spacing: .11em;
  color: #64748b;
}
.sap-nav-link {
  min-height: 39px;
  gap: .7rem;
  padding: .55rem .68rem;
  margin-bottom: 3px;
  border-radius: 9px;
  font-size: .84rem;
  color: var(--sap-sidebar-text);
}
.sap-nav-link svg { width: 17px; height: 17px; }
.sap-nav-link:hover { background: #1e293b; color: #fff; }
.sap-nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(37, 99, 235, .26), rgba(37, 99, 235, .11));
  box-shadow: inset 3px 0 0 #60a5fa, 0 6px 18px rgba(2, 6, 23, .12);
}
.sap-sidebar-tools { margin: .3rem 0 .7rem; }
.sap-notif-bell, .sap-theme-toggle { width: 38px; height: 38px; }
.sap-sidebar-user { padding: .8rem .35rem .1rem; }
.sap-avatar { width: 32px; height: 32px; }

.sap-main {
  width: calc(100% - 244px);
  max-width: var(--sap-content-max);
  margin: 0 auto;
  padding: 1.8rem clamp(1.25rem, 2.3vw, 2.5rem) 3rem;
}
.sap-main.sap-main-full { max-width: none; }
@media (min-width: 901px) {
  .sap-shell.sap-nav-collapsed .sap-main { width: calc(100% - 60px); }
  .sap-shell.sap-nav-collapsed .sap-sidebar-tools { gap: .45rem; }
  .sap-shell.sap-nav-collapsed .sap-sidebar-user { justify-content: center; padding-inline: 0; }
}

/* Page hierarchy */
.sap-main h1, .sap-page-title {
  font-size: clamp(1.38rem, 1.8vw, 1.7rem) !important;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.2;
}
.sap-main h2, .sap-main .h2 { font-size: 1.2rem !important; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.sap-main h3, .sap-main .h3 { font-size: 1.05rem !important; font-weight: 650; line-height: 1.35; }
.sap-main h4, .sap-main .h4, .sap-main h5, .sap-main .h5 { font-size: 1rem !important; font-weight: 650; line-height: 1.4; }
.sap-main h6, .sap-main .h6 { font-size: .9rem !important; font-weight: 650; line-height: 1.4; }
.sap-main p, .sap-main li, .sap-main dd, .sap-main .form-control, .sap-main .form-select { line-height: 1.5; }
.sap-main .small, .sap-main small { font-size: var(--sap-font-size-small); }
.sap-page-subtitle, .page-hero p { max-width: 72ch; }
.page-hero {
  position: relative;
  min-height: 96px;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius-xl);
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--sap-primary) 6%, var(--sap-surface)), var(--sap-surface) 48%);
  box-shadow: var(--sap-shadow-sm);
  overflow: hidden;
}
.page-hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -75px;
  top: -110px;
  border: 28px solid color-mix(in srgb, var(--sap-primary) 7%, transparent);
  border-radius: 50%;
  pointer-events: none;
}
.page-hero > * { position: relative; z-index: 1; }
.sap-eyebrow {
  color: var(--sap-primary);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .11em;
}

/* Surfaces and cards */
.card {
  border-color: var(--sap-border);
  border-radius: var(--sap-radius-lg);
  background: var(--sap-surface-raised);
  box-shadow: var(--sap-shadow-sm);
}
.card:not(.ops-card):not(a):not(.kpi-card):not(.exec-card):hover {
  border-color: var(--sap-border);
  box-shadow: var(--sap-shadow-sm);
}
a.card:hover, .ops-card:hover, .kpi-card:hover, .exec-card:hover {
  border-color: color-mix(in srgb, var(--sap-primary) 38%, var(--sap-border));
  box-shadow: var(--sap-shadow-md);
  transform: translateY(-2px);
}
.card-body { padding: 1.1rem 1.15rem; }
.card-header, .card-footer { padding: .85rem 1.1rem; }
.card-header-clean, .card-heading {
  min-height: 64px;
  padding: .95rem 1.15rem;
}
.card-header-clean h2, .card-heading h2 { margin: 0; }

.kpi-grid { gap: .85rem; margin-bottom: 1.35rem; }
.card.kpi-card {
  min-height: 112px;
  padding: .95rem 1.05rem;
  border: 0;
  border-left: 3px solid var(--sap-primary);
  border-radius: var(--sap-radius-xl);
  overflow: visible;
}
.kpi-label { margin-bottom: .4rem; font-size: .68rem; font-weight: 600; letter-spacing: .05em; color: var(--sap-text-muted); }
.kpi-value { font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-meta { margin-top: .35rem; }
.exec-summary-grid { gap: .85rem; }
.card.exec-card {
  min-height: 132px;
  padding: 1.15rem 1.2rem;
  border: 0;
  border-radius: var(--sap-radius-xl);
}
.exec-card-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .55rem; }
.exec-card-icon { width: 30px; height: 30px; border-radius: 10px; }
.exec-card-icon svg { width: 16px; height: 16px; }
.exec-card-label { font-size: .7rem; font-weight: 550; color: var(--sap-text-muted); }
.exec-card-value {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  color: var(--sap-text);
  font-variant-numeric: tabular-nums;
}

/* Dashboard chart containers follow the same "white tile, soft shadow,
   no hard border" contract as the metric cards above. */
.card.chart-card { border: 0; border-radius: var(--sap-radius-xl); }

/* Buttons and fields */
.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .48rem .82rem;
  border-radius: 9px;
  font-size: .84rem;
  line-height: 1.2;
}
.btn-sm { min-height: 32px; padding: .35rem .65rem; font-size: .78rem; }
.btn-xs { min-height: 27px; }
.btn-primary { box-shadow: 0 4px 12px -5px rgba(37, 99, 235, .7); }
.btn-outline-secondary { background: var(--sap-surface); }
.form-label { margin-bottom: .38rem; font-size: .8rem; }
.form-control, .form-select {
  min-height: 40px;
  padding: .5rem .72rem;
  border-radius: 9px;
  background: var(--sap-surface);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, .025);
}
textarea.form-control { min-height: 112px; }
.form-control, .form-select { font-size: var(--sap-font-size-body) !important; }
.form-label { font-size: var(--sap-font-size-small) !important; }
.table { font-size: .84rem !important; line-height: 1.45; }
.table thead th { font-size: .74rem !important; line-height: 1.3; }
.form-control::placeholder { color: color-mix(in srgb, var(--sap-text-muted) 72%, transparent); }
.form-control:hover, .form-select:hover { border-color: color-mix(in srgb, var(--sap-text-muted) 58%, var(--sap-border)); }
.form-control:focus, .form-select:focus {
  border-color: var(--sap-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sap-primary) 14%, transparent);
}
.input-group-text {
  border-color: var(--sap-border);
  background: var(--sap-surface-subtle);
  color: var(--sap-text-muted);
}

/* Data presentation */
.table { font-size: .84rem; }
.table thead th {
  padding-top: .72rem;
  padding-bottom: .72rem;
  background: var(--sap-surface-subtle);
  font-size: .69rem;
  letter-spacing: .07em;
}
.table > :not(caption) > * > * { padding: .68rem .75rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover > * { background-color: var(--sap-surface-hover); }
.sap-sortable-th-link { padding: .72rem .75rem; }
.sap-badge, .status-chip, .count-pill {
  min-height: 24px;
  padding: .25rem .58rem;
  font-size: .69rem;
  letter-spacing: .01em;
}
.operation-row { min-height: 68px; padding: .9rem 1.1rem; }
.operation-row:hover { background: var(--sap-surface-hover); }
.ops-grid { gap: .85rem; }
.ops-card { min-height: 112px; padding: 1rem 1.05rem; }
.ops-icon { border-radius: 12px; }

/* Navigation, overlays and feedback */
.nav-tabs {
  gap: .25rem;
  padding: .3rem;
  border: 1px solid var(--sap-border);
  border-radius: 11px;
  background: var(--sap-surface-subtle);
}
.nav-tabs .nav-link {
  min-height: 34px;
  padding: .42rem .7rem;
  border: 0;
  border-radius: 8px;
  color: var(--sap-text-muted);
  font-size: .8rem;
  font-weight: 600;
  transition: color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.nav-tabs .nav-link:hover { color: var(--sap-text); background: var(--sap-surface-hover); }
.nav-tabs .nav-link.active {
  color: var(--sap-primary);
  background: var(--sap-surface);
  font-weight: 700;
  box-shadow: var(--sap-shadow-sm);
}
.dropdown-menu {
  padding: .4rem;
  border-color: var(--sap-border);
  border-radius: 11px;
  background: var(--sap-surface-raised);
  box-shadow: var(--sap-shadow-lg);
}
.dropdown-item { padding: .52rem .65rem; border-radius: 7px; font-size: .82rem; }
.modal-content { border: 1px solid var(--sap-border); background: var(--sap-surface-raised); }
.alert { padding: .8rem .95rem; border-left: 4px solid currentColor; }

/* Slim 2FA banner — an inline amber strip instead of the old full-width
   alert-warning box so it recedes behind the page content. Session-scoped
   dismissal is handled by an inline script in base.html. */
.sap-2fa-banner {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.15rem;
  padding: .6rem .85rem;
  border: 1px solid #fde68a;
  border-radius: var(--sap-radius-md);
  background: #fffbeb;
  color: #92400e;
  box-shadow: var(--sap-shadow-sm);
  font-size: .81rem;
}
:root[data-theme="dark"] .sap-2fa-banner {
  border-color: rgba(245, 158, 11, .28);
  background: rgba(245, 158, 11, .12);
  color: #fcd34d;
}
.sap-2fa-banner-icon { flex-shrink: 0; width: 16px; height: 16px; }
.sap-2fa-banner-text { flex: 1 1 auto; min-width: 0; }
.sap-2fa-banner-text strong { font-weight: 700; }
.sap-2fa-banner-cta {
  flex-shrink: 0;
  padding: .3rem .65rem;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: .75rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.sap-2fa-banner-cta:hover { background: #fde68a; border-color: #f59e0b; color: #78350f; }
:root[data-theme="dark"] .sap-2fa-banner-cta {
  border-color: rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .18);
  color: #fcd34d;
}
:root[data-theme="dark"] .sap-2fa-banner-cta:hover { background: rgba(245, 158, 11, .28); color: #fde68a; }
.sap-2fa-banner-close {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 24px; height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b45309;
  cursor: pointer;
}
.sap-2fa-banner-close:hover { background: #fde68a; color: #78350f; }
:root[data-theme="dark"] .sap-2fa-banner-close { color: #fcd34d; }
:root[data-theme="dark"] .sap-2fa-banner-close:hover { background: rgba(245, 158, 11, .22); color: #fde68a; }
@media (max-width: 575px) {
  .sap-2fa-banner { flex-wrap: wrap; }
  .sap-2fa-banner-cta { margin-left: auto; }
}
.empty-state { padding: 3.2rem 1.25rem; }
.empty-state-icon { width: 48px; height: 48px; padding: 10px; border-radius: 14px; background: var(--sap-surface-subtle); opacity: .9; }
.empty-state-icon svg { width: 28px; height: 28px; }

/* Responsive behavior */
@media (max-width: 1100px) {
  .sap-main { width: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sap-main { padding: 1.25rem 1rem 2.5rem; }
  .sap-sidebar {
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    box-shadow: 18px 0 50px rgba(2, 6, 23, .34);
  }
  .sap-sidebar-nav-scroll { overscroll-behavior: contain; }
  .sap-shell.sap-nav-open .sap-sidebar-backdrop { touch-action: none; }
  .sap-mobile-topbar {
    min-height: 58px;
    background: rgba(15, 23, 42, .94);
    border-bottom: 1px solid rgba(148, 163, 184, .12);
    backdrop-filter: blur(18px);
  }
  .sap-mobile-menu-btn { width: 42px; height: 42px; border-radius: 9px; }
  .sap-mobile-menu-btn:hover { background: rgba(255,255,255,.10); }
}
@media (max-width: 575px) {
  .sap-main { padding: 1rem .75rem 2rem; }
  .page-hero { min-height: auto; padding: 1rem; border-radius: 14px; }
  .kpi-grid, .exec-summary-grid { grid-template-columns: 1fr; gap: .65rem; }
  .kpi-card { min-height: 92px; }
  .card-body { padding: .9rem; }
  .btn { min-height: 40px; }
  .d-flex.justify-content-between { row-gap: .75rem; }
  .nav-tabs { border-radius: 10px; }
}

/* Horizontal filter bar: scroll on mobile instead of wrapping into many rows */
.sap-filter-bar {
  display: flex;
  gap: .35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.sap-filter-bar::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .sap-filter-bar { flex-wrap: wrap; overflow-x: visible; }
}

@media print {
  .sap-sidebar, .sap-mobile-topbar, .sap-sidebar-backdrop, .btn, .nav-tabs { display: none !important; }
  .sap-main { width: 100%; max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Migration target: replace the repeated inline `exec-card-value text-muted; font-size:1.1rem` empty-state cells (was: 6 hardcoded occurrences across dashboard/admin) with a single tokenized utility. Consumes only existing tokens; zero new shadows/radii/fonts. */
.sap-empty-kpi {
  font-size: var(--sap-font-size-body);
  font-weight: 500;
  color: var(--sap-text-muted);
}
