/*  COGNICAM v4 — Clean Rewrite  */

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --bg: #0b1120;
  --bg2: #0f172a;
  --card: rgba(30, 41, 59, .75);
  --card2: rgba(30, 41, 59, .95);
  --txt: #f8fafc;
  --txt2: #94a3b8;
  --muted: #64748b;
  --bdr: rgba(255, 255, 255, .08);
  --bdr-hi: rgba(99, 102, 241, .3);
  --indigo: #6366f1;
  --indigo2: #818cf8;
  --iglow: rgba(99, 102, 241, .25);
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, .4);
  --ease: .3s cubic-bezier(.4, 0, .2, 1);
  --blur: blur(20px);
  --sw: 280px;
  /* sidebar width — desktop */
  --th: 68px;
  /* top-bar height */
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg2: #fff;
  --card: rgba(255, 255, 255, .8);
  --card2: #fff;
  --txt: #0f172a;
  --txt2: #475569;
  --muted: #94a3b8;
  --bdr: rgba(0, 0, 0, .07);
}

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

/* FIX: removed overflow:hidden from html/body — was causing
   History/Analytics/Settings to render black on laptop by
   collapsing the scroll context for mid-size screens          */
html,
body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--txt);
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-thumb {
  background: var(--bdr-hi);
  border-radius: 4px;
}

/* ── ANIMATIONS ──────────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ── AUTH VIEW (fixed, full-screen) ─────────────────── */
#view-auth {
  position: fixed !important;
  inset: 0;
  z-index: 9000;
  background: var(--bg);
  display: none;
}

#view-auth.active {
  display: flex !important;
}

.auth-left {
  width: 42%;
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem;
  position: relative;
  overflow: hidden;
}

.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

.auth-headline {
  font-family: 'Syne', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  margin-bottom: 1rem;
}

.auth-subtext {
  color: var(--txt2);
  font-size: .95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.auth-footer {
  margin-top: auto;
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.auth-features {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem;
  background: rgba(255, 255, 255, .03);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .05);
}

.feature-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .05);
  border-radius: 10px;
  font-size: 1.2rem;
}

.feature-info strong {
  display: block;
  font-size: .9rem;
  color: #fff;
}

.feature-info span {
  font-size: .8rem;
  color: var(--txt2);
}

.auth-card {
  width: 100%;
  max-width: 450px;
  padding: 2.5rem;
  border-radius: 28px;
  background: var(--card);
  border: 1px solid var(--bdr);
  box-shadow: 0 25px 50px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
}

.auth-card-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: .3rem;
}

.auth-card-subtext {
  font-size: .875rem;
  color: var(--txt2);
  margin-bottom: 1.75rem;
}

.auth-tabs {
  display: flex !important;
  background: rgba(0, 0, 0, .25);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 1.75rem;
  border: 1px solid var(--bdr);
}

.auth-tab {
  flex: 1;
  padding: .7rem;
  text-align: center;
  font-weight: 600;
  font-size: .875rem;
  color: var(--txt2);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  transition: var(--ease);
}

.auth-tab.active {
  background: var(--card2);
  color: var(--indigo2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--txt2);
  margin-bottom: .4rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap i {
  position: absolute;
  left: 14px;
  z-index: 2;
  font-style: normal;
  color: var(--indigo2);
}

.input-wrap input {
  width: 100%;
  height: 50px;
  padding: 0 1.25rem 0 3rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--bdr);
  border-radius: 14px;
  color: var(--txt);
  font-size: .95rem;
  transition: var(--ease);
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--iglow);
}

.auth-hint {
  margin-top: 1.25rem;
  padding: .85rem;
  background: rgba(99, 102, 241, .05);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  font-size: .8rem;
  color: var(--txt2);
  cursor: pointer;
  text-align: center;
  transition: var(--ease);
}

.auth-hint:hover {
  background: rgba(99, 102, 241, .1);
  border-color: var(--indigo);
}


/* ── APP SHELL ───────────────────────────────────────── */
#app {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* main-layout is hidden by default (class="layout-hidden") */
#main-layout {
  flex: 1;
  min-height: 0;
  height: 0; /* force flex to calculate remaining height correctly */
  display: none;
}

#main-layout:not(.layout-hidden) {
  display: flex !important;
  height: 100%;
}

.layout-hidden {
  display: none !important;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sw);
  min-width: var(--sw);
  /* Use align-self:stretch so sidebar grows to fill full #main-layout height */
  align-self: stretch;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.25rem;
  background: var(--bg2);
  border-right: 1px solid var(--bdr);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width var(--ease), padding var(--ease);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: 2.5rem;
  white-space: nowrap;
}

.logo-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--indigo2));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 0 18px var(--iglow);
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -1px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--bdr);
  border-radius: 16px;
  white-space: nowrap;
  overflow: hidden;
}

.avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--indigo);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-weight: 600;
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: .73rem;
  color: var(--txt2);
}

.nav-links {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-item {
  margin-bottom: .35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .8rem 1rem;
  border-radius: 12px;
  color: var(--txt2);
  /* FIX: explicit color — never inherit transparent */
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--ease), color var(--ease);
}

.nav-link i {
  font-style: normal;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.nav-link:hover {
  background: rgba(99, 102, 241, .08);
  color: var(--indigo2);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .14), transparent);
  color: var(--indigo2);
  border-left: 3px solid var(--indigo);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bdr);
}

.theme-toggle {
  display: flex;
  background: var(--bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--bdr);
  margin-bottom: .75rem;
}

.theme-btn {
  flex: 1;
  padding: .45rem;
  font-size: .78rem;
  border: none;
  background: transparent;
  color: var(--txt2);
  cursor: pointer;
  border-radius: 8px;
  transition: var(--ease);
  white-space: nowrap;
  overflow: hidden;
}

.theme-btn.active {
  background: var(--card);
  color: var(--indigo2);
}


/* ── CONTENT AREA ────────────────────────────────────── */
#content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* FIX: changed height:100% to min-height:0 — allows flex
     children (.view) to scroll correctly on all screen sizes */
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

#top-bar {
  height: var(--th) !important;
  min-height: var(--th) !important;
  flex-shrink: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 2rem !important;
  background: rgba(11, 17, 32, .7) !important;
  backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid var(--bdr) !important;
  z-index: 50;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.search-box {
  position: relative;
  width: 260px;
}

.search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  padding: .55rem 1rem .55rem 2.25rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  color: var(--txt);
  font-size: .875rem;
  transition: var(--ease);
}

.search-box input:focus {
  outline: none;
  border-color: var(--indigo);
}

.notification-btn {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  cursor: pointer;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg);
}


/* ── VIEWS ───────────────────────────────────────────── */
/* FIX: views were collapsing to 0 height on laptop because
   overflow:hidden on #content-area + no explicit height meant
   flex children had no available space to expand into.
   Solution: flex:1 + min-height:0 + overflow-y:auto on .view  */
.view {
  display: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  background: var(--bg);
  color: var(--txt);
}

.view.active {
  display: flex;
  flex-direction: column;
  animation: fadeUp .35s var(--ease);
}

/* Inner wrapper — History/Analytics/Settings use this */
.view-content {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--txt);
}

/* Card section titles */
.card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  color: var(--txt);
}

.dashboard-grid:empty,
#analytics-stats-grid:empty {
  min-height: 0;
  margin: 0;
  padding: 0;
}


/* ── CARDS & GRID ────────────────────────────────────── */
.glass-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: 22px;
  padding: 1.5rem;
  transition: var(--ease);
}

.glass-card:hover {
  border-color: var(--bdr-hi);
  transform: translateY(-2px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: .75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--ease);
  font-size: .9rem;
}

.btn-primary {
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 6px 18px var(--iglow);
}

.btn-primary:hover {
  background: var(--indigo2);
  transform: scale(1.02);
}

.btn-ghost {
  background: transparent;
  color: var(--txt2);
  border: 1px solid var(--bdr);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .05);
  color: var(--txt);
  border-color: var(--bdr-hi);
}

.btn-outline {
  background: transparent;
  color: var(--txt2);
  border: 1px solid var(--bdr);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, .04);
  color: var(--txt);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, .1);
  border: 1px solid var(--bdr);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--txt);
}

.stat-label {
  font-size: .8rem;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-trend {
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 100px;
}

.trend-up {
  color: var(--green);
  background: rgba(16, 185, 129, .1);
}

.trend-down {
  color: var(--red);
  background: rgba(239, 68, 68, .1);
}

.quick-action-card {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--indigo), #4338ca);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2.25rem;
  position: relative;
  overflow: hidden;
}

.quick-action-content {
  position: relative;
  z-index: 1;
}

.quick-action-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  margin-bottom: .4rem;
}

.quick-action-text {
  opacity: .8;
  margin-bottom: 1.25rem;
}

.quick-action-icon {
  width: 90px;
  height: 90px;
  background: rgba(255, 255, 255, .1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}


/* ── TABLES ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.filter-group {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.count-label {
  font-size: .85rem;
  color: var(--muted);
}

.table-container {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: 22px;
  overflow: hidden;
  margin-top: 1.75rem;
}

.table-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--bdr);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header h3 {
  font-family: 'Syne', sans-serif;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

th {
  padding: 1rem 1.5rem;
  text-align: left;
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--bdr);
}

td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--bdr);
  font-size: .9rem;
  vertical-align: middle;
  color: var(--txt);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.decision-badge {
  padding: .35rem .85rem;
  border-radius: 8px;
  font-size: .72rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.chip {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 700;
  background: rgba(99, 102, 241, .1);
  border: 1px solid var(--bdr);
  color: var(--txt2);
}


/* ── ANALYTICS ───────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.chart-container {
  height: 280px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 1rem;
}

.perf-table {
  width: 100%;
  border-collapse: collapse;
}

.perf-table th,
.perf-table td {
  padding: .85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--bdr);
  font-size: .875rem;
}


/* ── WIZARD ──────────────────────────────────────────── */
.wizard-container {
  max-width: 960px;
  margin: 0 auto;
}

.step-indicator {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3rem;
  position: relative;
}

.step-indicator::before {
  content: "";
  position: absolute;
  top: 19px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--bdr);
}

.step-progress {
  position: absolute;
  top: 19px;
  left: 0;
  height: 2px;
  background: var(--green);
  z-index: 1;
  transition: width .5s ease;
}

.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  flex: 1;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg2);
  border: 2px solid var(--bdr);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--muted);
  transition: all .3s;
}

.step-item.active .step-circle {
  border-color: var(--indigo);
  color: var(--indigo);
  box-shadow: 0 0 16px var(--iglow);
}

.step-item.complete .step-circle {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.step-name {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width:640px) {
  .step-name {
    display: none;
  }
}

.drop-zone {
  border: 2px dashed var(--indigo);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.25rem;
  transition: var(--ease);
}

.drop-zone:hover {
  background: rgba(99, 102, 241, .05);
}

.terminal {
  background: #000;
  border-radius: 10px;
  padding: 1rem;
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  color: #10b981;
  height: 160px;
  overflow-y: auto;
  border: 1px solid rgba(16, 185, 129, .2);
}

.rings-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
  margin: 1.75rem 0 3rem;
}

.mini-ring-card {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: 22px;
  padding: 1.25rem;
  text-align: center;
  transition: var(--ease);
}

.mini-ring-card:hover {
  border-color: var(--indigo);
  transform: translateY(-3px);
}

.ring-container {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 1rem;
}

.ring-val {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 1.1rem;
}

.ring-desc {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem;
}

.ring-rationale {
  font-size: .68rem;
  color: var(--txt2);
  line-height: 1.4;
}

.score-hero-card {
  border-radius: 28px;
  border: 1px solid var(--bdr-hi);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 2.5rem;
}

.gauge-container {
  position: relative;
  width: 190px;
  height: 190px;
}

.gauge-score {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge-number {
  font-family: 'Syne', sans-serif;
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1;
}

.overall-lbl {
  font-size: .75rem;
  opacity: .6;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pulse-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
}

.observation-textarea {
  width: 100%;
  height: 260px;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  padding: 1.1rem;
  color: var(--txt);
  font-family: inherit;
  font-size: .875rem;
  resize: none;
  line-height: 1.6;
}

.observation-textarea:focus {
  border-color: var(--indigo);
  outline: none;
}

.narrative-card {
  margin-bottom: 1.25rem;
  border-left: 4px solid var(--indigo);
}

.narrative-text {
  font-size: .875rem;
  line-height: 1.8;
  padding: .9rem;
  background: rgba(0, 0, 0, .2);
  border-radius: 8px;
}

.intel-card {
  padding: 1.5rem;
  border-radius: 18px;
  transition: var(--ease);
}

.intel-card-success {
  background: rgba(16, 185, 129, .05);
  border: 1px solid var(--green);
}

.intel-card-success h4 {
  color: var(--green);
}

/* ── SETTINGS FORM ───────────────────────────────────── */
.form-control {
  width: 100%;
  padding: .8rem 1.1rem;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  color: var(--txt);
  font-family: inherit;
  font-size: .9rem;
  transition: var(--ease);
}

.form-control:focus {
  outline: none;
  border-color: var(--indigo2);
  box-shadow: 0 0 12px var(--iglow);
}

/* ── LOADING ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(11, 17, 32, .85);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

#loading-overlay.active {
  display: flex;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bdr);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

#loading-text {
  color: var(--txt2);
  font-size: .9rem;
}

/* ── MISC ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.toast {
  padding: .9rem 1.4rem;
  border-radius: 14px;
  font-size: .875rem;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--bdr);
  color: var(--txt);
  box-shadow: var(--shadow);
  animation: fadeUp .3s ease;
  transition: opacity .5s, transform .5s;
}

.toast-success {
  border-color: var(--green);
}

.toast-error {
  border-color: var(--red);
}

.toast-info {
  border-color: var(--indigo);
}

#mobile-nav-bar {
  display: none;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  background: var(--bg2);
  border-bottom: 1px solid var(--bdr);
  z-index: 5000;
  align-items: center;
  padding: 0 1.25rem;
  justify-content: space-between;
}

.mobile-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
}

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  color: var(--txt);
  font-size: 1.4rem;
  cursor: pointer;
}

/* ── STEP PANEL GRID (used in wizard steps) ──────────── */
.step-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

/* ── IMPACT BAR ──────────────────────────────────────── */
.impact-gauge-container {
  margin-top: 1.5rem;
}

.impact-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, .06);
  border-radius: 4px;
  overflow: hidden;
  margin-top: .5rem;
}

.impact-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .6s ease, background .4s;
}

/* ── EXTRACTION STATUS ───────────────────────────────── */
.extraction-status {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(16, 185, 129, .05);
  border: 1px solid rgba(16, 185, 129, .2);
  border-radius: 12px;
}

.extraction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}

.extraction-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--green);
}

/* ── NOTICE BOX ──────────────────────────────────────── */
.notice-box {
  margin-top: 1rem;
  padding: .85rem 1rem;
  background: rgba(245, 158, 11, .05);
  border: 1px solid rgba(245, 158, 11, .2);
  border-radius: 10px;
}

.notice-text {
  font-size: .75rem;
  color: var(--txt2);
  line-height: 1.5;
}

/* ── INTEL HEADER (Research step) ───────────────────── */
.intel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── SENTIMENT DISPLAY ───────────────────────────────── */
.sentiment-display {
  display: flex;
  flex-direction: column;
}

.sentiment-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.sentiment-score {
  font-family: 'Syne', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  color: var(--green);
}

.sentiment-label {
  font-size: .75rem;
  color: var(--txt2);
  text-transform: uppercase;
  margin: .4rem 0 .75rem;
}

.sentiment-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: .4rem 1rem;
  border-radius: 20px;
  background: rgba(16, 185, 129, .1);
  color: var(--green);
}

/* ── DEMO DATASET BOX ────────────────────────────────── */
.demo-dataset-box {
  margin-top: 1.5rem;
  border-top: 1px solid var(--bdr);
  padding-top: 1.5rem;
}

/* ── CURSOR (terminal) ───────────────────────────────── */
.cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--green);
  animation: blink 1s step-end infinite;
}


/* ════════════════════════════════════════════════════════
   RESPONSIVE
   Desktop  > 1024px — full sidebar 280px
   Tablet   768–1024px — collapsed sidebar with labels
   Mobile   < 768px  — off-canvas sidebar
   ════════════════════════════════════════════════════════ */

/* TABLET  */
@media (max-width:1024px) {

  /* FIX: previously collapsed sidebar to 72px icon-only.
     This caused sidebar to "disappear" on many laptops that
     run at 1024px effective width or below due to browser
     zoom or display scaling.
     New behaviour: sidebar stays visible at 200px with short
     labels visible — no icon-only mode.                      */
  :root {
    --sw: 200px;
  }

  #sidebar {
    padding: 1.5rem .75rem;
  }

  .logo-text {
    font-size: 1rem;
  }

  .user-info {
    display: block;
  }

  .user-name {
    font-size: .8rem;
  }

  .user-role {
    font-size: .68rem;
  }

  /* Nav links stay readable — just slightly smaller */
  .nav-link {
    padding: .7rem .85rem;
    font-size: .82rem;
    gap: .65rem;
    color: var(--txt2);
    /* FIX: was set to transparent — made all labels invisible */
  }

  .nav-link i {
    font-size: 1.1rem;
    color: var(--txt2);
  }

  .nav-link.active i {
    color: var(--indigo2);
  }

  .nav-link:hover i {
    color: var(--indigo2);
  }

  .user-profile {
    padding: .65rem .75rem;
  }

  .theme-toggle {
    flex-direction: column;
    gap: 2px;
  }

  .theme-btn {
    width: 100%;
    padding: .5rem .3rem;
    font-size: .72rem;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .pulse-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .score-hero-card {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }

  .rings-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .step-panel-grid {
    grid-template-columns: 1fr;
  }

  .quick-action-card {
    grid-column: auto;
  }
}


/* MOBILE */
@media (max-width:767px) {

  /* Show mobile top bar */
  #mobile-nav-bar,
  .mobile-nav {
    display: flex !important;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 58px;
    bottom: 0;
    width: 275px !important;
    height: calc(100% - 58px);
    background: var(--bg2);
    z-index: 4000;
    transform: translateX(-100%);
    transition: transform .3s ease;
    /* Restore full sidebar labels on mobile overlay */
    align-items: flex-start;
    padding: 1.5rem 1.25rem;
  }

  /* Restore all text when sidebar is open overlay */
  #sidebar .nav-link {
    color: var(--txt2) !important;
    font-size: .9rem !important;
    gap: .85rem !important;
    justify-content: flex-start !important;
    padding: .8rem 1rem !important;
  }

  #sidebar .nav-link i {
    color: var(--txt2) !important;
  }

  #sidebar .nav-link.active {
    color: var(--indigo2) !important;
  }

  #sidebar .logo {
    justify-content: flex-start !important;
  }

  #sidebar .logo-text {
    display: block !important;
    font-size: 1.3rem !important;
  }

  #sidebar .user-info {
    display: block !important;
  }

  #sidebar .user-name {
    font-size: .9rem !important;
  }

  #sidebar .user-profile {
    justify-content: flex-start !important;
  }

  #sidebar .theme-btn {
    font-size: .78rem !important;
  }

  #sidebar .theme-toggle {
    flex-direction: row !important;
  }

  /* Open state */
  #sidebar.open {
    transform: translateX(0);
  }

  /* Push content down so it clears the mobile top bar */
  #content-area {
    padding-top: 58px;
  }

  #top-bar {
    display: none !important;
  }

  /* Sidebar is fixed/overlaid so doesn't take layout space */
  :root {
    --sw: 0px;
  }

  .view {
    padding: 1.25rem 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  .quick-action-card {
    grid-column: auto;
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
  }

  .chart-grid,
  .pulse-grid,
  .field-grid,
  .rings-row {
    grid-template-columns: 1fr !important;
  }

  .step-panel-grid {
    grid-template-columns: 1fr !important;
  }

  .rings-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .score-hero-card {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }

  .wizard-container {
    max-width: 100%;
  }

  /* Prevent table overflow on mobile */
  table {
    min-width: 500px;
  }

  .table-container {
    overflow-x: auto;
  }

  /* Auth page stacks on mobile */
  #view-auth {
    flex-direction: column;
    overflow-y: auto;
  }

  .auth-left {
    width: 100%;
    padding: 2rem 1.5rem;
    min-height: auto;
  }

  .auth-right {
    padding: 1.5rem;
  }

  .auth-headline {
    font-size: 1.8rem;
  }
}


/* ════════════════════════════════════════════════════════
   ADDITIONAL RESPONSIVE PATCHES
   ════════════════════════════════════════════════════════ */

/* ── TABLET: shrink top-bar search & tighten padding ─── */
@media (max-width: 1024px) {
  .search-box {
    width: 180px;
  }

  #top-bar {
    padding: 0 1.25rem !important;
  }

  .view {
    padding: 1.5rem 1.5rem;
  }

  /* Step-4 inline 3-col grids → 2-col on tablet */
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── MOBILE: sidebar backdrop overlay ───────────────── */
@media (max-width: 767px) {
  /* Dim backdrop when sidebar open */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 3999;
    backdrop-filter: blur(2px);
  }

  #sidebar-backdrop.visible {
    display: block;
  }

  /* Top-bar hidden on mobile — already set but make sure search doesn't leak */
  .search-box {
    width: 100%;
    max-width: 200px;
  }

  /* Step-4 inline 3-col grids → 1-col on mobile */
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* Flex rows with fixed gap → wrap on mobile */
  [style*="display: flex"][style*="gap: 32px"] {
    flex-wrap: wrap;
    gap: 16px !important;
    justify-content: center !important;
  }

  /* Stat mini cards in step-4 hero row */
  .stat-mini {
    min-width: 0;
  }

  /* Gauge container shrink */
  .gauge-container {
    width: 150px;
    height: 150px;
  }

  .gauge-number {
    font-size: 2.5rem;
  }

  /* Mini ring cards: 2-col */
  .rings-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .ring-container {
    width: 90px;
    height: 90px;
  }

  /* Quick-action full-width button */
  .quick-action-card .btn {
    width: 100%;
    justify-content: center;
  }

  /* Auth page: hide decorative left panel on small mobile */
  .auth-features {
    display: none;
  }

  /* Filter bar stacks on mobile */
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Table actions wrap */
  .top-actions {
    gap: .65rem;
  }

  /* Wizard step buttons wrap */
  .step-indicator {
    gap: .4rem;
  }

  .step-circle {
    width: 30px;
    height: 30px;
    font-size: .8rem;
  }
}

/* ── EXTRA-SMALL (≤ 480px) ──────────────────────────── */
@media (max-width: 480px) {
  /* Auth card padding reduction */
  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: 20px;
  }

  .auth-left {
    padding: 1.5rem 1.25rem;
    min-height: 160px;
  }

  .auth-headline {
    font-size: 1.4rem;
  }

  /* View padding */
  .view {
    padding: 1rem .85rem;
  }

  /* Rings → single column */
  .rings-row {
    grid-template-columns: 1fr 1fr !important;
    gap: .85rem;
  }

  .ring-container {
    width: 80px;
    height: 80px;
  }

  /* Gauge barely fits — scale down */
  .gauge-container {
    width: 130px;
    height: 130px;
  }

  .gauge-number {
    font-size: 2rem;
  }

  /* Score hero stack tightly */
  .score-hero-card {
    padding: 1.25rem;
    gap: 1rem;
  }

  /* Stat cards font */
  .stat-value {
    font-size: 1.6rem;
  }

  /* Buttons full-width inside wizard nav */
  .wizard-container > div[style*="justify-content: flex-end"] {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: .75rem;
  }

  .wizard-container > div[style*="justify-content: flex-end"] .btn {
    width: 100%;
    justify-content: center;
  }

  /* Toast position */
  #toast-container {
    top: auto;
    bottom: 1rem;
    right: .75rem;
    left: .75rem;
  }

  .toast {
    font-size: .8rem;
    padding: .75rem 1rem;
  }

  /* Mobile nav bar */
  .mobile-logo {
    font-size: .95rem;
  }

  /* Table min-width tightened */
  table {
    min-width: 400px;
  }
}