/* ============================================================
   EEP — Electrical Engineering Platform Design System v5.0
   Engineering-grade UI — NEC 2023 / CEC 2024 Compliance
   Table-first, dense dashboard, deterministic trace output
   ============================================================ */

:root {
  /* Typography */
  --font-ui: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;

  /* Surface */
  --page-bg:    #f4f6f9;   /* cool grey — engineering workbench */
  --white:      #ffffff;
  --surface-2:  #f0f3f7;   /* secondary surface */
  --surface-3:  #e8ecf2;   /* tertiary surface */

  /* Brand */
  --navy-950:   #060f1c;   /* deepest — sidebar, headers */
  --navy-900:   #0c1d35;
  --navy-800:   #0f2545;
  --navy-700:   #14305a;
  --blue-700:   #0b55c8;   /* primary action */
  --blue-650:   #1268e8;
  --blue-600:   #1c78f5;
  --blue-500:   #3d8eff;
  --blue-75:    #eef4ff;   /* hover tint */

  /* Text */
  --text-950:   #0b1929;
  --text-850:   #162542;
  --text-700:   #3a4b65;
  --text-600:   #50637c;
  --text-500:   #6d839e;
  --text-400:   #8fa4bc;

  /* Lines */
  --line:       #dae0ea;
  --line-soft:  #eaeff6;
  --line-hard:  #c8d2df;

  /* Status — engineering indicators */
  --status-pass:    #1a7a4d;
  --status-pass-bg: #eaf6f0;
  --status-fail:    #c0392b;
  --status-fail-bg: #fdf0ef;
  --status-warn:    #b35b00;
  --status-warn-bg: #fff3e0;
  --status-nc:      #6a1b9a;   /* NOT COMPLIANT */
  --status-nc-bg:   #f5edff;
  --status-info:    #0b55c8;
  --status-info-bg: #eef4ff;

  /* Semantic colors */
  --green:        #1a7a4d;
  --green-light:  #eaf6f0;
  --orange:       #b35b00;
  --orange-light: #fff3e0;
  --red:          #c0392b;
  --red-light:    #fdf0ef;

  /* Shadows */
  --shadow-soft: 0 2px 8px rgba(11, 25, 55, 0.06), 0 1px 2px rgba(11, 25, 55, 0.04);
  --shadow-card: 0 4px 16px rgba(11, 25, 55, 0.08);
  --shadow-blue: 0 8px 24px rgba(12, 104, 232, 0.20);

  /* Layout */
  --sidebar-width:  228px;
  --sidebar-bg:     #060f1c;   /* near-black — serious engineering tool */
  --topbar-height:  52px;
  --topbar-bg:      #ffffff;
  --border-radius:  6px;        /* tighter radius = more engineering, less SaaS */
  --border-radius-sm: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -0.01em;
  background: var(--page-bg);
  color: var(--text-950);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ─── APP SHELL ─── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.brand-logo {
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.09em;
  line-height: 1;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.22);
  flex-shrink: 0;
}

.brand-subtitle {
  color: #9fc3f5;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  margin: 1px 8px;
  color: rgba(255,255,255,0.62);
  font-size: 12px;
  font-weight: 500;
  transition: background 150ms, color 150ms;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.88);
}

.nav-item.active {
  background: rgba(45, 134, 255, 0.18);
  color: #fff;
}

.nav-item.active .nav-icon { color: var(--blue-500); }

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.nav-sub-item {
  display: block;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  border-radius: 5px;
  margin: 1px 0;
  transition: background 130ms, color 130ms;
}
.nav-sub-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.8); }
.nav-sub-item.active { color: #fff; font-weight: 600; background: rgba(45,134,255,0.15); }

/* ─── FREE TOOLS DROPDOWN ──────────────────────────────────────────── */
.free-tools-section {
  /* Full-width band so no margin slivers reveal page bg under sidebar */
  margin: 0;
  padding: 8px 8px 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.7);
}
.free-tools-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font: 700 10px/1 inherit;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 6px;
  transition: background 150ms, color 150ms;
}
.free-tools-header:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.85); }
.free-tools-header > span:nth-child(2) {
  flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.free-tools-count {
  background: rgba(16,185,129,0.18); color: #34d399;
  padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em;
}
.free-tools-chevron {
  font-size: 10px; color: rgba(255,255,255,0.4);
  transition: transform 200ms ease;
}
.free-tools-section.is-open .free-tools-chevron { transform: rotate(180deg); color: #34d399; }
.free-tools-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 280ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0 0 0 6px;
  background: var(--sidebar-bg);
}
.free-tools-section.is-open .free-tools-body {
  max-height: 600px;        /* tall enough for all tools, scrolls inside .sidebar if longer */
  padding: 4px 0 6px 6px;
}
.free-tools-body .nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.62);
  border-radius: 5px;
}
.free-tools-body .nav-sub-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
}
.free-tools-body .nav-sub-item .free-tag {
  margin-left: auto;
  font-size: 8px; font-weight: 800; letter-spacing: 0.04em;
  background: rgba(16,185,129,0.15); color: #34d399;
  padding: 1px 5px; border-radius: 3px;
  white-space: nowrap;
}

.sidebar-project {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.project-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.project-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.project-pill-name {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-pill-num {
  color: rgba(255,255,255,0.38);
  font-size: 9px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.user-name {
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  color: rgba(255,255,255,0.4);
  font-size: 9px;
}

/* ─── MAIN ─── */

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── TOPBAR ─── */

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  z-index: 30;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
}

.topbar-breadcrumb a {
  color: var(--text-500);
  font-size: 12px;
  font-weight: 500;
}

.topbar-breadcrumb a:hover { color: var(--blue-700); }

.breadcrumb-sep {
  color: var(--text-500);
  font-size: 11px;
}

.topbar-title {
  color: var(--text-950);
  font-size: 14px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
}

.topbar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.topbar-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-600);
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}

.topbar-icon-btn:hover {
  background: var(--blue-75);
  border-color: #c5d9f5;
  color: var(--blue-700);
}

.topbar-icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ─── BUTTONS ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 150ms, box-shadow 150ms, background 150ms;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  box-shadow: var(--shadow-blue);
}

.btn-secondary {
  color: var(--blue-700);
  background: white;
  border-color: #bcd2f3;
  box-shadow: 0 4px 12px rgba(15,38,77,0.05);
}

.btn-ghost {
  color: var(--text-600);
  background: transparent;
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--blue-75);
  color: var(--blue-700);
  border-color: #c5d9f5;
}

.btn-danger {
  color: var(--red);
  background: var(--red-light);
  border-color: #f5c6c6;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ─── CARDS ─── */

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.card-title {
  color: var(--text-850);
  font-size: 13px;
  font-weight: 700;
}

.card-body { padding: 18px; }

/* ─── STAT CARDS ─── */

.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
}

.stat-label {
  color: var(--text-500);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.stat-value {
  color: var(--text-950);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-sub {
  color: var(--text-500);
  font-size: 10px;
  font-weight: 500;
}

.stat-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--blue-75);
  border: 1px solid #cfe0f8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-700);
  margin-bottom: 10px;
}

.stat-icon-wrap svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ─── BADGES ─── */

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-blue { background: var(--blue-75); color: var(--blue-700); border: 1px solid #cde0ff; }
.badge-green { background: var(--green-light); color: #0e7a50; border: 1px solid #b8ead8; }
.badge-orange { background: var(--orange-light); color: var(--orange); border: 1px solid #f5d8a0; }
.badge-red { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c6; }
.badge-gray { background: #f4f7fb; color: var(--text-600); border: 1px solid var(--line); }

/* ── Engineering compliance status badges ─────────────────────────────
   Use these for validation results, compliance checks, rule outcomes.
   Style: monospace uppercase, pill with left-border accent.
───────────────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--border-radius-sm);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono), var(--font-ui);
  white-space: nowrap;
}

.status-badge.pass {
  background: var(--status-pass-bg);
  color: var(--status-pass);
  border: 1px solid #b5dfc8;
  border-left: 3px solid var(--status-pass);
}
.status-badge.fail {
  background: var(--status-fail-bg);
  color: var(--status-fail);
  border: 1px solid #f0b8b4;
  border-left: 3px solid var(--status-fail);
}
.status-badge.warning {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid #f5cfa0;
  border-left: 3px solid var(--status-warn);
}
.status-badge.not-compliant {
  background: var(--status-nc-bg);
  color: var(--status-nc);
  border: 1px solid #d8b4fe;
  border-left: 3px solid var(--status-nc);
}
.status-badge.info {
  background: var(--status-info-bg);
  color: var(--status-info);
  border: 1px solid #bdd2f8;
  border-left: 3px solid var(--status-info);
}

/* Engineering dot indicators (inline in tables) */
.eng-dot { display:inline-block; width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.eng-dot.pass    { background: var(--status-pass); }
.eng-dot.fail    { background: var(--status-fail); }
.eng-dot.warning { background: var(--status-warn); }
.eng-dot.nc      { background: var(--status-nc);   }

/* Compliance result row highlighting */
tbody tr.result-pass    td { background: rgba(26,122,77,0.03); }
tbody tr.result-fail    td { background: rgba(192,57,43,0.04); }
tbody tr.result-warning td { background: rgba(179,91,0,0.04);  }

/* Code rule reference chip (TraceStep) */
.rule-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: #f0f4f8;
  border: 1px solid var(--line-hard);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono), monospace;
  color: var(--text-600);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.rule-ref.cec { border-color: #a5d6a7; color: #1b5e20; background: #f1f8f2; }
.rule-ref.nec { border-color: #90caf9; color: #0d47a1; background: #f0f6fd; }

/* ─── TABLES ─── */

.table-wrap {
  overflow-x: auto;
  border-radius: 11px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  background: #f8fafd;
  color: var(--text-500);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-700);
  font-size: 12px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: #fafcff; }

/* ─── PROGRESS BAR ─── */

.progress-bar {
  height: 4px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-700), var(--blue-500));
  border-radius: 999px;
}

/* ─── FORM ELEMENTS ─── */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  color: var(--text-700);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text-950);
  font-size: 13px;
  transition: border-color 150ms, box-shadow 150ms;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(18,104,232,0.09);
}

.form-input::placeholder { color: var(--text-500); }

/* ─── RIGHT PANEL ─── */

.right-panel {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--line-soft);
  background: white;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-section-title {
  color: var(--text-850);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
}

.panel-row:last-child { border-bottom: 0; }

.panel-row-label { color: var(--text-500); font-weight: 500; }
.panel-row-value { color: var(--text-950); font-weight: 600; }
.panel-row-value.blue { color: var(--blue-700); }

/* ─── PAGE CONTENT ─── */

.page-content {
  flex: 1;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header-left {}

.page-title {
  color: var(--text-950);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.page-subtitle {
  color: var(--text-500);
  font-size: 12px;
  margin-top: 3px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── GRID LAYOUTS ─── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

/* ─── AVATAR STACK ─── */

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
  margin-left: -7px;
  flex-shrink: 0;
}

.avatar:first-child { margin-left: 0; }

.avatar-more {
  background: var(--line-soft);
  color: var(--text-500);
  font-size: 8px;
}

/* ─── TAGS ─── */

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--blue-75);
  color: var(--blue-700);
}

/* ─── SEARCH INPUT ─── */

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--text-500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.search-input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text-950);
  font-size: 12px;
  transition: border-color 150ms, box-shadow 150ms;
}

.search-input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(18,104,232,0.09);
}

/* ─── FOOTER (landing-style footer in app) ─── */

.app-footer {
  margin-top: auto;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 11px;
  color: var(--text-500);
}

/* ─── DONUT CHART ─── */

.donut {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-label {
  position: absolute;
  text-align: center;
}

.donut-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-950);
  letter-spacing: -0.04em;
  display: block;
}

.donut-sub {
  font-size: 9px;
  color: var(--text-500);
  font-weight: 500;
}

/* ─── EMPTY STATE ─── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-500);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  background: var(--blue-75);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  color: var(--blue-700);
}

.empty-state-icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* ─── TOOLTIP ─── */

[data-tip] { position: relative; cursor: help; }

/* ─── RESPONSIVE ─── */

@media (max-width: 1100px) {
  :root { --sidebar-width: 60px; }
  .brand-subtitle, .brand-divider, .nav-section-label,
  .nav-item span, .project-pill-name, .project-pill-num,
  .user-info { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .project-pill { justify-content: center; padding: 8px; }
  .sidebar-user { justify-content: center; padding: 10px 0; }
  .right-panel { width: 240px; }
}

@media (max-width: 768px) {
  .app-main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .right-panel { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}

/* ─── LAYOUT HELPERS ─── */

.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-body {
  padding: 24px 28px;
  flex: 1;
}

.page-header { margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 800; color: var(--text-950); letter-spacing: -0.03em; }
.page-sub { font-size: 12px; color: var(--text-500); margin-top: 3px; }

/* ─── DATA TABLE ─── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  text-align: left;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-500);
  background: var(--page-bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-700);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--blue-75); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════
   EEP EXTENSIONS — Phase 6 Complete
   All additions maintain exact design token compatibility
   with uploaded template (eep-frontend-package_-_very_good.zip)
═══════════════════════════════════════════════════════ */

/* ── Advisory Labels (Rulebook Ch11 §11.2) ── */
.advisory-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
}
.advisory-label.final    { background:#e6f7f1; color:#0b6e43; border:1px solid #b8ead8; }
.advisory-label.advisory { background:#fff4e6; color:#9a3e00; border:1px solid #f5cfa0; }
.advisory-label.review   { background:#fef3c7; color:#92400e; border:1px solid #f5d8a0; }
.advisory-label.draft    { background:var(--blue-75); color:var(--blue-700); border:1px solid #cde0ff; }
.advisory-label.blocked  { background:var(--red-light); color:var(--red); border:1px solid #f5c6c6; }
.advisory-label.prelim   { background:#f5f3ff; color:#6d28d9; border:1px solid #ddd6fe; }

/* ── Professional Review Notice Banner (MANDATORY §15.2) ── */
.review-notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 8px;
  background: #fff4e6; border: 1.5px solid #f5cfa0;
  margin-bottom: 16px;
}
.review-notice-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.review-notice-text strong { color: #9a3e00; font-size: 12px; display: block; margin-bottom: 3px; }
.review-notice-text p { color: #78350f; font-size: 11px; line-height: 1.5; margin: 0; }

/* ── TraceStep Display (Rulebook Ch15) ── */
.trace-container { margin-top: 16px; }
.trace-toggle-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--white);
  color: var(--text-600); font-size: 11.5px; font-weight: 600;
  cursor: pointer; margin-bottom: 10px; transition: all 150ms;
}
.trace-toggle-btn:hover { background: var(--blue-75); color: var(--blue-700); border-color: #cde0ff; }
.trace-step {
  display: flex; gap: 10px; margin-bottom: 8px;
  animation: fadeIn 200ms ease;
}
.trace-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-75); border: 1.5px solid #cde0ff;
  color: var(--blue-700); font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.trace-body {
  flex: 1; background: #fafcff; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 8px 12px;
}
.trace-label { font-size: 11.5px; font-weight: 700; color: var(--text-950); margin-bottom: 3px; }
.trace-formula {
  font-size: 11px; font-family: "Fira Code", "Consolas", monospace;
  background: #f0f4fb; border-radius: 5px; padding: 4px 8px;
  color: var(--text-700); margin-bottom: 4px;
}
.trace-sourceref {
  display: inline-flex; align-items: center; height: 18px;
  padding: 0 7px; border-radius: 3px; font-size: 9.5px;
  font-weight: 700; font-family: monospace; background: var(--blue-75);
  color: var(--blue-700); border: 1px solid #cde0ff;
}
.trace-warning {
  display: flex; gap: 8px; padding: 6px 10px; border-radius: 6px;
  font-size: 11px; margin-top: 4px;
}
.trace-warning.info     { background: var(--blue-75); border: 1px solid #cde0ff; color: var(--blue-700); }
.trace-warning.warning  { background: #fff4e6; border: 1px solid #f5cfa0; color: #92400e; }
.trace-warning.critical { background: var(--red-light); border: 1px solid #f5c6c6; color: var(--red); }
.trace-warning.sgp      { background: #f5f3ff; border: 1px solid #ddd6fe; color: #6d28d9; }

/* ── Overlay Status (Rulebook Ch14) ── */
.overlay-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.overlay-badge.unresolved { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c6; }
.overlay-badge.resolved   { background: var(--green-light); color: #0b6e43; border: 1px solid #b8ead8; }
.overlay-badge.na         { background: var(--line-soft); color: var(--text-500); border: 1px solid var(--line); }
.overlay-card {
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px; background: var(--white);
  transition: border-color 150ms;
}
.overlay-card.blocking { border-color: #f5c6c6; background: #fffafb; }
.overlay-card.resolved { border-color: #b8ead8; }

/* ── Contractor Toolbox ── */
.tool-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; cursor: pointer;
  transition: transform 180ms, box-shadow 180ms, border-color 180ms;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: #cde0ff; }
.tool-icon { font-size: 26px; margin-bottom: 10px; }
.tool-name { font-size: 13px; font-weight: 700; color: var(--text-950); margin-bottom: 4px; }
.tool-desc { font-size: 11px; color: var(--text-500); line-height: 1.45; }

/* ── Form elements ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; color: var(--text-700); font-size: 11px; font-weight: 600; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-input, .form-select, .form-textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--text-950); font-size: 13px;
  font-family: var(--font-ui); outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(18,111,242,0.09);
}
.form-input::placeholder { color: var(--text-500); }
.form-textarea { height: 100px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.form-hint { font-size: 11px; color: var(--text-500); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; }
.form-select { cursor: pointer; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Loading states ── */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white; animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-blue { border-color: rgba(11,94,215,0.2); border-top-color: var(--blue-700); }
.btn-loading { pointer-events: none; opacity: 0.8; }
.skeleton { background: linear-gradient(90deg,#f0f4f8 25%,#e2e8f0 50%,#f0f4f8 75%); background-size: 400px 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 6px; }

/* ── Error/Empty states ── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-950); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; color: var(--text-500); line-height: 1.55; margin-bottom: 20px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 9px; font-size: 12.5px; margin-bottom: 14px; }
.alert-error   { background: var(--red-light); border: 1px solid #f5c6c6; color: #991b1b; }
.alert-success { background: var(--green-light); border: 1px solid #b8ead8; color: #065f46; }
.alert-info    { background: var(--blue-75); border: 1px solid #cde0ff; color: var(--blue-700); }
.alert-warning { background: #fff4e6; border: 1px solid #f5cfa0; color: #92400e; }

/* ── Toast notifications ── */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: var(--white); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(15,38,77,0.15); font-size: 13px; min-width: 260px; animation: slideIn 250ms ease; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue-700); }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 998; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal { background: var(--white); border-radius: 16px; box-shadow: 0 32px 64px rgba(0,0,0,0.22); overflow: hidden; width: 100%; max-width: 520px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 800; color: var(--text-950); }
.modal-close { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: var(--page-bg); cursor: pointer; color: var(--text-500); display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 22px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }

/* ── Voltage system badge ── */
.vsys-badge {
  display: inline-flex; align-items: center; height: 20px;
  padding: 0 8px; border-radius: 4px; font-size: 10px;
  font-weight: 800; font-family: monospace; background: var(--navy-950);
  color: rgba(255,255,255,0.9);
}

/* ── Role badge ── */
.role-badge {
  display: inline-flex; align-items: center; height: 20px;
  padding: 0 8px; border-radius: 99px; font-size: 10px; font-weight: 700;
}
.role-badge.engineer    { background: var(--blue-75); color: var(--blue-700); border: 1px solid #cde0ff; }
.role-badge.contractor  { background: #fff4e6; color: #92400e; border: 1px solid #f5cfa0; }
.role-badge.admin       { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.role-badge.gc-desk     { background: var(--green-light); color: #0b6e43; border: 1px solid #b8ead8; }
.role-badge.free        { background: var(--page-bg); color: var(--text-500); border: 1px solid var(--line); }

/* ── Animations ── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
   Activated via: document.body.classList.toggle('dark-mode')
   Persisted via: localStorage.setItem('eep_theme', 'dark')
   ═══════════════════════════════════════════════════════════════ */
body.dark-mode {
  --page-bg:     #0d1829;
  --white:       #162039;
  --text-950:    #e8edf6;
  --text-850:    #cdd5e4;
  --text-700:    #9aafc9;
  --text-600:    #7a93b5;
  --text-500:    #5c7a9e;
  --line:        #1e2e47;
  --line-soft:   #182338;
  --blue-75:     #0f1e35;
  --sidebar-bg:  #060f1e;
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.35);

  background: var(--page-bg);
  color: var(--text-950);
}

body.dark-mode .card,
body.dark-mode .panel,
body.dark-mode .section-card,
body.dark-mode .sub-card,
body.dark-mode .result-card,
body.dark-mode .info-card {
  background: var(--white);
  border-color: var(--line);
}

body.dark-mode .topbar {
  background: #0d1829;
  border-bottom-color: var(--line);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #0d1829;
  border-color: var(--line);
  color: var(--text-950);
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(23, 111, 242, 0.18);
}

body.dark-mode .table-container table th {
  background: #0d1829;
  border-bottom-color: var(--line);
  color: var(--text-600);
}

body.dark-mode .table-container table td {
  border-bottom-color: var(--line);
  color: var(--text-700);
}

body.dark-mode .table-container table tr:hover td {
  background: rgba(23, 111, 242, 0.06);
}

body.dark-mode .std-badge.cec  { background: #0f2a50; color: #6ab0ff; border-color: #1a4070; }
body.dark-mode .std-badge.nec  { background: #2a1a0a; color: #ffa94d; border-color: #5c360a; }
body.dark-mode .std-badge.both { background: #1a0d2e; color: #c084fc; border-color: #3d1d5e; }

body.dark-mode .btn-outline {
  border-color: var(--line);
  color: var(--text-700);
}
body.dark-mode .btn-outline:hover {
  background: var(--line-soft);
  color: var(--text-950);
}

/* Dark mode toggle button (rendered in topbar) */
.dark-mode-toggle {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-600);
  transition: background 0.15s, color 0.15s;
}
.dark-mode-toggle:hover { background: var(--line-soft); color: var(--text-950); }
body.dark-mode .dark-mode-toggle { color: #fbbf24; }

/* ══════════════════════════════════════════════════════════════════════
   FREEMIUM GATE — Plan-aware access control styles
   Free users see grayed tour mode; paid features unlock by tier
══════════════════════════════════════════════════════════════════════ */

/* Sidebar: tour-mode nav items */
.nav-item-tour {
  opacity: 0.45 !important;
  filter: grayscale(0.6);
  cursor: pointer !important; /* still clickable — shows upgrade modal */
}
.nav-item-tour:hover {
  opacity: 0.65 !important;
  background: rgba(107,114,128,0.08) !important;
}
.nav-item-free {
  color: rgba(255,255,255,0.9) !important;
}
.nav-item-free:hover { background: rgba(16,185,129,0.08) !important; }

/* Locked element state (buttons, inputs, sections) */
.plan-locked {
  opacity: 0.45;
  filter: grayscale(0.7);
  pointer-events: none;
  cursor: not-allowed !important;
  position: relative;
}
.plan-locked:disabled { cursor: not-allowed; }

/* Freemium tour banner at top of main content */
.eep-freemium-banner {
  padding: 0 0 12px 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.eep-freemium-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #1e40af 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(29,78,216,0.30);
}
.eep-freemium-banner-inner svg { flex-shrink: 0; opacity: 0.9; }
.eep-freemium-banner-inner span { flex: 1; }
.eep-upgrade-btn {
  padding: 5px 14px;
  background: #fff;
  color: #1d4ed8;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.eep-upgrade-btn:hover { background: #eff6ff; }
.eep-freemium-dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
.eep-freemium-dismiss:hover { color: #fff; }

/* Upgrade modal */
.eep-upgrade-modal {
  position: fixed;
  inset: 0;
  background: rgba(6,15,28,0.65);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.eep-upgrade-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 28px 24px;
  max-width: 620px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(6,15,28,0.35);
  position: relative;
}
.eep-upgrade-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: transparent; border: none;
  font-size: 18px; color: #9ca3af;
  cursor: pointer; line-height: 1; padding: 2px 5px;
}
.eep-upgrade-modal-close:hover { color: #374151; }
.eep-upgrade-modal-icon {
  width: 52px; height: 52px;
  background: #eff6ff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.eep-upgrade-modal-title {
  text-align: center;
  font-size: 18px; font-weight: 800;
  color: #0b1929; margin-bottom: 8px;
}
.eep-upgrade-modal-body {
  text-align: center;
  font-size: 13px; color: #4b5563; line-height: 1.6;
  margin-bottom: 20px;
}
.eep-upgrade-modal-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 560px) {
  .eep-upgrade-modal-plans { grid-template-columns: 1fr; }
}
.eep-plan-card {
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.15s;
}
.eep-plan-card:hover { border-color: #93c5fd; }
.eep-plan-card--highlighted {
  border-color: #1d4ed8;
  background: #eff6ff;
}
.eep-plan-card-name {
  font-size: 11px; font-weight: 800;
  color: #374151; letter-spacing: 0.05em; text-transform: uppercase;
}
.eep-plan-card-price {
  font-size: 18px; font-weight: 900; color: #0b1929;
  line-height: 1.2;
}
.eep-plan-card-features {
  list-style: none; padding: 0; margin: 4px 0 auto;
  flex: 1;
}
.eep-plan-card-features li {
  font-size: 11px; color: #6b7280; padding: 2px 0;
  padding-left: 14px; position: relative;
}
.eep-plan-card-features li::before {
  content: '✓'; position: absolute; left: 0;
  color: #10b981; font-weight: 700;
}
.eep-plan-card-btn {
  display: block; text-align: center;
  padding: 6px 0; border-radius: 5px;
  font-size: 11px; font-weight: 700;
  border: 1.5px solid #d1d5db; color: #374151;
  text-decoration: none;
  transition: all 0.15s;
  margin-top: 8px;
}
.eep-plan-card-btn:hover { border-color: #9ca3af; background: #f9fafb; }
.eep-plan-card-btn--primary {
  background: #1d4ed8; color: #fff;
  border-color: #1d4ed8;
}
.eep-plan-card-btn--primary:hover { background: #1e40af; border-color: #1e40af; color: #fff; }

