/* ============================================================
   ESCSEC NEXA — ISO 27001:2022 Dashboard Stylesheet
   Layout: Sidebar + Topbar + Multi-page SPA
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --corporate-blue: #2563eb;
  --corporate-blue-dark: #1d4ed8;
  --corporate-navy: #1e3a8a;
  --bg-app: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --orange: #d97706;
  --orange-bg: #fef3c7;
  --green: #059669;
  --green-bg: #d1fae5;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   APP SHELL — Sidebar Layout
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--corporate-blue);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 14px;
  color: #f1f5f9;
  display: block;
  letter-spacing: -0.2px;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  font-weight: 500;
  display: block;
  letter-spacing: 0.3px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  padding: 8px 16px 4px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(37,99,235,0.2);
  color: #93c5fd;
  border-left-color: var(--corporate-blue);
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-item.active .sidebar-icon { opacity: 1; }

.sidebar-badge {
  margin-left: auto;
  background: rgba(37,99,235,0.3);
  color: #93c5fd;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Footer / User */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--corporate-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  display: block;
}

.sidebar-user-role {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  display: block;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.btn-sidebar-logout {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 5px;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.btn-sidebar-logout:hover {
  background: rgba(220,38,38,0.2);
  color: #fca5a5;
  border-color: rgba(220,38,38,0.3);
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 0.25s ease;
}

.main-area.expanded {
  margin-left: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}

.topbar-page-title h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-page-title span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-sync {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.status-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.2);
  animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 3px rgba(5,150,105,0.2); }
  50% { box-shadow: 0 0 0 5px rgba(5,150,105,0.05); }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  border: none;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-primary { background: var(--corporate-blue); color: #fff; }
.btn-primary:hover { background: var(--corporate-blue-dark); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }

.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid #fca5a5;
}
.btn-danger-outline:hover { background: var(--red-bg); }

.icon { width: 15px; height: 15px; flex-shrink: 0; }
.icon-sm { width: 13px; height: 13px; flex-shrink: 0; }

.compliance-badge {
  background: #d1fae5;
  color: #065f46;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid #6ee7b7;
  white-space: nowrap;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

.page { display: block; }
.page.hidden { display: none; }

/* ============================================================
   KPI CARDS — Fixed equal height/width
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 140px;
  overflow: hidden;
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border-light);
}

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.kpi-icon {
  font-size: 16px;
  line-height: 1;
}

.kpi-card-body {
  flex: 1;
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kpi-big-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-sub-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.kpi-foot {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
}

/* Gauge Card */
.kpi-gauge-body {
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.gauge-wrapper {
  flex-shrink: 0;
}

.gauge-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 6px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #fff;
}

.gauge-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.gauge-meta { flex: 1; min-width: 0; }

.gauge-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 3px;
  line-height: 1.3;
}

.gauge-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* SLA Card */
.sla-list { margin-bottom: 8px; }

.sla-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}

.sla-type { color: var(--text-secondary); font-weight: 500; }
.sla-val { font-weight: 700; font-size: 11px; }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-yellow { color: #b45309; }

/* Status Pills */
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.active-pill { background: #d1fae5; color: #065f46; }
.disc-pill { background: #f1f5f9; color: var(--text-secondary); }

/* Severity Badges */
.badge-crit { background: #fee2e2; color: #991b1b; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-high { background: #fef3c7; color: #92400e; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-med  { background: #dbeafe; color: #1e40af; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.panel-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.panel-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-wrap {
  padding: 16px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.bar-wrap {
  min-height: 200px;
}

.donut-wrap canvas { max-width: 220px; max-height: 220px; }
.bar-wrap canvas { max-height: 220px; width: 100% !important; }

/* ============================================================
   GROUPS STRIP
   ============================================================ */










/* ============================================================
   PIPELINE
   ============================================================ */
.pipeline-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-top: 1px solid var(--border-light);
}

.pipeline-card {
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border-light);
  position: relative;
}

.pipeline-card:last-child { border-right: none; }

.pipeline-card:hover { background: #f8fafc; }

.pipeline-card.active-filter {
  background: #eff6ff;
  border-bottom: 2px solid var(--corporate-blue);
}

.pipe-indicator {
  width: 28px;
  height: 3px;
  border-radius: 2px;
}

.pipe-all { background: #94a3b8; }
.pipe-open { background: var(--red); }
.pipe-inprogress { background: var(--orange); }
.pipe-resolved { background: var(--green); }
.pipe-accepted { background: #94a3b8; }

.pipe-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipe-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipe-count {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.pipe-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text-secondary);
  width: fit-content;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-panel-header {
  flex-wrap: wrap;
  gap: 12px;
}

.table-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.custom-select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  background: #fff;
  outline: none;
  cursor: pointer;
}

.custom-select:focus { border-color: var(--corporate-blue); }

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table thead { background: #f8fafc; }

.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.text-center { text-align: center; }
.py-5 { padding-top: 40px; padding-bottom: 40px; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }

/* Table cells */
.asset-name-cell { font-weight: 700; color: var(--text-primary); }
.asset-name-cell small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }

.badge-risk {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.risk-CRITICAL { background: #fee2e2; color: #991b1b; }
.risk-HIGH { background: #fef3c7; color: #92400e; }
.risk-MEDIUM { background: #dbeafe; color: #1e40af; }
.risk-LOW { background: #d1fae5; color: #065f46; }
.risk-NONE { background: #f1f5f9; color: #64748b; }

.sla-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}

.sla-overdue { background: #fee2e2; color: #991b1b; }
.sla-action { background: #fef3c7; color: #92400e; }
.sla-scheduled { background: #dbeafe; color: #1e40af; }
.sla-compliant { background: #d1fae5; color: #065f46; }

.treatment-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.t-OPEN { background: #fee2e2; color: #991b1b; }
.t-IN_PROGRESS { background: #fef3c7; color: #92400e; }
.t-RESOLVED { background: #d1fae5; color: #065f46; }
.t-RISK_ACCEPTED { background: #f1f5f9; color: #64748b; }

.btn-detail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--corporate-blue);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-detail:hover {
  background: var(--corporate-blue);
  color: #fff;
  border-color: var(--corporate-blue);
}

/* ============================================================
   REMEDIATION STATS (Matching Dashboard KPI Card Design)
   ============================================================ */
.remediation-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 18px;
}

.rem-kpi-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.rem-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.rem-kpi-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  line-height: 1.4;
}

.rem-kpi-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Status Variations */
.rem-kpi-open .rem-kpi-tag {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.rem-kpi-open .rem-kpi-icon-wrap {
  background: #fee2e2;
  color: #dc2626;
}
.rem-kpi-open:hover {
  border-color: #fecaca;
}

.rem-kpi-progress .rem-kpi-tag {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.rem-kpi-progress .rem-kpi-icon-wrap {
  background: #fef3c7;
  color: #d97706;
}
.rem-kpi-progress:hover {
  border-color: #fde68a;
}

.rem-kpi-resolved .rem-kpi-tag {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}
.rem-kpi-resolved .rem-kpi-icon-wrap {
  background: #d1fae5;
  color: #059669;
}
.rem-kpi-resolved:hover {
  border-color: #a7f3d0;
}

.rem-kpi-accepted .rem-kpi-tag {
  background: #eef2ff;
  color: #4f46e5;
  border: 1px solid #c7d2fe;
}
.rem-kpi-accepted .rem-kpi-icon-wrap {
  background: #e0e7ff;
  color: #4f46e5;
}
.rem-kpi-accepted:hover {
  border-color: #c7d2fe;
}


/* ============================================================
   GLOBAL SVG ICON SIZE CONSTRAINTS
   ============================================================ */
.header-svg-icon {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

.section-title-with-icon {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.kpi-icon svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
}
