:root {
  --bg: #0a0f14;
  --panel: rgba(11, 23, 32, 0.82);
  --panel-strong: rgba(18, 33, 45, 0.94);
  --line: rgba(159, 199, 220, 0.18);
  --text: #e7f2f8;
  --muted: #9cb8c8;
  --accent: #ff8a3d;
  --accent-soft: rgba(255, 138, 61, 0.18);
  --ok: #7fd6b9;
  --danger: #ff6a6a;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 138, 61, 0.18), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(79, 168, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #081018 0%, #0a0f14 40%, #10161b 100%);
}

.background-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78), transparent);
  pointer-events: none;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 28px auto 48px;
  position: relative;
  z-index: 1;
}

.hero,
.panel,
.control-strip {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
  border-radius: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.74rem;
  color: var(--accent);
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.lede,
.panel-header p,
.meta-label,
label,
.target-meta,
.interface-meta {
  color: var(--muted);
}

.lede {
  max-width: 820px;
  font-size: 1rem;
  line-height: 1.7;
  margin: 18px 0 0;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.meta-card {
  padding: 18px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-card.accent {
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.2), rgba(255, 138, 61, 0.08));
}

.meta-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.control-strip {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 22px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.shell-chrome {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.page-nav,
.shell-auth-strip,
.workflow-card {
  border: 1px solid var(--line);
  background: rgba(8, 18, 27, 0.76);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border-radius: 20px;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.page-nav a:hover,
.page-nav a.active {
  color: var(--text);
  border-color: rgba(255, 138, 61, 0.42);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.18), rgba(79, 168, 255, 0.08));
  transform: translateY(-1px);
}

.shell-auth-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  border-radius: 20px;
}

.shell-auth-strip label {
  flex: 1 1 320px;
}

.shell-auth-status {
  flex: 1 1 260px;
  margin: 0;
}

.workflow-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.workflow-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 22px;
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.workflow-card:hover,
.workflow-card.active {
  transform: translateY(-1px);
  border-color: rgba(255, 138, 61, 0.4);
  background: linear-gradient(145deg, rgba(255, 138, 61, 0.14), rgba(79, 168, 255, 0.08));
}

.workflow-card strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.workflow-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.scope-panel {
  margin-top: 18px;
}

.profile-panel {
  margin-top: 18px;
}

.live-debug-panel,
.profile-studio-panel {
  margin-top: 18px;
}

.profile-studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
}

.profile-library-panel,
.profile-detail-panel {
  min-width: 0;
}

.profile-subheader {
  margin-bottom: 12px;
}

.profile-subheader h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.35fr;
  gap: 18px;
  margin-top: 18px;
}

.operations-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border-radius: 24px;
  padding: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.panel-header p {
  margin: 0;
  max-width: 420px;
  line-height: 1.5;
}

.target-list,
.interfaces-grid,
.summary-cards {
  display: grid;
  gap: 12px;
}

.target-card,
.interface-card,
.summary-card {
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.target-card {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.target-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 138, 61, 0.34);
}

.target-card.selected {
  border-color: rgba(255, 138, 61, 0.6);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.18), rgba(255, 138, 61, 0.05));
}

.profile-card.editor-selected {
  border-color: rgba(79, 168, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(79, 168, 255, 0.18);
}

.profile-card.runtime-selected {
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.18), rgba(255, 138, 61, 0.05));
}

.target-card h3,
.interface-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.target-meta,
.interface-meta {
  font-size: 0.92rem;
  line-height: 1.6;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

button,
select,
input,
.button-link {
  font: inherit;
}

button,
select,
input,
.button-link {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 12px 14px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

input::placeholder {
  color: rgba(156, 184, 200, 0.62);
}

button {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 138, 61, 0.6);
}

.button-link:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 138, 61, 0.6);
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

button:disabled:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.08);
}

button.danger {
  background: linear-gradient(135deg, rgba(255, 106, 106, 0.24), rgba(255, 138, 61, 0.16));
}

button.ghost {
  background: rgba(255, 255, 255, 0.04);
}

.button-link.ghost {
  background: rgba(255, 255, 255, 0.04);
}

label {
  display: grid;
  gap: 8px;
  min-width: 220px;
  font-size: 0.92rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: auto;
}

.summary-cards {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 14px;
}

.builder-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.rollout-form {
  margin-bottom: 18px;
}

.management-grid,
.editor-layout,
.panel-stack,
.split-panel,
.json-columns,
.node-health-grid,
.assignment-list,
.alert-list {
  display: grid;
  gap: 16px;
}

.management-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  margin-top: 18px;
}

.editor-layout {
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
}

.split-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.json-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-stack,
.assignment-list,
.alert-list {
  grid-template-columns: 1fr;
}

.node-health-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.textarea-input,
.mono-input {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  line-height: 1.55;
}

.mono-input {
  min-height: auto;
}

.editor-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.assignment-card,
.alert-card,
.node-card,
.note-card {
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.assignment-card p,
.alert-card p,
.node-card p,
.note-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.alert-card.critical,
.alert-card.high {
  border-color: rgba(255, 106, 106, 0.28);
  background: linear-gradient(145deg, rgba(255, 106, 106, 0.12), rgba(255, 255, 255, 0.03));
}

.alert-card.warning,
.alert-card.medium {
  border-color: rgba(255, 138, 61, 0.28);
  background: linear-gradient(145deg, rgba(255, 138, 61, 0.12), rgba(255, 255, 255, 0.03));
}

.profile-studio-grid-compact {
  grid-template-columns: 1fr;
}

.profile-studio-grid-compact .profile-library-panel {
  min-width: 0;
}

.builder-span-2 {
  grid-column: 1 / -1;
}

.helper-note {
  margin: -2px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.88rem;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.3rem;
  word-break: break-word;
}

.code-block {
  margin: 0;
  border-radius: 18px;
  padding: 16px;
  background: #050a0f;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: auto;
  max-height: 440px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.6;
}

.code-block.compact {
  max-height: 260px;
}

.debug-panel,
.status-panel,
.log-panel {
  margin-top: 18px;
}

.interfaces-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.chart-card,
.rule-stat-card {
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.chart-card {
  min-height: 240px;
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.chart-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  flex-wrap: wrap;
}

.chart-summary strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.chart-summary span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-svg {
  width: 100%;
  height: 160px;
  display: block;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-area {
  fill: rgba(255, 138, 61, 0.22);
  stroke: rgba(255, 138, 61, 0.92);
  stroke-width: 2;
}

.chart-line-secondary,
.chart-line-outbound {
  fill: none;
  stroke: rgba(127, 214, 185, 0.85);
  stroke-width: 2;
}

.chart-line-inbound {
  fill: none;
  stroke: #ffc857;
  stroke-width: 2;
}

.chart-line-blocked {
  fill: none;
  stroke: rgba(255, 106, 106, 0.92);
  stroke-width: 2;
}

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.primary {
  background: var(--accent);
}

.legend-dot.secondary {
  background: var(--ok);
}

.legend-dot.inbound {
  background: #ffc857;
}

.legend-dot.outbound {
  background: var(--ok);
}

.legend-dot.blocked {
  background: var(--danger);
}

.rule-stats-list {
  display: grid;
  gap: 12px;
}

.telemetry-note {
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.09);
}

.diagnose-match {
  border-color: rgba(255, 138, 61, 0.32);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.12), rgba(255, 255, 255, 0.03));
}

.profile-card {
  min-height: 100%;
}

.profile-draft-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.control-note {
  flex: 1 1 320px;
  margin: 0;
}

.profile-rule-card {
  display: grid;
  gap: 12px;
}

.profile-rule-card.selected {
  border-color: rgba(79, 168, 255, 0.55);
  background: linear-gradient(135deg, rgba(79, 168, 255, 0.12), rgba(255, 255, 255, 0.03));
}

.profile-rule-summary {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.profile-rule-editor-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rule-editor-input {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  margin-bottom: 14px;
  font-family: "IBM Plex Mono", monospace;
  line-height: 1.55;
}

.rule-inline-actions {
  margin-bottom: 0;
}

.rule-inline-actions button {
  padding: 10px 12px;
}

.debug-stream-panel {
  margin-top: 18px;
}

.debug-live-card.blocked {
  border-color: rgba(255, 106, 106, 0.34);
  background: linear-gradient(135deg, rgba(255, 106, 106, 0.16), rgba(255, 255, 255, 0.03));
}

.debug-live-card.allowed,
.debug-live-card.reply-observed {
  border-color: rgba(127, 214, 185, 0.3);
  background: linear-gradient(135deg, rgba(127, 214, 185, 0.14), rgba(255, 255, 255, 0.03));
}

.debug-event-message {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.debug-payload {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
  overflow: auto;
}

.debug-empty {
  border-radius: 18px;
  padding: 20px;
  border: 1px dashed rgba(255, 255, 255, 0.09);
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

.diagnose-reasons {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.rule-stat-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.rule-stat-head h3 {
  margin: 0;
  font-size: 0.98rem;
}

.rule-stat-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.rule-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 12px;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 138, 61, 0.72), rgba(127, 214, 185, 0.82));
}

.harness-panel {
  margin-top: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(127, 214, 185, 0.12);
  color: var(--ok);
}

.pill.warn {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.danger {
  background: rgba(255, 106, 106, 0.12);
  color: var(--danger);
}

.pill.attack-clear {
  background: rgba(127, 214, 185, 0.12);
  color: var(--ok);
}

.pill.attack-low,
.pill.attack-medium {
  background: rgba(255, 200, 87, 0.12);
  color: #ffc857;
}

.pill.attack-high,
.pill.attack-critical {
  background: rgba(255, 106, 106, 0.12);
  color: var(--danger);
}

@media (max-width: 980px) {
  .operations-grid,
  .dashboard-grid,
  .profile-studio-grid,
  .management-grid,
  .editor-layout,
  .split-panel,
  .json-columns,
  .workflow-grid {
    grid-template-columns: 1fr;
  }

  .builder-form,
  .field-grid,
  .rule-stat-grid {
    grid-template-columns: 1fr;
  }

  .shell-auth-strip {
    align-items: stretch;
  }
}