:root {
  --bg-top: #111722;
  --bg-bottom: #0b1018;
  --panel: rgba(17, 24, 36, 0.94);
  --panel-soft: rgba(10, 17, 29, 0.9);
  --panel-border: rgba(138, 180, 255, 0.16);
  --panel-strong: rgba(138, 180, 255, 0.28);
  --text-main: #eef4ff;
  --text-muted: #b7c5d9;
  --text-faint: #8a9ab0;
  --accent: #8ab4ff;
  --accent-soft: rgba(138, 180, 255, 0.14);
  --success-soft: rgba(84, 208, 154, 0.14);
  --success-text: #8de4bc;
  --warning-soft: rgba(255, 181, 76, 0.16);
  --warning-text: #ffd28f;
  --danger-soft: rgba(255, 108, 108, 0.16);
  --danger-text: #ffb1b1;
  --table-stripe: rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(138, 180, 255, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.variables-shell {
  width: min(1660px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

/* =========================================================
   KPI STRIP
   Forced horizontal layout on desktop
   ========================================================= */

.kpi-grid {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 16px !important;
  margin: 18px 0 20px !important;
  width: 100% !important;
}

.kpi-grid > * {
  flex: 1 1 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px 18px;
  min-width: 0;
  min-height: 132px;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
}

.kpi-label {
  color: var(--text-faint);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 8px;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.kpi-note {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.control-panel,
.surface-card,
.diagnostics-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 0;
}

.control-panel {
  margin-bottom: 18px;
  padding: 16px 18px 14px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.toolbar-row + .toolbar-row {
  margin-top: 12px;
}

.toolbar-row label {
  min-width: 142px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toolbar-row label span {
  color: var(--text-faint);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-wrap {
  flex: 1 1 300px;
  min-width: 260px;
}

input,
select,
button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(6, 11, 18, 0.88);
  color: var(--text-main);
  font: inherit;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: var(--panel-strong);
  box-shadow: 0 0 0 3px rgba(138, 180, 255, 0.12);
}

.secondary-btn {
  min-height: 40px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toolbar-row-pills {
  align-items: center;
}

.kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  line-height: 1;
}

.kpi-pill strong {
  font-size: 0.96rem;
}

.kpi-pill.neutral {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(138, 180, 255, 0.16);
}

.kpi-pill.success {
  background: var(--success-soft);
  color: var(--success-text);
  border-color: rgba(84, 208, 154, 0.18);
}

.kpi-pill.warning {
  background: var(--warning-soft);
  color: var(--warning-text);
  border-color: rgba(255, 181, 76, 0.22);
}

.kpi-pill.danger {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: rgba(255, 108, 108, 0.18);
}

.surface-card {
  padding: 16px 18px 20px;
}

.surface-card-head,
.diagnostics-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.surface-card-head h2,
.diagnostics-head h2 {
  margin: 0 0 4px;
  font-size: 1.14rem;
}

.surface-card-head p,
.diagnostics-head p,
.table-meta {
  color: var(--text-muted);
  margin: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  width: 100%;
  max-width: 100%;
}

.surface-table {
  width: 100%;
  min-width: 1590px;
  border-collapse: collapse;
}

.surface-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 12px;
  background: #101724;
  color: var(--text-muted);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.surface-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.surface-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.surface-table tbody tr:hover {
  background: rgba(138, 180, 255, 0.05);
}

.num {
  text-align: right;
}

.compact-surface-table .col-variable { min-width: 205px; }
.compact-surface-table .col-version { min-width: 112px; }
.compact-surface-table .col-yn { min-width: 88px; }
.compact-surface-table .col-assignment { min-width: 112px; }
.compact-surface-table .col-binding { min-width: 210px; }
.compact-surface-table .col-assigned-ext { min-width: 360px; }
.compact-surface-table .col-coverage-summary { min-width: 215px; }
.compact-surface-table .col-inspect { min-width: 108px; width: 108px; }

.surface-table td.col-inspect,
.surface-table th.col-inspect {
  white-space: nowrap;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.type {
  background: rgba(138, 180, 255, 0.14);
  color: var(--accent);
}

.badge.assigned {
  background: var(--success-soft);
  color: var(--success-text);
}

.badge.unassigned {
  background: var(--warning-soft);
  color: var(--warning-text);
}

.badge.mandatory-yes,
.badge.unique-yes,
.badge.version-latest,
.badge.version-all {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.badge.version-none,
.badge.mandatory-no,
.badge.unique-no {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.badge.coverage-all-live {
  background: var(--success-soft);
  color: var(--success-text);
  border-color: rgba(84, 208, 154, 0.24);
}

.badge.coverage-partial-gap {
  background: var(--warning-soft);
  color: var(--warning-text);
  border-color: rgba(255, 181, 76, 0.24);
}

.badge.coverage-no-vault-match {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: rgba(255, 108, 108, 0.24);
}

.badge.coverage-unassigned,
.badge.coverage-no-extension {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.08);
}

.variable-name {
  font-weight: 700;
  line-height: 1.15;
}

.variable-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.variable-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.variable-subtle {
  color: var(--text-faint);
  font-size: 0.78rem;
  line-height: 1.2;
}

.binding-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.binding-block {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
}

.binding-attribute {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.2;
  word-break: break-word;
}

.assigned-ext-cell {
  min-width: 0;
  display: flex;
  align-items: center;
}

.assigned-ext-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.assigned-ext-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.assigned-ext-pill.assigned-live {
  background: rgba(108, 230, 0, 0.16);
  color: #b8ff6f;
  border-color: rgba(108, 230, 0, 0.24);
}

.assigned-ext-pill.assigned-more {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-faint);
  border-color: rgba(255, 255, 255, 0.08);
}

.coverage-summary-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.coverage-summary-text {
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.22;
}

.detail-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.detail-toggle:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

.detail-toggle.is-open {
  border-color: rgba(138, 180, 255, 0.18);
  background: rgba(138, 180, 255, 0.10);
  color: var(--accent);
}

.compact-toggle {
  min-width: 84px;
  width: 84px;
  justify-content: center;
  display: inline-flex;
  font-weight: 800;
}

.surface-table tbody tr.detail-row {
  background: rgba(7, 12, 20, 0.86);
}

.surface-table tbody tr.detail-row:hover {
  background: rgba(7, 12, 20, 0.86);
}

.detail-cell {
  padding: 0 !important;
}

.detail-panel {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.01)),
    rgba(7, 12, 20, 0.84);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-block {
  min-width: 0;
  padding: 11px 13px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.detail-block h4 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--text-main);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-block p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}

.detail-empty {
  color: var(--text-faint);
  font-style: italic;
}

tr.row-severity-high {
  box-shadow: inset 3px 0 0 rgba(255, 108, 108, 0.7);
}

tr.row-severity-medium {
  box-shadow: inset 3px 0 0 rgba(255, 181, 76, 0.7);
}

tr.row-severity-low {
  box-shadow: inset 3px 0 0 rgba(138, 180, 255, 0.45);
}

tr.row-status-unassigned {
  opacity: 0.96;
}

.diagnostics-card {
  margin-top: 22px;
  padding: 18px 20px 22px;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.diag-group {
  min-width: 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.diag-group h3 {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.diag-group.action h3 {
  color: var(--danger-text);
}

.diag-group.review h3 {
  color: var(--warning-text);
}

.diag-group.ignore h3 {
  color: var(--text-muted);
}

.diag-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diag-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6, 11, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.diag-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diag-ext {
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.diag-meta {
  color: var(--text-faint);
  font-size: 0.78rem;
  line-height: 1.25;
}

.diag-count {
  flex: 0 0 auto;
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.92rem;
}

.diag-empty {
  padding: 12px;
  border-radius: 14px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.empty-state {
  padding: 28px 18px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 1220px) {
  .kpi-grid {
    flex-wrap: wrap !important;
  }

  .kpi-grid > * {
    flex: 1 1 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
  }

  .detail-grid,
  .diagnostics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .variables-shell {
    width: min(100vw - 20px, 1680px);
    padding-top: 16px;
  }

  .control-panel,
  .surface-card,
  .diagnostics-card,
  .kpi-card {
    border-radius: 18px;
  }

  .kpi-grid > * {
    flex: 1 1 100% !important;
    width: 100% !important;
  }
}