*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: #0d1b2a;
  color: #e8eaf0;
  min-height: 100vh;
}

/* ── Auth gate ─────────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  color: #fff;
  padding: 40px;
}

.gate h2 { font-size: 20px; font-weight: 600; }
.gate p  { font-size: 14px; color: rgba(255,255,255,0.6); }

.signin-btn {
  margin-top: 8px;
  padding: 11px 36px;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.signin-btn:hover { background: #0077ed; }

.gate-back {
  margin-top: 4px;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  text-decoration: none;
}
.gate-back:hover { color: #fff; }

/* ── Header ────────────────────────────────────────────── */

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 90px;
  background-image: url("../Images/header.png");
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-link { text-decoration: none; color: inherit; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 75px;
  width: auto;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.brand-tagline {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ── Nav ───────────────────────────────────────────────── */

.dash-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-link {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-link:hover { color: #fff; }
.nav-link.active {
  color: #4ade80;
  font-weight: 600;
}

.refresh-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  line-height: 1;
}
.refresh-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Main layout ───────────────────────────────────────── */

main {
  padding: 14px 28px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.last-updated {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
}

/* ── KPI strip (4 cols) ────────────────────────────────── */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 12px 20px;
  text-align: center;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #4ade80;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.50);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Filter bar ────────────────────────────────────────── */

.filter-bar {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.filter-select {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  color: #e8eaf0;
  font-size: 13px;
  font-family: inherit;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  min-width: 160px;
}
.filter-select:focus { border-color: rgba(255,255,255,0.28); }
.filter-select option { background: #1a2d42; }

.filter-checks {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255,255,255,0.70);
  cursor: pointer;
  user-select: none;
}

.filter-check-label input[type="checkbox"] {
  accent-color: #4ade80;
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.filter-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.10);
}

/* ── Graph + drawer wrapper ────────────────────────────── */

.graph-layout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* ── Graph panel ───────────────────────────────────────── */

.graph-panel {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.panel-sub {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.40);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.focus-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.focus-reset-btn {
  background: rgba(74,222,128,0.12);
  border: 1px solid rgba(74,222,128,0.30);
  color: #4ade80;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.focus-reset-btn:hover { background: rgba(74,222,128,0.22); }

.graph-container {
  width: 100%;
  height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0,0,0,0.20);
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
}

.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: rgba(255,255,255,0.30);
}

/* ── Legend ─────────────────────────────────────────────── */

.graph-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.60);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot.Rule     { background: #4ade80; }
.legend-dot.Decision { background: #60a5fa; }
.legend-dot.Code     { background: #fbbf24; }
.legend-dot.Note     { background: #a78bfa; }

/* ── Node detail drawer ────────────────────────────────── */

.node-drawer {
  width: 320px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 20px 20px;
  display: none;
  flex-direction: column;
  gap: 14px;
  align-self: flex-start;
}

.node-drawer.open {
  display: flex;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.40);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.drawer-close:hover { color: #fff; }

.drawer-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.drawer-badge.Rule     { background: rgba(74,  222, 128, 0.18); color: #4ade80; border: 1px solid rgba(74,  222, 128, 0.35); }
.drawer-badge.Decision { background: rgba(96,  165, 250, 0.18); color: #60a5fa; border: 1px solid rgba(96,  165, 250, 0.35); }
.drawer-badge.Code     { background: rgba(251, 191,  36, 0.18); color: #fbbf24; border: 1px solid rgba(251, 191,  36, 0.35); }
.drawer-badge.Note     { background: rgba(167, 139, 250, 0.18); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.35); }

.drawer-content {
  font-size: 13px;
  color: #d0d4e0;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.drawer-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
}

.drawer-connections {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-conn-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.40);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.drawer-conn-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: rgba(255,255,255,0.60);
}

.drawer-conn-arrow {
  font-size: 10px;
  color: rgba(255,255,255,0.30);
}

/* ── Lower analytics row ───────────────────────────────── */

.lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Tables ────────────────────────────────────────────── */

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dash-table thead th {
  padding: 5px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

.dash-table tbody td {
  padding: 6px 8px;
  color: #d0d4e0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}

.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover td { background: rgba(255,255,255,0.03); }

.table-empty {
  text-align: center;
  color: rgba(255,255,255,0.30);
  padding: 24px 0 !important;
}

/* ── Badges ────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1100px) {
  .node-drawer { width: 280px; }
}

@media (max-width: 900px) {
  .graph-layout { flex-direction: column; }
  .node-drawer { width: 100%; }
  .lower-grid { grid-template-columns: 1fr; }
  .kpi-strip  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  main { padding: 16px 16px 40px; }
  .dash-header { padding: 0 16px; height: 72px; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 28px; }
  .graph-container { height: 400px; }
}
