/* =====================================================================
   ITSec Platform — Master Stylesheet
   Purple / Cyan modern SaaS theme, inspired by Sprout Social / Hootsuite
   ===================================================================== */

:root {
  /* Palette */
  --brand-purple:   #7C3AED;
  --brand-purple-2: #6D28D9;
  --brand-purple-3: #A855F7;
  --brand-blue:     #1E1B4B;
  --brand-deep:     #0F0B2E;
  --brand-cyan:     #00D4FF;
  --brand-pink:     #EC4899;
  --brand-mint:     #10B981;
  --brand-amber:    #F59E0B;
  --brand-red:      #EF4444;
  --brand-blue-2:   #3B82F6;

  /* Surfaces */
  --bg-page:        #F8F9FB;
  --bg-soft:        #F4F3FF;
  --surface:        #FFFFFF;
  --surface-2:      #FAFBFF;
  --mini:           #1A1F2E;
  --mini-hover:     #2A3142;

  /* Text */
  --text-1:         #15192C;
  --text-2:         #4F5469;
  --text-3:         #6E7384;
  --text-muted:     #8A8FB0;

  /* Border */
  --border:         #E5E7EB;
  --border-2:       #F0F1F4;

  /* Gradients */
  --grad-primary:   linear-gradient(135deg, #7C3AED 0%, #00D4FF 100%);
  --grad-warm:      linear-gradient(135deg, #EC4899 0%, #7C3AED 100%);
  --grad-dark:      linear-gradient(135deg, #0F0B2E 0%, #1E1B4B 100%);
  --grad-mint:      linear-gradient(135deg, #00D4FF 0%, #10B981 100%);

  /* Shadows */
  --sh-sm:  0 2px 6px rgba(15,11,46,0.05);
  --sh-md:  0 8px 24px rgba(15,11,46,0.07);
  --sh-lg:  0 24px 60px rgba(15,11,46,0.12);
  --sh-glow: 0 16px 50px rgba(124,58,237,0.3);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
/* ========== Font system ==========
   LTR (English): Segoe UI — system font on Windows, falls back to web-safe stack on other OSes.
   RTL (Arabic):  Bahij Janna Bold (local font file) — falls back to Tajawal if not installed.
   To enable Bahij Janna, place its font files in /assets/fonts/ :
     - bahij_janna.woff2          (regular)
     - bahij_janna_bold.woff2     (bold)
   Bahij Janna is a commercial typeface already licensed at Solutions Group.
*/
@font-face {
  font-family: 'Bahij Janna';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: local('Bahij Janna'),
       url('../fonts/bahij_janna.woff2') format('woff2'),
       url('../fonts/bahij_janna.woff')  format('woff');
}
@font-face {
  font-family: 'Bahij Janna';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: local('Bahij Janna Bold'), local('Bahij Janna-Bold'),
       url('../fonts/bahij_janna_bold.woff2') format('woff2'),
       url('../fonts/bahij_janna_bold.woff')  format('woff');
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-1);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--brand-purple); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-purple-2); }
h1, h2, h3, h4, h5, h6 { font-family: 'Segoe UI', system-ui, sans-serif; font-weight: 700; color: var(--text-1); margin: 0; letter-spacing: -0.01em; }

/* RTL — Arabic uses Cairo as the universal primary font.
   Matches both body[dir=rtl] (when dir is set on body) and html[dir=rtl] body
   (when dir is set on the html element only — common pattern). Cairo is
   applied to ALL elements (input, button, textarea, etc.) so the entire UI
   has consistent Arabic typography. */
body[dir="rtl"], body[dir="rtl"] *,
html[dir="rtl"] body, html[dir="rtl"] body * {
  font-family: 'Cairo', 'Bahij Janna', 'Tajawal', 'Segoe UI', system-ui, sans-serif;
}
/* Code-like content must stay monospace even in RTL */
body[dir="rtl"] code, body[dir="rtl"] pre, body[dir="rtl"] kbd,
body[dir="rtl"] .text-monospace, body[dir="rtl"] [class*="font-monospace"],
html[dir="rtl"] body code, html[dir="rtl"] body pre, html[dir="rtl"] body kbd {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
/* Bootstrap-icons stay icon font */
body[dir="rtl"] .bi, body[dir="rtl"] i[class*="bi-"],
html[dir="rtl"] body .bi, html[dir="rtl"] body i[class*="bi-"] {
  font-family: 'bootstrap-icons' !important;
}
body[dir="rtl"] h1, body[dir="rtl"] h2, body[dir="rtl"] h3,
body[dir="rtl"] h4, body[dir="rtl"] h5, body[dir="rtl"] h6,
body[dir="rtl"] strong, body[dir="rtl"] .fw-bold {
  font-weight: 700;
}

/* =====================================================================
   AUTH PAGES (login)
   ===================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-page);
}
@media (max-width: 991px) { .auth-shell { grid-template-columns: 1fr; } }

.auth-side {
  background: var(--grad-dark);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(124,58,237,0.45), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0,212,255,0.35), transparent 45%),
    linear-gradient(135deg, #0F0B2E 0%, #1E1B4B 100%);
  color: #fff;
  padding: 56px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 70%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side .brand-row { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.15rem; }
.auth-side .brand-mark {
  width: 38px; height: 38px;
  background: var(--grad-primary);
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(124,58,237,0.55);
  color: #fff; font-size: 1.1rem;
}
.auth-side h1 { color: #fff; font-size: 2.4rem; line-height: 1.1; margin-bottom: 18px; }
.auth-side .lead { color: rgba(255,255,255,0.8); font-size: 1rem; max-width: 460px; }
.auth-side .features { display: grid; gap: 14px; margin-top: 28px; }
.auth-side .feature { display: flex; gap: 12px; align-items: flex-start; color: rgba(255,255,255,0.85); font-size: 0.92rem; }
.auth-side .feature .dot {
  flex: 0 0 28px; height: 28px;
  border-radius: 8px;
  background: rgba(124,58,237,0.18);
  border: 1px solid rgba(124,58,237,0.35);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
}
.auth-side .foot { color: rgba(255,255,255,0.5); font-size: 0.78rem; }

.auth-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: 38px 36px;
  width: 100%; max-width: 420px;
}
.auth-card h2 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-3); font-size: 0.9rem; margin-bottom: 22px; }
.auth-card .form-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.auth-card .form-control {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 0.92rem;
}
.auth-card .form-control:focus {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 4px rgba(124,58,237,0.12);
}
.auth-card .btn-primary {
  background: var(--grad-primary);
  border: 0;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: var(--r-md);
  width: 100%;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  box-shadow: var(--sh-glow);
}
.auth-card .btn-primary:hover { filter: brightness(0.97); }
.auth-card .alert {
  border-radius: var(--r-md);
  border: 0;
  font-size: 0.88rem;
  padding: 10px 14px;
}

/* =====================================================================
   APP SHELL (sidebar + main)
   ===================================================================== */
.app-body { background: var(--bg-page); }

/* Mini sidebar (icons-only) */
.app-mini-side {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 64px;
  background: var(--mini);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0;
  z-index: 1031;
}
[dir="rtl"] .app-mini-side { left: auto; right: 0; }
.app-mini-side .brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--grad-primary);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1rem;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px rgba(124,58,237,0.4);
}
.app-mini-side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; width: 100%; align-items: center; }
.app-mini-side nav a {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.55);
  font-size: 1.05rem;
  position: relative;
  transition: background .12s, color .12s;
}
.app-mini-side nav a:hover { background: var(--mini-hover); color: #fff; }
.app-mini-side nav a.active { background: var(--mini-hover); color: #fff; }
.app-mini-side nav a.active::before {
  content: ''; position: absolute;
  left: -14px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand-purple); border-radius: 0 3px 3px 0;
}
[dir="rtl"] .app-mini-side nav a.active::before { left: auto; right: -14px; border-radius: 3px 0 0 3px; }
.app-mini-side .foot { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.app-mini-side .foot .avatar {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-amber), var(--brand-pink));
  color: #fff; font-weight: 700; font-size: 0.78rem;
  display: inline-flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.app-mini-side .foot a {
  color: rgba(255,255,255,0.55);
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 0.95rem;
}
.app-mini-side .foot a:hover { background: var(--mini-hover); color: #fff; }

/* Named sidebar */
.app-side {
  position: fixed;
  top: 0; left: 64px; bottom: 0;
  width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  overflow-y: auto;
  z-index: 1030;
}
[dir="rtl"] .app-side { left: auto; right: 64px; border-right: 0; border-left: 1px solid var(--border); }
.app-side .head {
  padding: 0 6px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-2);
}
.app-side .head .org-label {
  font-size: 0.68rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.app-side .head h3 { font-size: 1.05rem; margin-top: 2px; }
.app-side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.app-side nav a:hover { background: var(--bg-page); color: var(--text-1); }
.app-side nav a.active {
  background: rgba(124,58,237,0.08);
  color: var(--brand-purple);
  font-weight: 600;
}
.app-side nav a i { width: 16px; text-align: center; opacity: 0.8; }
.app-side .nav-section {
  padding: 12px 12px 4px;
  font-size: 0.68rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}

/* Main */
.app-main { margin-left: 294px; min-height: 100vh; }
[dir="rtl"] .app-main { margin-left: 0; margin-right: 294px; }

@media (max-width: 991px) {
  .app-mini-side { width: 56px; }
  .app-side { left: 56px; width: 200px; }
  [dir="rtl"] .app-side { right: 56px; }
  .app-main { margin-left: 256px; }
  [dir="rtl"] .app-main { margin-right: 256px; margin-left: 0; }
}

/* =====================================================================
   TOPBAR (app)
   ===================================================================== */
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
}
.app-topbar .title-block h1 { font-size: 1.18rem; letter-spacing: -0.005em; }
.app-topbar .title-block .crumb { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.app-topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
[dir="rtl"] .app-topbar .actions { margin-left: 0; margin-right: auto; }

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn-pd {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 0.85rem; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-1);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.2;
}
.btn-pd:hover { background: var(--bg-page); color: var(--text-1); }
.btn-pd.primary {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}
.btn-pd.primary:hover { background: var(--brand-purple-2); border-color: var(--brand-purple-2); color: #fff; }
.btn-pd.gradient {
  background: var(--grad-primary);
  border-color: transparent; color: #fff;
}
.btn-pd.gradient:hover { filter: brightness(0.97); color: #fff; }
.btn-pd.danger {
  background: var(--brand-red); border-color: var(--brand-red); color: #fff;
}
.btn-pd.danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }
.btn-pd.ghost { background: transparent; border-color: transparent; }
.btn-pd.ghost:hover { background: var(--bg-page); }
.btn-pd.icon-only { padding: 8px 10px; }
.btn-pd.sm { padding: 5px 10px; font-size: 0.78rem; }

/* =====================================================================
   PAGE / CONTENT
   ===================================================================== */
.app-content { padding: 22px 26px 40px; }

.section-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.section-header h2 { font-size: 1.35rem; }
.section-header .sub { color: var(--text-3); font-size: 0.88rem; margin-top: 2px; }

/* Cards */
.card-pd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-pd .card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  flex-wrap: wrap; gap: 10px;
}
.card-pd .card-head h5 { font-size: 1rem; }
.card-pd .card-head .sub { font-size: 0.82rem; color: var(--text-muted); }
.card-pd .card-body { padding: 18px 20px; }
.card-pd .card-body.flush { padding: 0; }

/* =====================================================================
   STAT CARDS (dashboard)
   ===================================================================== */
.stat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 991px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 110px; height: 110px;
  background: var(--grad-primary);
  opacity: 0.06;
  border-radius: 50%;
  transform: translate(40%, -40%);
  pointer-events: none;
}
[dir="rtl"] .stat-card::after { right: auto; left: 0; transform: translate(-40%, -40%); }
.stat-card .label {
  font-size: 0.82rem; color: var(--text-3); font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.stat-card .label .ic {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(124,58,237,0.1); color: var(--brand-purple);
  font-size: 0.92rem;
}
.stat-card .value {
  font-size: 2rem; font-weight: 700; color: var(--text-1);
  letter-spacing: -0.02em; line-height: 1; margin-top: 12px;
}
.stat-card .delta { font-size: 0.78rem; color: var(--text-3); margin-top: 6px; }
.stat-card .delta.up { color: var(--brand-mint); }
.stat-card .delta.down { color: var(--brand-red); }

/* Variants by accent */
.stat-card.green::after { background: var(--grad-mint); }
.stat-card.green .label .ic { background: rgba(16,185,129,0.1); color: var(--brand-mint); }
.stat-card.amber::after { background: linear-gradient(135deg, #F59E0B 0%, #EC4899 100%); }
.stat-card.amber .label .ic { background: rgba(245,158,11,0.1); color: var(--brand-amber); }
.stat-card.red::after { background: linear-gradient(135deg, #EF4444 0%, #EC4899 100%); }
.stat-card.red .label .ic { background: rgba(239,68,68,0.1); color: var(--brand-red); }
.stat-card.blue::after { background: linear-gradient(135deg, #3B82F6 0%, #00D4FF 100%); }
.stat-card.blue .label .ic { background: rgba(59,130,246,0.1); color: var(--brand-blue-2); }

/* =====================================================================
   TABLES
   ===================================================================== */
.table-pd { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table-pd thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
[dir="rtl"] .table-pd thead th { text-align: right; }
.table-pd tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-1);
  vertical-align: middle;
}
.table-pd tbody tr:hover { background: var(--surface-2); }
.table-pd tbody tr:last-child td { border-bottom: 0; }
.table-pd .actions-cell { white-space: nowrap; text-align: right; }
[dir="rtl"] .table-pd .actions-cell { text-align: left; }
.table-pd .actions-cell .btn-pd { margin-left: 4px; }

/* Pills (status badges) */
.pd-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.pd-pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.pd-pill-ok      { background: rgba(16,185,129,0.1);  color: var(--brand-mint); }
.pd-pill-warn    { background: rgba(245,158,11,0.1);  color: var(--brand-amber); }
.pd-pill-danger  { background: rgba(239,68,68,0.1);   color: var(--brand-red); }
.pd-pill-info    { background: rgba(59,130,246,0.1);  color: var(--brand-blue-2); }
.pd-pill-muted   { background: rgba(110,115,132,0.1); color: var(--text-3); }
.pd-pill-purple  { background: rgba(124,58,237,0.1);  color: var(--brand-purple); }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty .em-icon {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--bg-page);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--text-muted);
  margin-bottom: 12px;
}

/* =====================================================================
   FORMS
   ===================================================================== */
.form-pd .form-label {
  font-weight: 600; color: var(--text-1); font-size: 0.82rem;
  margin-bottom: 5px; display: block;
}
.form-pd .form-control,
.form-pd .form-select {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 0.9rem;
  width: 100%;
  background: var(--surface);
}
.form-pd .form-control:focus,
.form-pd .form-select:focus {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 4px rgba(124,58,237,0.1);
  outline: 0;
}
.form-pd textarea.form-control { min-height: 90px; }
.form-pd .form-text { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }
.form-pd .form-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 575px) { .form-pd .form-grid { grid-template-columns: 1fr; } }
.form-pd .form-grid .full { grid-column: 1 / -1; }

/* ----- Form tabs (inside modals) ----- */
.form-tabs {
  border-bottom: 1px solid var(--border-1);
  flex-wrap: wrap;
  gap: 2px;
}
.form-tabs .nav-item { margin-bottom: -1px; }
.form-tabs .nav-link {
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.form-tabs .nav-link:hover {
  color: var(--brand-purple);
  background: rgba(124, 58, 237, 0.05);
  border-color: transparent;
}
.form-tabs .nav-link.active {
  color: var(--brand-purple);
  background: #fff;
  border-color: var(--border-1) var(--border-1) #fff;
  font-weight: 600;
}
.form-tabs .nav-link i { font-size: 0.95rem; }
body[dir="rtl"] .form-tabs .nav-link { padding: 9px 14px; }

/* ----- Network Map: force LTR direction on SVG diagrams -----
   When the page is in RTL, SVG inherits direction:rtl which breaks
   text-anchor and dx positioning and reorders <tspan> sequences. We
   isolate diagrams to LTR so geometry stays predictable. */
body[data-page="network_map"] svg,
body[data-page="network_map"] svg text,
body[data-page="network_map"] svg tspan {
  direction: ltr;
  unicode-bidi: isolate;
}

/* =====================================================================
   ALERTS / FLASH
   ===================================================================== */
.flash-stack { position: fixed; top: 76px; right: 26px; z-index: 1050; display: flex; flex-direction: column; gap: 8px; }
[dir="rtl"] .flash-stack { right: auto; left: 26px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 0.88rem; font-weight: 500;
  border: 1px solid;
  background: var(--surface);
  box-shadow: var(--sh-md);
  max-width: 360px;
}
.flash.success { color: var(--brand-mint); border-color: rgba(16,185,129,0.4); }
.flash.error   { color: var(--brand-red);  border-color: rgba(239,68,68,0.4); }
.flash.warn    { color: var(--brand-amber); border-color: rgba(245,158,11,0.4); }
.flash.info    { color: var(--brand-blue-2); border-color: rgba(59,130,246,0.4); }

/* =====================================================================
   TOOLBAR (search + filters above tables)
   ===================================================================== */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
}
.toolbar .form-control,
.toolbar .form-select {
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  padding: 8px 12px; font-size: 0.85rem;
  background: var(--surface);
}
.toolbar .form-control:focus { border-color: var(--brand-purple); box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }
.toolbar .toolbar-spacer { flex: 1; }

/* =====================================================================
   MODAL polish
   ===================================================================== */
.modal-content {
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border-2);
  padding: 16px 20px;
}
.modal-header .modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top: 1px solid var(--border-2); padding: 12px 20px; }

/* =====================================================================
   Lang switcher
   ===================================================================== */
.lang-switch {
  display: inline-flex; gap: 0;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
}
.lang-switch a {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-3);
}
.lang-switch a.active { background: var(--surface); color: var(--brand-purple); box-shadow: var(--sh-sm); }

/* =====================================================================
   Pagination
   ===================================================================== */
.pager {
  display: flex; gap: 4px; align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--border-2);
  background: var(--surface);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.pager .info { color: var(--text-3); font-size: 0.82rem; }
.pager .pager-spacer { flex: 1; }
.pager a, .pager span {
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.82rem;
}
.pager a:hover { background: var(--bg-page); color: var(--text-1); }
.pager .active { background: var(--brand-purple); border-color: var(--brand-purple); color: #fff; }
.pager .disabled { color: var(--text-muted); pointer-events: none; }

/* =====================================================================
   Misc
   ===================================================================== */
.text-muted { color: var(--text-3) !important; }
.text-mute2 { color: var(--text-muted) !important; }
.divider { height: 1px; background: var(--border-2); margin: 14px 0; }
.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: var(--bg-page);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Mobile menu burger */
.app-burger {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  color: var(--text-1);
}
@media (max-width: 767px) {
  .app-burger { display: inline-flex; }
  .app-mini-side, .app-side { transform: translateX(-110%); transition: transform .25s; }
  [dir="rtl"] .app-mini-side, [dir="rtl"] .app-side { transform: translateX(110%); }
  .app-mini-side.open, .app-side.open { transform: translateX(0); }
  .app-main { margin-left: 0 !important; margin-right: 0 !important; }
  .app-content { padding: 16px; }
}

/* Print helpers */
@media print {
  .app-mini-side, .app-side, .app-topbar, .actions, .btn-pd { display: none !important; }
  .app-main { margin-left: 0 !important; margin-right: 0 !important; }
  .card-pd { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------- Dashboard extras ---------- */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.activity-feed { list-style: none; padding: 0; margin: 0; }
.activity-feed li {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-1);
}
.activity-feed li:last-child { border-bottom: 0; }
.activity-feed .dot {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(0,212,255,0.12));
  color: var(--brand-purple);
  font-size: 0.95rem;
}

/* Tabs (used in cybersecurity / settings) */
.pd-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 18px;
}
.pd-tabs a {
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.18s ease;
}
.pd-tabs a:hover { color: var(--brand-purple); }
.pd-tabs a.active {
  color: var(--brand-purple);
  border-bottom-color: var(--brand-purple);
}

/* Severity color overrides for pills (info=blue, purple variant) */
.pd-pill-purple {
  background: rgba(124,58,237,0.12);
  color: var(--brand-purple);
}

/* Modal polish for forms */
.modal .modal-content {
  border-radius: 16px;
  border: 0;
  box-shadow: 0 24px 56px rgba(15,11,46,0.16);
}
.modal .modal-header {
  border-bottom: 1px solid var(--border-1);
  padding: 18px 22px;
}
.modal .modal-header .modal-title {
  font-weight: 700;
  font-size: 1.05rem;
}
.modal .modal-body { padding: 20px 22px; }

/* ----- Modal scrolling fix -----
   Make the modal content a flex column so the body grows and scrolls between
   the fixed header and footer. Works for both centered and top-aligned dialogs.
*/
.modal-dialog {
  max-height: calc(100vh - 1rem);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
.modal-content {
  max-height: calc(100vh - 1rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-content .modal-header,
.modal-content .modal-footer {
  flex-shrink: 0;
}
.modal-content .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.modal .modal-footer {
  border-top: 1px solid var(--border-1);
  padding: 14px 22px;
}

/* Stat label/value/meta — semantic class names used in dashboard */
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--text-1); margin-top: 6px; line-height: 1.05; }
.stat-card .stat-meta  { font-size: 0.78rem; color: var(--text-3); margin-top: 8px; }
.stat-card .stat-meta i { color: var(--brand-purple); margin-right: 4px; }

/* Card head / card body wrappers used by module pages */
.card-pd .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-pd .card-head h5 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.card-pd .card-head h5 i { color: var(--brand-purple); }
.card-pd .card-body-pd { padding: 18px 20px; }
.card-pd .card-body-pd.p-0 { padding: 0; }

/* Filter pills */
.filter-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pills a {
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-page);
  color: var(--text-2);
  border: 1px solid var(--border-1);
}
.filter-pills a.active {
  background: var(--brand-purple);
  color: #fff;
  border-color: var(--brand-purple);
}
