/* ── CSS Variables ── */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #dde3ec;
  --text-primary: #1a1f3a;
  --text-secondary: #5a6280;
  --text-muted: #9aa0b8;
  --accent: #362680;
  --accent-light: #eceeff;
  --accent2: #00c2e0;
  --accent2-light: #e0fafd;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --critical: #7f1d1d;
  --critical-bg: #fecaca;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --orange: #ea580c;
  --orange-bg: #ffedd5;
  --yellow: #ca8a04;
  --yellow-bg: #fef9c3;
  --chart-line: #362680;
  --chart-fill-start: rgba(54, 38, 128, 0.15);
  --chart-fill-end: rgba(54, 38, 128, 0.01);
  --chart-avg: rgba(0, 194, 224, 0.5);
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ── Reset ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
}

/* ── Base ── */
body {
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

canvas {
  width: 100% !important;
}

/* ── Error Toast ── */
.error-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-primary);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-width: calc(100vw - 32px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.error-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Offline Banner ── */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--orange);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 9px 16px;
  line-height: 1.4;
}
.offline-banner.show { display: flex; }
.offline-banner svg { flex-shrink: 0; }

/* ── Screens ── */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(240, 242, 245, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  gap: 16px;
}
.loading-overlay .big-spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid rgba(54, 38, 128, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-overlay p {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Freshness badge ── */
.freshness-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.freshness-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
  margin-bottom: 12px;
}

/* ── Logo ── */
.logo-img {
  display: block;
  height: auto;
  width: auto;
  max-width: 100%;
}
.cylo-logo .logo-img { height: 32px; }

/* ── Page layout ── */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px 48px;
}
.page-top {
  padding: 16px 0 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.page-top-left {
  flex: 1;
  min-width: 0;
}
.page-top-title {
  font-family: 'Rubik', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  color: var(--accent);
}
.page-top-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.page-top-title-row .page-top-title { margin-bottom: 0; }
.page-top-desc {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.6;
}
.page-top-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.page-top-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.policy-switcher-wrap { flex-shrink: 0; min-width: 0; max-width: 100%; }
.page-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 7px;
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.15s;
}
.btn:hover { background: var(--bg); }
.btn svg { width: 13px; height: 13px; opacity: 0.7; }
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: #302272; }

/* ── Page views ── */
.page-view { display: none; }
.page-view.active { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .offline-banner { font-size: 13px; padding: 10px 14px; }
  .cylo-logo .logo-img { height: 34px; }
  .topbar { padding: 0 12px; }
  /* .page-top { flex-direction: column; gap: 10px; } */
  .page-top-title { font-size: 20px; }
  .page-top-title-row { flex-wrap: wrap; row-gap: 8px; }
  .page-top-desc  { font-size: 14px; }
  .page-top-link  { font-size: 14px; }
  .btn { font-size: 14px; padding: 8px 14px; }
  .btn svg { width: 15px; height: 15px; }
}
@media (max-width: 480px) {
  .cylo-logo .logo-img { height: 32px; }
}

@media print {
  body { background: #fff; font-size: 11px; }

  .topbar,
  .mobile-nav-drawer,
  .filter-bar,
  .page-top-actions,
  .time-tabs,
  .loading-overlay { display: none !important; }

  .screen { display: block !important; min-height: unset; }
  #loginScreen, #otpScreen { display: none !important; }
  #dashboardScreen { display: block !important; }

  .page { max-width: 100%; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #dde3ec; }
  .top-grid { grid-template-columns: 1fr 1fr; }
  .chart-wrap { height: 160px; }

  .page-top-title::before {
    content: "CYLO Cyber Risk Profile — ";
  }
}

/* Sits as a third flex child between the existing left and right groups.
   If .topbar-left / .topbar-right are flex:1 in your actual CSS (not
   confirmed — I don't have that file), this may need adjusting so the
   center group doesn't get squeezed unevenly; flex-shrink here is a
   defensive default, not a guarantee against that. */
/* .topbar already has position:sticky, which — same as position:relative
   — establishes a containing block for this absolutely-positioned child,
   so no extra positioning rule is needed on .topbar itself. Centered on
   the FULL bar width via left:50%, independent of how wide .topbar-left
   or .topbar-right's content happens to be. */
.topbar-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  pointer-events: none; /* wrapper itself shouldn't block clicks reaching neighbors if it ever visually overlaps them */
}
.topbar-center .policy-switcher-select {
  pointer-events: auto; /* the actual control still needs to be clickable */
}
 
.policy-switcher-select {
  appearance: none;
  -webkit-appearance: none;
  width: auto;
  max-width: 100%;
  height: 28px;
  padding: 0 4px 0 12px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 28px;
  color: var(--text-primary);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23362680' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 13px;
  cursor: pointer;
  text-overflow: ellipsis;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.policy-switcher-select:hover {
  background-color: var(--bg);
}
.policy-switcher-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(82, 60, 176, 0.12);
}
 
/* Tight mobile viewports — same screenshot constraint as before (logo +
   subtext, avatar, hamburger, no slack). Shrinks rather than disappears,
   per "middle on both mobile and desktop." */
/* Below 768px, .nav-tabs disappears entirely (moves into the hamburger
   drawer) while .avatar-btn grows to 38px and .hamburger-btn to 40px —
   so matching nav-tab height no longer applies here; sized closer to
   those instead so it doesn't look undersized next to them. */
@media (max-width: 480px) {
  .policy-switcher-select {
    height: 34px;
    line-height: 34px;
    padding: 0 4px 0 10px;
    font-size: 11px;
  }
}
 
/* The policy switcher now lives inline in the dashboard page-top, so no
   extra narrow-screen hiding is needed — it simply shrinks per the
   .policy-switcher-select rule above. */