/* ============================================================
   CAMPAGNA ROMA — Sala Operativa
   Design system: command-center authority + Italian editorial gravitas
   ============================================================ */

:root {
  /* Surface palette — deep teal-navy chrome / warm cream documents */
  --ink-deep:      #050D14;   /* Deepest console field */
  --ink:           #0A1620;   /* Console frame */
  --ink-2:         #0E1F2C;   /* Panel surface */
  --ink-3:         #14293A;   /* Hover / panel internal */
  --card:          #1A2A22;   /* Deep console green-charcoal — agent card surface */
  --card-hover:    #0E1612;
  --card-line:     rgba(95,208,130,0.24);
  --card-glow:     #5FD082;     /* Vibrant emerald accent */

  /* Italian flag accents — muted/institutional palette */
  --flag-green:    #4A7150;
  --flag-white:    #C8C0A8;
  --flag-red:      #AB2330;
  --line-dark:     rgba(228,210,170,0.10);
  --line-dark-2:   rgba(228,210,170,0.18);

  --paper:         #F2ECDD;   /* Document cream */
  --paper-2:       #ECE4D2;   /* Cream variant */
  --paper-warm:    #FAF5E8;   /* Bright cream surface */
  --line:          #D8CFB8;
  --line-2:        #C4B89B;

  --text:          #1A1410;   /* Body ink on cream */
  --text-soft:     #4A413A;
  --text-muted:    #8B7F6E;
  --text-faint:    #B0A38C;

  --text-on-dark:        #F2ECDD;
  --text-on-dark-soft:   rgba(242,236,221,0.62);
  --text-on-dark-faint:  rgba(242,236,221,0.36);

  /* Accents — restrained, institutional */
  --brass:         #B8923A;   /* Aged brass / gold */
  --brass-deep:    #8E6F26;
  --brass-soft:    rgba(184,146,58,0.14);

  /* HUD signal — cyan/teal, premium not neon */
  --signal:        #5FD8CE;   /* Primary HUD cyan */
  --signal-bright: #7FE8DE;   /* Highlights */
  --signal-deep:   #3DA5A0;   /* Recessed */
  --signal-glow:   rgba(95,216,206,0.45);
  --signal-line:   rgba(95,216,206,0.32);
  --signal-soft:   rgba(95,216,206,0.10);
  --signal-faint:  rgba(95,216,206,0.05);

  /* Status (sober, not garish) */
  --ok:            #3F9A5E;
  --ok-bright:     #5FD082;
  --ok-soft:       rgba(95,208,130,0.14);
  --warn:          #D89544;
  --warn-bright:   #F5B768;
  --warn-soft:     rgba(216,149,68,0.14);
  --alert:         #D04A3A;
  --alert-bright:  #F26E5E;
  --alert-soft:    rgba(208,74,58,0.14);
  --critical:      #6B2D7E;
  --critical-soft: rgba(107,45,126,0.12);

  /* Fonts — tech console: mono for headings, sans for body */
  --f-display: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  --f-body:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:    'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  /* Geometry */
  --notch: 12px;
  --notch-sm: 8px;
  --notch-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ink-deep);
  color: var(--text);
  font-family: var(--f-body);
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  min-height: 100vh;
}

button, textarea, input { font-family: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
textarea::placeholder, input::placeholder { color: var(--text-faint); font-style: italic; }

/* Custom scroll */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(184,146,58,0.25); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: rgba(184,146,58,0.5); }

/* ============================================================
   ATMOSPHERIC LAYERS — subtle texture and grid
   ============================================================ */

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(95,216,206,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95,216,206,0.035) 1px, transparent 1px);
  background-size: 56px 56px;
}
.bg-vignette {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(95,216,206,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(184,146,58,0.05) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 0% 50%, rgba(95,216,206,0.04) 0%, transparent 70%);
}
.paper-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4  0 0 0 0 0.35  0 0 0 0 0.25  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.65; box-shadow: 0 0 0 4px transparent; }
}
@keyframes scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes sweep {
  0%   { transform: translateX(-30%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateX(130%); opacity: 0; }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}
@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.fade-up { animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.fade-in { animation: fadeIn 0.4s ease both; }
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }

/* ============================================================
   LAYOUT PRIMITIVES
   ============================================================ */

#app { position: relative; z-index: 1; min-height: 100vh; }
.shell { max-width: 1500px; margin: 0 auto; padding: 0 32px; }

/* Notched panel — uses clip-path to create chamfered corners */
.notched {
  clip-path: polygon(
    0 var(--notch), var(--notch) 0,
    calc(100% - var(--notch)) 0, 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, 0 calc(100% - var(--notch))
  );
}
.notched-tr {
  /* top-right notch only */
  clip-path: polygon(
    0 0, calc(100% - 16px) 0, 100% 16px,
    100% 100%, 0 100%
  );
}

/* Bracket corners for cream cards */
.brackets { position: relative; }
.brackets::before, .brackets::after,
.brackets > .br-tr, .brackets > .br-bl {
  content: ''; position: absolute; width: 14px; height: 14px;
  border: 1.5px solid var(--brass);
  pointer-events: none;
}
.brackets::before { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.brackets::after  { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.brackets > .br-tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.brackets > .br-bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }

/* ============================================================
   CLASSIFICATION BAR — top of viewport
   ============================================================ */

.classification {
  background: var(--ink-deep);
  border-bottom: 1px solid var(--line-dark);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--text-on-dark-soft);
  text-transform: uppercase;
  position: sticky; top: 0; z-index: 50;
}
.classification-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 28px;
  gap: 24px;
  flex-wrap: wrap;
}
.cls-left, .cls-right { display: flex; align-items: center; gap: 18px; }
.cls-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 2px 10px;
  background: rgba(178,58,42,0.18);
  color: #E8B7AF;
  border: 1px solid rgba(178,58,42,0.35);
  font-weight: 500;
}
.cls-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--signal); color: var(--signal);
  animation: pulse 2.2s ease-in-out infinite;
}
.cls-divider { width: 1px; height: 11px; background: var(--line-dark-2); }
.cls-claim {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.20em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 500;
}
.cls-claim b {
  color: var(--brass);
  font-weight: 700;
  letter-spacing: 0.12em;
}

/* Full-width Italian tricolor accent — muted, runs under the classification bar */
.global-tricolor {
  position: sticky; top: 35px; z-index: 49;
  display: flex;
  height: 4px;
  width: 100%;
}
.global-tricolor i { flex: 1; display: block; }
.global-tricolor i:nth-child(1) { background: var(--flag-green); }
.global-tricolor i:nth-child(2) { background: var(--flag-white); }
.global-tricolor i:nth-child(3) { background: var(--flag-red); }

/* ============================================================
   BRIEF OPERATIVO — left rail status
   ============================================================ */

.brief-grid { display: flex; flex-direction: column; }
.brief-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-dark);
  font-size: 12.5px;
}
.brief-row:last-child { border-bottom: none; }
.bk {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}
.bv {
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.04em;
}

/* ============================================================
   CONSOLE FRAME — outer wrapper, header, footer
   ============================================================ */

.console {
  position: relative;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 28px 28px;
}

/* Console title row — Sala Operativa header */
.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 26px 4px 22px;
  border-bottom: 1px solid var(--line-dark-2);
  position: relative;
  margin-bottom: 22px;
}
.console-title {
  display: inline-flex;
  align-items: center;
  font-family: var(--f-display);
  text-transform: uppercase;
  color: var(--text-on-dark);
}
.console-title .ct-main {
  font-size: 17px; font-weight: 600;
  letter-spacing: 0.46em;
}

/* Product brief — between Sala Operativa header and Rete di Sicurezza banner */
.product-intro {
  margin: 0 0 22px;
  padding: 18px 24px 20px;
  border: 1px solid rgba(242,236,221,0.12);
  border-left: 3px solid rgba(242,236,221,0.55);
  background: linear-gradient(90deg, rgba(242,236,221,0.025), transparent 70%);
  display: flex;
  justify-content: center;
  align-items: center;
}
.product-intro-label {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.30em; text-transform: uppercase;
  color: transparent; font-weight: 600;
  padding-top: 4px;
  display: flex; align-items: center; gap: 10px;
}
.product-intro-label::after {
  content: ''; flex: 1; height: 1px;
  background: rgba(242,236,221,0.22);
  margin-right: -10px;
}
.product-intro-text {
  font-family: var(--f-display);
  font-size: 13.5px; line-height: 1.75;
  letter-spacing: 0.01em;
  color: var(--text-on-dark-soft);
  max-width: 1100px;
  text-align: center;
}
.product-intro-text b {
  color: var(--text-on-dark);
  font-weight: 700;
}
.product-intro-text em {
  color: var(--paper);
  font-style: normal;
  font-weight: 600;
}

@media (max-width: 880px) {
  .product-intro {
    grid-template-columns: 1fr;
    padding: 16px 18px 18px;
  }
  .product-intro-label::after { display: none; }
}

/* Section divider — quiet break, neutral tones, dual-weight lines, no animations */
.section-divider {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 38px 0 30px;
  padding: 0 4px;
}
.section-divider[onclick] { cursor: pointer; }
.section-divider[onclick]:hover .section-divider-label {
  border-color: rgba(242,236,221,0.50);
  background: rgba(242,236,221,0.08);
}
.section-divider[onclick] .arrow {
  transition: transform 0.3s ease;
}

/* Collapsible console panel */
#console-panel {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  overflow: hidden;
  transition: grid-template-rows 0.45s cubic-bezier(0.16,1,0.3,1),
              opacity 0.3s ease;
}
#console-panel.collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
}
#console-panel > * {
  min-height: 0;
  overflow: hidden;
}
.section-divider-rule {
  flex: 1;
  position: relative;
  height: 14px;
}
/* Primary 2px line */
.section-divider-rule::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 5px;
  height: 2px;
}
.section-divider-rule.left::before {
  background: linear-gradient(90deg, transparent, rgba(242,236,221,0.55) 50%, rgba(242,236,221,0.55));
}
.section-divider-rule.right::before {
  background: linear-gradient(90deg, rgba(242,236,221,0.55), rgba(242,236,221,0.55) 50%, transparent);
}
/* Secondary 1px line below */
.section-divider-rule::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 11px;
  height: 1px;
}
.section-divider-rule.left::after {
  background: linear-gradient(90deg, transparent, rgba(242,236,221,0.18) 50%, rgba(242,236,221,0.18));
}
.section-divider-rule.right::after {
  background: linear-gradient(90deg, rgba(242,236,221,0.18), rgba(242,236,221,0.18) 50%, transparent);
}

/* Central badge — neutral, static */
.section-divider-label {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.30em; text-transform: uppercase;
  color: var(--paper); font-weight: 600;
  border: 1px solid rgba(242,236,221,0.28);
  background: rgba(242,236,221,0.04);
}
.section-divider-label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--paper);
  flex-shrink: 0;
  opacity: 0.75;
}
.section-divider-label .arrow {
  color: var(--paper);
  font-size: 12px;
  opacity: 0.75;
}
.section-divider-label .step {
  color: var(--text-on-dark-faint);
  font-weight: 500;
  letter-spacing: 0.28em;
  font-size: 10px;
  padding-right: 10px;
  border-right: 1px solid rgba(242,236,221,0.22);
}
.brand-mark {
  display: flex; align-items: flex-end; gap: 18px;
  color: var(--text-on-dark);
}
.brand-stack { display: flex; flex-direction: column; gap: 6px; }
.brand-mark .b-eyebrow {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  font-weight: 500;
}
.brand-mark .b-title {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-on-dark);
  white-space: nowrap;
}
.brand-mark .b-title em {
  color: var(--brass);
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark .b-tricolor {
  display: inline-flex;
  height: 3px;
  width: 132px;
  margin-top: 4px;
  border: 1px solid rgba(0,0,0,0.5);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04);
}
.brand-mark .b-tricolor i {
  flex: 1;
  display: block;
}
.brand-mark .b-tricolor i:nth-child(1) { background: var(--flag-green); }
.brand-mark .b-tricolor i:nth-child(2) { background: var(--flag-white); }
.brand-mark .b-tricolor i:nth-child(3) { background: var(--flag-red); }
.brand-mark .b-version {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--signal);
  border: 1px solid var(--signal-line);
  padding: 3px 8px;
  align-self: flex-end;
  margin-bottom: 2px;
}

.console-tagline {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  text-align: center;
  display: flex; align-items: center; gap: 14px; justify-content: center;
}
.console-tagline .sep {
  display: inline-block; width: 24px; height: 1px;
  background: var(--signal-line);
}
.console-tagline em {
  color: var(--signal); font-style: normal; font-weight: 500;
}

.console-status {
  display: flex; align-items: center; gap: 22px;
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-on-dark-soft);
}
.console-status .stat-item { display: inline-flex; align-items: center; gap: 8px; }
.console-status .stat-item b {
  color: var(--signal-bright); font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.console-status .stat-divider {
  width: 1px; height: 14px; background: var(--signal-line);
}

/* ============================================================
   PANEL — base HUD chrome with cyan corner brackets
   ============================================================ */

.panel {
  position: relative;
  background: var(--ink-2);
  border: 1px solid var(--signal-line);
  box-shadow:
    0 0 0 1px var(--signal-faint),
    inset 0 0 40px rgba(95,216,206,0.025),
    0 6px 24px -8px rgba(0,0,0,0.6);
  /* notched bottom-left + top-right corners (mirror standard) */
  clip-path: polygon(
    var(--notch) 0,
    100% 0,
    100% calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%,
    0 100%,
    0 var(--notch)
  );
}
/* cyan corner brackets removed for cleaner look */
.panel::before, .panel::after { content: none; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px 12px 22px;
  border-bottom: 1px solid var(--signal-line);
  background: linear-gradient(90deg, rgba(95,216,206,0.06), transparent 70%);
}
.panel-title {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--signal-bright); font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px;
}
.panel-title .pdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--signal-bright);
  box-shadow: 0 0 10px var(--signal-glow);
}
.panel-title .pcode {
  color: var(--brass); font-weight: 600;
  letter-spacing: 0.12em;
}
.panel-tag {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}
.panel-tag .tg-live {
  color: var(--ok-bright);
  display: inline-flex; align-items: center; gap: 6px;
}
.panel-tag .tg-live .ld {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok-bright);
  box-shadow: 0 0 6px var(--ok-bright);
  animation: glowPulse 1.6s ease-in-out infinite;
}

.panel-body { padding: 18px 22px 20px; position: relative; }

/* ============================================================
   FRAMED GRID — agents on perimeter, summary panel at center
   ============================================================ */

.framed-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(480px, 1.55fr) minmax(320px, 1fr);
  grid-template-rows: auto auto auto;
  gap: 22px;
  align-items: stretch;
}

.framed-grid > .card-1 { grid-column: 1; grid-row: 1; }
.framed-grid > .card-2 { grid-column: 1; grid-row: 2; }
.framed-grid > .card-3 { grid-column: 1; grid-row: 3; }
.framed-grid > .card-4 { grid-column: 3; grid-row: 1; }
.framed-grid > .card-5 { grid-column: 3; grid-row: 2 / span 2; }
.framed-grid > .center-panel-frame {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-items: stretch;
}

/* ============================================================
   AGENT CARD — perimeter dossier, with HUD chrome
   ============================================================ */

.agent-card {
  position: relative;
  background: var(--card);
  color: var(--text-on-dark);
  border: 1px solid var(--card-line);
  box-shadow:
    0 0 0 1px rgba(95,208,130,0.06),
    inset 0 0 50px rgba(0,0,0,0.35),
    0 6px 28px -10px rgba(0,0,0,0.8);
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1), background 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* clip-path for subtle notched corners (top-left + bottom-right) */
.agent-card {
  clip-path: polygon(
    var(--notch) 0,
    100% 0,
    100% calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%,
    0 100%,
    0 var(--notch)
  );
}
/* Subtle emerald corner accents — agent cards only */
.agent-card::before {
  content: ''; position: absolute;
  top: 0; left: 0;
  width: 18px; height: 18px;
  border-top: 1px solid var(--card-glow);
  border-left: 1px solid var(--card-glow);
  pointer-events: none;
  opacity: 0.65;
  filter: drop-shadow(0 0 3px rgba(95,208,130,0.45));
  z-index: 4;
  transition: opacity 0.3s ease;
}
.agent-card::after {
  content: ''; position: absolute;
  bottom: 0; right: 0;
  width: 18px; height: 18px;
  border-bottom: 1px solid var(--card-glow);
  border-right: 1px solid var(--card-glow);
  pointer-events: none;
  opacity: 0.65;
  filter: drop-shadow(0 0 3px rgba(95,208,130,0.45));
  z-index: 4;
  transition: opacity 0.3s ease;
}
.agent-card:hover::before, .agent-card:hover::after { opacity: 1; }
.agent-card:hover {
  background: var(--card-hover);
  border-color: rgba(95,208,130,0.48);
  transform: translateY(-2px);
}

/* color spine — vibrant emerald, uniform across all agents */
.agent-card .ac-spine {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 3px;
  background: var(--card-glow);
  box-shadow: 0 0 16px -1px rgba(95,208,130,0.6);
  opacity: 0.95;
  transition: width 0.3s ease, opacity 0.3s ease;
  z-index: 3;
}
.agent-card:hover .ac-spine { width: 4px; opacity: 1; }

.ac-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px 12px 22px;
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-soft);
  border-bottom: 1px solid rgba(95,208,130,0.20);
  background: linear-gradient(90deg, rgba(95,208,130,0.08), transparent 70%);
}
.ac-head .ac-id { color: var(--brass); font-weight: 600; letter-spacing: 0.12em; }
.ac-head .ac-id .div { opacity: 0.5; margin: 0 6px; }
.ac-head .ac-tag { color: var(--text-on-dark-soft); }
.ac-head .ac-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 9.5px;
  color: var(--ok-bright);
  letter-spacing: 0.18em;
}
.ac-head .ac-status .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok-bright);
  box-shadow: 0 0 6px var(--ok-bright);
  animation: glowPulse 2s ease-in-out infinite;
}

.ac-body {
  padding: 26px 28px 20px 30px;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
}
.ac-name {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 60, "SOFT" 30, "wght" 500;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--text-on-dark);
  margin-bottom: 5px;
}
.ac-role {
  font-family: var(--f-display);
  font-style: normal; font-weight: 500;
  font-size: 13px;
  color: var(--brass);
  margin-bottom: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ac-desc {
  font-family: var(--f-display);
  font-size: 13px; line-height: 1.65;
  letter-spacing: 0.01em;
  color: var(--text-on-dark-soft);
  padding-bottom: 16px;
  border-bottom: 1px dashed rgba(95,208,130,0.24);
  margin-bottom: 14px;
  flex: 1;
}
.ac-modes {
  display: flex; gap: 7px; flex-wrap: wrap;
}
.ac-mode {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.16em;
  padding: 7px 11px;
  background: rgba(95,208,130,0.06);
  color: #ffffff;
  border: 1px solid rgba(95,208,130,0.32);
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s ease, box-shadow 0.25s ease;
}
.agent-card:hover .ac-mode {
  background: rgba(95,208,130,0.10);
  border-color: rgba(95,208,130,0.45);
}
.ac-mode:hover {
  background: rgba(95,208,130,0.20) !important;
  color: #ffffff;
  border-color: rgba(95,208,130,0.75) !important;
  transform: translateY(-1px);
  box-shadow:
    0 0 14px -2px rgba(95,208,130,0.55),
    inset 0 0 18px rgba(95,208,130,0.12);
}
/* Sweep highlight on hover */
.ac-mode::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -120%;
  width: 60%;
  background: linear-gradient(90deg, transparent, rgba(95,208,130,0.25), transparent);
  transition: left 0.55s ease;
  pointer-events: none;
}
.ac-mode:hover::after { left: 130%; }
.ac-mode:active {
  transform: translateY(0) scale(0.97);
  animation: chipPulse 0.45s ease;
}
@keyframes chipPulse {
  0%   { box-shadow: 0 0 0 0 rgba(95,208,130,0.55); }
  50%  { box-shadow: 0 0 22px 6px rgba(95,208,130,0.45); }
  100% { box-shadow: 0 0 0 0 rgba(95,208,130,0); }
}

.ac-foot {
  padding: 10px 18px 10px 22px;
  border-top: 1px solid rgba(95,208,130,0.20);
  background: rgba(0,0,0,0.32);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}
.ac-foot .open {
  color: var(--brass); font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  transition: gap 0.25s ease, color 0.25s ease;
}
.agent-card:hover .ac-foot .open { gap: 14px; color: #D4AF55; }

/* ============================================================
   CENTER PANEL — Briefing aggregato, empty state premium
   ============================================================ */

/* Outer "lifted paper" shadow lives on a wrapper so clip-path on the panel
   doesn't clip it. The wrapper carries the drop-shadow + 3D tilt; the inner
   panel keeps the notched clip-path, border, inset highlight. */
.center-panel-frame {
  position: relative;
  display: flex;
  filter:
    drop-shadow(0 18px 22px rgba(0,0,0,0.85))
    drop-shadow(0 50px 70px rgba(0,0,0,0.75));
  transform-origin: center center;
  transition: filter 0.4s cubic-bezier(0.16,1,0.3,1);
  will-change: transform, filter;
}
.center-panel-frame:hover {
  filter:
    drop-shadow(0 32px 36px rgba(0,0,0,0.95))
    drop-shadow(0 80px 130px rgba(0,0,0,0.85));
}
.center-panel-frame.is-resetting {
  transition: transform 0.55s cubic-bezier(0.16,1,0.3,1),
              filter 0.4s cubic-bezier(0.16,1,0.3,1);
}

.center-panel {
  position: relative;
  width: 100%;
  /* Subtle elevation: a hair lighter than --ink-deep so the cast shadow can read */
  background: #0F141B;
  border: 1px solid rgba(184,146,58,0.36);
  box-shadow:
    0 0 0 1px rgba(184,146,58,0.06),
    inset 0 0 80px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.025);
  display: flex; flex-direction: column;
  min-height: 600px;
  transition: border-color 0.4s ease,
              box-shadow 0.4s cubic-bezier(0.16,1,0.3,1),
              background 0.4s ease;
  clip-path: polygon(
    var(--notch-lg) 0,
    100% 0,
    100% calc(100% - var(--notch-lg)),
    calc(100% - var(--notch-lg)) 100%,
    0 100%,
    0 var(--notch-lg)
  );
}
.center-panel-frame:hover .center-panel {
  background: #131923;
  border-color: rgba(184,146,58,0.6);
  box-shadow:
    0 0 0 1px rgba(184,146,58,0.14),
    inset 0 0 90px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.04);
}
.center-panel::before, .center-panel::after { content: none; }

.cp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(184,146,58,0.24);
  background: linear-gradient(90deg, rgba(184,146,58,0.08), transparent 70%);
}
.cp-title {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 36, "SOFT" 30, "wght" 500;
  font-size: 24px;
  color: var(--text-on-dark);
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 14px;
}
.cp-title .pcode {
  font-family: var(--f-mono); font-size: 10px;
  font-weight: 600; letter-spacing: 0.14em;
  color: var(--brass);
  border: 1px solid rgba(184,146,58,0.4);
  padding: 4px 8px;
  text-transform: uppercase;
}
.cp-status {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  display: inline-flex; align-items: center; gap: 7px;
}
.cp-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 8px var(--brass);
  animation: glowPulse 2.4s ease-in-out infinite;
}

/* Sub-banner inside center panel — operative brief in mono */
.cp-subbanner {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  padding: 14px 28px 16px;
  border-bottom: 1px solid rgba(184,146,58,0.18);
  background: linear-gradient(90deg, rgba(184,146,58,0.05), transparent 80%);
}
.cp-sub-item {
  display: flex; flex-direction: column; gap: 5px;
  padding-left: 14px;
  border-left: 1px dashed var(--line-dark);
  min-width: 0;
}
.cp-sub-item:first-child {
  border-left: none;
  padding-left: 0;
}
.cp-sub-key {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  white-space: nowrap;
}
.cp-sub-val {
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-body {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 32px;
  position: relative;
}
.cp-reticle {
  position: relative;
  width: 200px; height: 200px;
  margin-bottom: 28px;
}
.cp-reticle svg { width: 100%; height: 100%; display: block; }
.cp-reticle .ring-rotate { transform-origin: center; animation: spin 18s linear infinite; }
.cp-reticle .ring-rotate-rev { transform-origin: center; animation: spin 30s linear infinite reverse; }

.cp-state {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 14px;
  padding: 6px 14px;
  border: 1px solid rgba(184,146,58,0.4);
  background: rgba(184,146,58,0.08);
}
.cp-headline {
  font-family: var(--f-display);
  font-size: 15.5px; font-weight: 600;
  color: var(--text-on-dark);
  text-align: center;
  margin-bottom: 12px;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cp-sub {
  font-family: var(--f-display); font-size: 13px;
  color: var(--text-on-dark-soft);
  text-align: center;
  max-width: 520px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  margin-bottom: 40px;
}

.cp-feeders {
  width: 100%; max-width: 460px;
  border-top: 1px dashed rgba(184,146,58,0.24);
  padding-top: 24px;
}
.cp-feeders-label {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  text-align: center;
  margin-bottom: 14px;
}
.cp-feeders-list {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.cp-feeder {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 500;
  padding: 3px 9px;
  border: 1px solid rgba(95,216,206,0.16);
  background: transparent;
  display: inline-flex; align-items: center; gap: 7px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.cp-feeder:hover {
  color: var(--signal-bright);
  border-color: rgba(95,216,206,0.48);
  background: rgba(95,216,206,0.04);
}
.cp-feeder .num {
  color: var(--brass); font-weight: 600;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}
.cp-feeder:hover .num { opacity: 1; }
.cp-feeder.is-rete {
  color: rgba(232,168,158,0.82);
  border-color: rgba(208,74,58,0.20);
  background: transparent;
}
.cp-feeder.is-rete:hover {
  color: var(--alert-bright);
  border-color: rgba(208,74,58,0.55);
  background: rgba(208,74,58,0.04);
}
.cp-feeder.is-rete .num { color: rgba(232,168,158,0.85); }
.cp-feeder.is-rete:hover .num { color: var(--alert-bright); opacity: 1; }

/* ============================================================
   RETE BAR — bottom strip, full width
   ============================================================ */

.rete-bar {
  margin-top: 18px;
  margin-bottom: 36px;
  position: relative;
  /* Middle ground — clearly elevated from the page, only a hint of warm cast */
  background: linear-gradient(180deg, #14111A 0%, #0F0C12 100%);
  border: 1px solid rgba(178,58,42,0.30);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.03),
    inset 0 0 80px rgba(178,58,42,0.025),
    0 18px 30px -12px rgba(0,0,0,0.78),
    0 44px 80px -28px rgba(0,0,0,0.62);
  padding: 0;
  display: grid;
  grid-template-columns: 4px auto 1fr auto;
  align-items: stretch;
  gap: 0;
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.4s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}
.rete-bar:hover {
  border-color: rgba(208,74,58,0.48);
  background: linear-gradient(180deg, #1A1421 0%, #140F18 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 0 90px rgba(178,58,42,0.05),
    0 26px 36px -12px rgba(0,0,0,0.86),
    0 60px 120px -30px rgba(0,0,0,0.74);
}

/* Red institutional spine on the left edge */
.rete-spine {
  background: linear-gradient(180deg, #B23A2A 0%, #8E2D20 100%);
  box-shadow: 0 0 12px -2px rgba(208,74,58,0.55);
}

/* Shield icon block */
.rete-glyph {
  display: grid; place-items: center;
  width: 64px;
  background: rgba(178,58,42,0.06);
  border-right: 1px solid rgba(178,58,42,0.18);
  color: #E8B0A6;
}
.rete-glyph svg {
  width: 26px; height: 26px;
  filter: drop-shadow(0 0 6px rgba(208,74,58,0.35));
}

/* Center text column */
.rete-text {
  color: var(--text-on-dark);
  padding: 18px 28px 18px 24px;
  display: flex; flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.rete-tag {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.30em; text-transform: uppercase;
  color: #E8A89E;
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 500;
}
.rete-tag::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alert-bright);
  box-shadow: 0 0 8px var(--alert-bright);
  animation: pulse 2s ease-in-out infinite;
}
.rete-name {
  font-family: var(--f-display);
  font-size: 18px; font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
}
.rete-desc {
  font-family: var(--f-display);
  font-size: 12.5px;
  color: var(--text-on-dark-soft);
  line-height: 1.6;
  letter-spacing: 0.01em;
  max-width: 820px;
  margin-top: 2px;
}

/* Metadata strip */
.rete-meta {
  display: flex; align-items: center; gap: 16px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.rete-meta-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}
.rete-meta-item b {
  color: #E8A89E; font-weight: 600;
}
.rete-meta-divider {
  width: 1px; height: 10px;
  background: rgba(178,58,42,0.22);
}

/* Right CTA column */
.rete-action {
  display: flex; align-items: center;
  padding: 0 22px;
  border-left: 1px solid rgba(178,58,42,0.18);
  background: rgba(178,58,42,0.04);
}
.rete-cta {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: #F2D1CB; font-weight: 600;
  padding: 12px 20px;
  border: 1px solid rgba(208,74,58,0.45);
  background: rgba(208,74,58,0.10);
  display: inline-flex; align-items: center; gap: 12px;
  transition: gap 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  white-space: nowrap;
}
.rete-cta-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: 1px solid currentColor;
  font-size: 10px;
}
.rete-bar:hover .rete-cta {
  gap: 16px;
  background: rgba(208,74,58,0.20);
  border-color: rgba(208,74,58,0.65);
  color: #FFE1DA;
}

/* ============================================================
   FOOTER — compact mono strip
   ============================================================ */

.console-foot {
  margin-top: 24px;
  padding: 14px 4px 6px;
  border-top: 1px solid var(--line-dark);
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  flex-wrap: wrap; gap: 12px;
}
.console-foot .foot-warn {
  color: var(--warn-bright);
  display: inline-flex; align-items: center; gap: 8px;
}
.console-foot b { color: var(--signal); font-weight: 500; }
.admin-link {
  background: none; border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark-faint);
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 6px 12px; cursor: pointer;
  transition: all 0.2s;
}
.admin-link:hover { color: var(--signal); border-color: var(--signal-line); }
.console-foot-actions { display: flex; gap: 6px; }

/* ============================================================
   AGENT PAGE
   ============================================================ */

.agent-header {
  background: var(--ink);
  position: sticky; top: 35px; z-index: 30;
  border-bottom: 1px solid var(--line-dark);
  padding: 18px 0;
  overflow: hidden;
}
.agent-header-inner {
  max-width: 1500px; margin: 0 auto; padding: 0 32px;
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  align-items: center;
  gap: 24px;
}
.agent-header-inner > .header-spacer { display: block; }
.btn-back {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 500;
  padding: 9px 14px;
  border: 1px solid var(--line-dark-2);
  background: transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-back:hover { background: rgba(242,236,221,0.05); color: var(--paper); }

.agent-header-center { text-align: center; }
.agent-header-id {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.32em; color: var(--brass);
  text-transform: uppercase; font-weight: 500;
  margin-bottom: 4px;
}
.agent-header-name {
  font-family: var(--f-display);
  font-size: 18px; font-weight: 600;
  color: var(--paper);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 12px;
}
.agent-header-name .gly {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  padding: 4px;
  border: 1px solid rgba(184,146,58,0.4);
  background: rgba(184,146,58,0.06);
  color: var(--brass);
}
.agent-header-name .gly svg { width: 100%; height: 100%; display: block; }

/* Workspace — dark console surface */
.workspace {
  background: var(--ink-deep);
  min-height: calc(100vh - 100px);
  padding-bottom: 80px;
  position: relative;
}
.workspace-inner {
  max-width: 1200px; margin: 0 auto; padding: 36px 32px 0;
  position: relative;
  z-index: 1;
}

/* ============================================================
   CHAT LAYOUT — sticky input, scrollable output
   ============================================================ */

/* Lock body scroll when chat layout is active */
body.chat-active {
  overflow: hidden;
  height: 100vh;
}
body.chat-active #app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--ink-deep);
  position: relative;
  overflow: hidden;
}

/* Scrollable output area */
.chat-output {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.chat-output-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 24px;
}

/* Sticky input bar at bottom */
.chat-input-bar {
  flex-shrink: 0;
  background: var(--ink);
  border-top: 1px solid var(--line-dark-2);
  padding: 0;
  position: relative;
  z-index: 10;
}
.chat-input-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 32px 14px;
}

/* Mode tabs — compact horizontal row */
.chat-modes {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.chat-mode-btn {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 5px 12px;
  color: var(--text-on-dark-faint);
  background: transparent;
  border: 1px solid var(--line-dark-2);
  cursor: pointer;
  transition: all 0.18s ease;
}
.chat-mode-btn:hover {
  color: var(--text-on-dark);
  border-color: var(--signal-line);
  background: rgba(95,216,206,0.04);
}
.chat-mode-btn.active {
  color: var(--signal-bright);
  border-color: var(--signal);
  background: rgba(95,216,206,0.08);
}

/* Channel select inline with modes */
.chat-channel-select-wrap {
  margin-left: auto;
}

/* Input row — textarea + send button */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line-dark-2);
  background: rgba(5,13,20,0.65);
  color: var(--text-on-dark);
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.chat-textarea::placeholder {
  color: var(--text-on-dark-faint);
  font-style: italic;
}
.chat-textarea:focus {
  border-color: var(--signal);
  background: rgba(5,13,20,0.85);
}
.chat-no-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--text-on-dark-faint);
  letter-spacing: 0.04em;
  border: 1px dashed var(--line-dark-2);
  background: rgba(5,13,20,0.35);
}
.chat-send-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: rgba(95,216,206,0.10);
  border: 1px solid var(--signal-line);
  color: var(--signal-bright);
  cursor: pointer;
  transition: all 0.2s ease;
}
.chat-send-btn:hover:not(:disabled) {
  background: rgba(95,216,206,0.20);
  color: #B6F2EC;
}
.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: progress;
}
.chat-send-arrow {
  font-family: var(--f-mono);
  font-size: 16px;
  font-weight: 600;
}
.chat-disclaimer {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--warn-bright);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-disclaimer::before {
  content: '◮';
  font-size: 11px;
}

/* Light theme chat */
body.light .chat-layout { background: var(--ink-deep); }
body.light .chat-input-bar { background: var(--ink); border-top-color: rgba(26,20,16,0.16); }
body.light .chat-mode-btn { color: var(--text-muted); border-color: rgba(26,20,16,0.16); }
body.light .chat-mode-btn:hover { color: var(--text); border-color: rgba(56,116,76,0.40); background: rgba(56,116,76,0.04); }
body.light .chat-mode-btn.active { color: var(--signal-bright); border-color: var(--signal); background: rgba(56,116,76,0.08); }
body.light .chat-textarea { background: #FFFFFF; border-color: rgba(26,20,16,0.18); color: var(--text); }
body.light .chat-textarea:focus { border-color: var(--signal); }
body.light .chat-no-input { background: rgba(255,255,255,0.5); border-color: rgba(26,20,16,0.16); color: var(--text-muted); }
body.light .chat-send-btn { background: rgba(44,117,112,0.10); border-color: rgba(44,117,112,0.35); color: var(--signal-bright); }

@media (max-width: 880px) {
  .chat-output-inner { padding: 20px 16px 16px; }
  .chat-input-inner { padding: 10px 16px 12px; }
}

/* Onboard panel — dark briefing card */
.onboard {
  display: block;
  background: var(--ink-2);
  border: 1px solid var(--signal-line);
  padding: 22px 26px 22px 30px;
  margin-bottom: 28px;
  position: relative;
  box-shadow:
    0 0 0 1px var(--signal-faint),
    inset 0 0 30px rgba(95,216,206,0.025);
}
.onboard-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #3F7A4E;
  box-shadow: 0 0 12px -2px #3F7A4E;
}
.onboard-label {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.22em; color: var(--signal-bright);
  text-transform: uppercase; font-weight: 600;
  margin-bottom: 12px;
}
.onboard-text {
  font-family: var(--f-body); font-weight: 400;
  font-size: 14.5px; line-height: 1.65;
  color: var(--text-on-dark-soft);
}

/* Login background */
.login-bg {
  position: fixed; inset: 0; z-index: -2;
  background: url('/static/img/colosseo.jpg') center center / cover no-repeat;
}
.login-bg-overlay {
  position: fixed; inset: 0; z-index: -1;
  background: rgba(8,11,14,0.65);
  backdrop-filter: blur(8px) saturate(1.2);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
}
.login-spotlight {
  position: fixed; z-index: -1;
  inset: 0;
  background: url('/static/img/colosseo.jpg') center center / cover no-repeat;
  pointer-events: none;
  opacity: 0.7;
  mask-image: radial-gradient(circle 140px at var(--spot-x, -200px) var(--spot-y, -200px), rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: radial-gradient(circle 140px at var(--spot-x, -200px) var(--spot-y, -200px), rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
}

/* Briefing panel — dark HUD surface with cyan brackets */
.briefing-panel {
  background: var(--ink-2);
  border: 1px solid var(--signal-line);
  padding: 28px;
  margin-bottom: 22px;
  position: relative;
  box-shadow:
    0 0 0 1px var(--signal-faint),
    inset 0 0 40px rgba(95,216,206,0.025),
    0 6px 24px -8px rgba(0,0,0,0.6);
  clip-path: polygon(
    var(--notch) 0,
    100% 0,
    100% calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%,
    0 100%,
    0 var(--notch)
  );
}
.briefing-panel::before, .briefing-panel::after { content: none; }

.briefing-label {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.22em; color: var(--signal-bright);
  text-transform: uppercase; font-weight: 600;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 10px;
}
.briefing-label::after { content: ''; flex: 1; height: 1px; background: var(--signal-line); }

/* Mode selector — dark HUD tabs */
.mode-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}
.mode-tab {
  position: relative;
  text-align: left;
  padding: 16px 20px;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 16px;
  align-items: center;
  color: var(--text-on-dark);
}
.mode-tab:hover {
  border-color: var(--signal-line);
  background: rgba(95,216,206,0.04);
}
.mode-tab.active {
  background: rgba(95,216,206,0.07);
  border-color: var(--signal);
  box-shadow: inset 3px 0 0 0 #3F7A4E;
}
.mode-tab.active .mt-num { color: var(--signal-bright); }
.mode-tab.active .mt-name { color: var(--signal-bright); }
.mode-tab.active .mt-desc { color: var(--text-on-dark); }
.mode-tab.active .mt-arrow { color: var(--signal-bright); opacity: 1; }

.mt-num {
  font-family: var(--f-mono); font-size: 11px;
  font-weight: 600;
  color: var(--brass);
  letter-spacing: 0.05em;
}
.mt-name {
  font-family: var(--f-display); font-weight: 500;
  font-size: 14.5px;
  letter-spacing: 0.02em;
  margin-bottom: 3px;
  color: var(--text-on-dark);
  text-transform: uppercase;
}
.mt-desc { font-size: 12.5px; color: var(--text-on-dark-soft); line-height: 1.5; }
.mt-arrow { font-family: var(--f-mono); font-size: 14px; color: var(--text-on-dark-faint); opacity: 0.7; transition: all 0.2s ease; }

/* Input area — dark terminal field */
.input-block { margin-bottom: 18px; }
.input-label {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.22em; color: var(--text-on-dark-soft);
  text-transform: uppercase; font-weight: 600;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.input-label::after { content: ''; flex: 1; height: 1px; background: var(--line-dark-2); }

.input-field {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line-dark-2);
  background: rgba(5,13,20,0.65);
  color: var(--text-on-dark);
  font-size: 14.5px; line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: var(--f-body);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.input-field::placeholder { color: var(--text-on-dark-faint); font-style: italic; }
.input-field:focus {
  border-color: var(--signal);
  background: rgba(5,13,20,0.85);
  box-shadow: 0 0 0 3px rgba(95,216,206,0.12);
}

/* Run button — HUD execution control */
.btn-run {
  width: 100%;
  padding: 18px 24px;
  background: rgba(95,216,206,0.08);
  color: var(--signal-bright);
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  border: 1px solid var(--signal-line);
  box-shadow:
    0 0 0 1px var(--signal-faint),
    inset 0 0 24px rgba(95,216,206,0.04);
}
.btn-run::before, .btn-run::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  border: 1px solid var(--signal-bright);
  pointer-events: none;
  transition: all 0.25s ease;
  filter: drop-shadow(0 0 3px var(--signal-glow));
}
.btn-run::before { top: 0; left: 0; border-right: none; border-bottom: none; }
.btn-run::after  { bottom: 0; right: 0; border-left: none; border-top: none; }
.btn-run:hover:not(:disabled) {
  background: rgba(95,216,206,0.16);
  letter-spacing: 0.28em;
  color: #B6F2EC;
}
.btn-run:disabled {
  background: rgba(10,22,32,0.6); cursor: progress;
  color: var(--text-on-dark-faint);
  border-color: var(--line-dark-2);
}
.btn-run .arrow {
  font-family: var(--f-mono); font-size: 14px;
}

/* Loading state */
.loading-block {
  display: none;
  text-align: center;
  padding: 56px 0;
}
.loading-block.active { display: block; }
.loading-spin {
  width: 48px; height: 48px;
  margin: 0 auto 18px;
  position: relative;
}
.loading-spin::before, .loading-spin::after {
  content: ''; position: absolute; inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--signal-bright);
  border-radius: 50%;
}
.loading-spin::before { animation: spin 1.4s linear infinite; filter: drop-shadow(0 0 4px var(--signal-glow)); }
.loading-spin::after {
  border-top-color: var(--brass);
  animation: spin 2s linear infinite reverse;
  inset: 6px;
}
.loading-text {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 500;
}
.loading-text::after { content: ''; animation: blink 1s steps(1) infinite; }
.loading-text::after { content: ' ▮'; }

/* ============================================================
   RESULT — Intel Report styling
   ============================================================ */

.result-block { display: none; margin-top: 22px; }
.result-block.active { display: block; }
.result-frame {
  background: var(--ink-2);
  border: 1px solid var(--signal-line);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--signal-faint),
    inset 0 0 60px rgba(95,216,206,0.02),
    0 6px 30px -10px rgba(0,0,0,0.7);
  clip-path: polygon(
    var(--notch) 0,
    100% 0,
    100% calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%,
    0 100%,
    0 var(--notch)
  );
}
.result-frame::before, .result-frame::after { content: none; }
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, rgba(95,216,206,0.08), transparent 70%);
  color: var(--text-on-dark);
  border-bottom: 1px solid var(--signal-line);
}
.result-header .left {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
}
.result-header .left .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  color: var(--brass);
}
.result-header .left .icon svg { width: 16px; height: 16px; display: block; }
.result-header .left .agent-name { color: var(--signal-bright); font-weight: 600; }
.result-header .left .mode { color: var(--text-on-dark-soft); }
.result-header .left .div { width: 1px; height: 12px; background: var(--signal-line); }

.btn-copy {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--signal-bright); font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--signal-line);
  background: rgba(95,216,206,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-copy:hover { background: rgba(95,216,206,0.16); color: #B6F2EC; }
.btn-copy.copied { color: #B7E3C0; border-color: rgba(63,122,78,0.5); background: rgba(63,122,78,0.18); }

.result-body { padding: 30px 36px; color: var(--text-on-dark); }

.result-disclaimer {
  padding: 12px 22px;
  background: rgba(216,149,68,0.08);
  border-top: 1px solid var(--line-dark-2);
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--warn-bright);
}
.result-disclaimer::before {
  content: '◮'; font-size: 14px;
}

/* ============================================================
   RENDERED MARKDOWN — refined editorial styling
   ============================================================ */

.rendered { font-family: var(--f-body); font-size: 14px; line-height: 1.75; color: var(--text-on-dark); }
.rendered h2 {
  font-family: var(--f-display);
  font-size: 18px; font-weight: 600;
  margin: 32px 0 12px; color: var(--signal-bright);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 14px;
  border-top: 1px solid var(--signal-line);
}
.rendered h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.rendered h3 {
  font-family: var(--f-display);
  font-size: 14.5px; font-weight: 600;
  margin: 26px 0 10px; color: #DCEFEC;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex; align-items: baseline; gap: 12px;
}
.rendered h3::before {
  content: ''; width: 18px; height: 1.5px; background: var(--brass);
  display: inline-block;
}
.rendered h4 {
  font-family: var(--f-mono); font-size: 11px; font-weight: 600;
  margin: 22px 0 10px;
  color: var(--brass);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.rendered p { margin: 8px 0; font-size: 14px; line-height: 1.75; color: var(--text-on-dark-soft); }
.rendered strong { color: var(--text-on-dark); font-weight: 600; }
.rendered .bullet {
  padding-left: 26px; position: relative;
  margin: 6px 0; font-size: 14px; line-height: 1.7;
  color: var(--text-on-dark-soft);
}
.rendered .bullet::before {
  content: '▸'; position: absolute; left: 8px; top: 0;
  color: var(--signal-bright);
  font-size: 11px; line-height: 24px;
}
.rendered .num-item {
  padding-left: 36px; position: relative;
  margin: 8px 0; font-size: 14px; line-height: 1.7;
  color: var(--text-on-dark-soft);
}
.rendered .num-item .num {
  position: absolute; left: 0; top: 0;
  font-family: var(--f-mono); font-weight: 700; font-size: 13px;
  color: var(--brass);
  letter-spacing: 0.04em;
  line-height: 24px;
}
.rendered .spacer { height: 8px; }

/* Horizontal rule */
.rendered hr.md-rule {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, var(--signal-line), rgba(184,146,58,0.18) 50%, transparent);
  margin: 28px 0;
}

/* Blockquote */
.rendered .md-quote {
  margin: 14px 0;
  padding: 14px 20px;
  border-left: 3px solid var(--brass);
  background: rgba(184,146,58,0.05);
  font-family: var(--f-display);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-on-dark);
  font-style: italic;
  letter-spacing: 0.01em;
}
.rendered .md-quote br { margin-bottom: 4px; }

/* Code block */
.rendered .md-code-block {
  margin: 16px 0;
  padding: 16px 20px;
  background: rgba(5,13,20,0.65);
  border: 1px solid var(--line-dark-2);
  border-left: 3px solid var(--signal-deep);
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-on-dark);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Inline code */
.rendered .md-inline-code {
  font-family: var(--f-mono);
  font-size: 12px;
  padding: 2px 7px;
  background: rgba(95,216,206,0.08);
  border: 1px solid rgba(95,216,206,0.18);
  color: var(--signal-bright);
}
.rendered .md-link {
  color: var(--signal-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(95,216,206,0.4);
  transition: text-decoration-color 0.15s;
}
.rendered .md-link:hover { text-decoration-color: var(--signal-bright); }
.rete-result-body .rendered .md-link { color: #F2A89E; text-decoration-color: rgba(208,74,58,0.4); }
.rete-result-body .rendered .md-link:hover { text-decoration-color: #F2A89E; }

/* Italic */
.rendered em {
  font-style: italic;
  color: var(--text-on-dark);
}

/* H5 — sub-sub header */
.rendered .md-h5 {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  margin: 18px 0 8px;
  color: var(--text-on-dark);
  letter-spacing: 0.04em;
}

/* ============================================================
   BADGES & VERDICTS — sober, document-like
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px;
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  vertical-align: 2px;
  margin: 0 2px;
}
.badge::before {
  display: inline-block; font-size: 9px;
}
.badge-green   { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(63,122,78,0.3); }
.badge-green::before { content: '✓'; }
.badge-orange  { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(184,118,42,0.3); }
.badge-orange::before { content: '!'; }
.badge-red     { background: var(--alert-soft); color: var(--alert); border: 1px solid rgba(178,58,42,0.35); }
.badge-red::before { content: '✕'; }
.badge-purple  { background: var(--critical-soft); color: var(--critical); border: 1px solid rgba(107,45,126,0.3); }
.badge-purple::before { content: '↺'; }

.verdict {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  margin: 12px 0 22px;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-left: 4px solid;
  position: relative;
}
.verdict::before {
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid currentColor;
}
.verdict-green   { background: var(--ok-soft); color: var(--ok-bright); border-left-color: var(--ok-bright); }
.verdict-green::before { content: 'PRONTO'; }
.verdict-orange  { background: var(--warn-soft); color: var(--warn-bright); border-left-color: var(--warn-bright); }
.verdict-orange::before { content: 'DA RIVEDERE'; }
.verdict-red     { background: var(--alert-soft); color: var(--alert-bright); border-left-color: var(--alert-bright); }
.verdict-red::before { content: 'NON USARE'; }

/* ============================================================
   CHAT THREAD
   ============================================================ */

#chat-thread { display: flex; flex-direction: column; gap: 16px; }
#chat-thread:not(:empty) { margin-bottom: 24px; }

.chat-bubble { max-width: 85%; animation: fadeUp 0.25s ease; }
.chat-bubble-user {
  align-self: flex-end;
  background: var(--agent-color, var(--signal));
  color: var(--bg-deep);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 20px;
  width: 100%;
  max-width: 100%;
}
.chat-bubble-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-family: var(--f-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--agent-color, var(--signal));
  margin-bottom: 12px; font-weight: 600;
}
.chat-bubble-header .icon { font-size: 14px; }
.chat-bubble-content { min-width: 0; }
.chat-bubble-content .rendered { font-size: 14px; line-height: 1.45; }
.chat-bubble-content .rendered p { line-height: 1.45; margin: 4px 0; }
.chat-bubble-content .rendered h2 { margin: 18px 0 8px; }
.chat-bubble-content .rendered h3 { margin: 14px 0 6px; }
.chat-bubble-content .rendered h4 { margin: 12px 0 6px; }
.chat-bubble-content .rendered .bullet { line-height: 1.45; margin: 3px 0; }
.chat-bubble-content .rendered .num-item { line-height: 1.45; margin: 4px 0; }
.chat-bubble-content .rendered .spacer { height: 4px; }
.chat-bubble-content .rendered hr.md-rule { margin: 16px 0; }
.chat-bubble-actions {
  display: flex; justify-content: flex-end;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line-dark-2);
}
.chat-bubble-actions .btn-copy {
  font-size: 11px; padding: 4px 12px;
}

/* Light theme */
body.light .chat-bubble-user {
  background: var(--agent-color, var(--signal));
  color: #fff;
}
body.light .chat-bubble-assistant {
  background: rgba(255,255,255,0.6);
  border-color: rgba(26,20,16,0.16);
}
body.light .chat-bubble-actions { border-top-color: rgba(26,20,16,0.12); }

/* ============================================================
   HISTORY
   ============================================================ */

.history-section { margin-top: 48px; }
.history-label {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 600;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px;
}
.history-label-toggle {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.history-label-toggle .chevron {
  margin-left: auto;
  font-size: 12px;
  line-height: 1;
  color: var(--brass);
}
.history-label::after { content: ''; flex: 1; height: 1px; background: var(--line-dark-2); }
.history-label-toggle::after { content: ''; flex: 1; height: 1px; background: var(--line-dark-2); }
.history-label .count {
  font-family: var(--f-mono); color: var(--brass);
  background: var(--brass-soft);
  padding: 2px 8px; font-size: 10px;
  border: 1px solid rgba(184,146,58,0.3);
}
.history-section-collapsed { margin-bottom: 8px; }

.history-group {
  margin-bottom: 18px;
}
.history-group-label {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brass);
  margin: 16px 0 10px;
}
.history-group-label .count {
  font-family: var(--f-mono); color: var(--brass);
  background: rgba(184,146,58,0.12);
  padding: 2px 8px; font-size: 10px;
  border: 1px solid rgba(184,146,58,0.22);
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 18px;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.18s ease;
  color: var(--text-on-dark);
}
.history-delete {
  background: none; border: none; cursor: pointer;
  color: var(--text-on-dark-faint);
  font-size: 16px; line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.history-delete:hover {
  color: var(--alert);
  background: var(--alert-soft);
}
.history-item:hover {
  background: rgba(95,216,206,0.05);
  border-color: var(--signal-line);
}
.history-mode {
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--brass); font-weight: 600;
  text-transform: uppercase;
}
.history-input {
  font-size: 13px; color: var(--text-on-dark-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.history-time {
  font-family: var(--f-mono); font-size: 10.5px;
  color: var(--text-on-dark-faint); white-space: nowrap;
}

/* ============================================================
   RETE SIDEBAR
   ============================================================ */

.rete-overlay {
  position: fixed; inset: 0;
  background: rgba(11,27,38,0.7);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: fadeIn 0.25s ease;
}
.rete-sidebar {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(540px, 96vw);
  background: linear-gradient(180deg, #0B0F12 0%, #080B0E 100%);
  z-index: 100;
  display: flex; flex-direction: column;
  box-shadow: -12px 0 60px rgba(0,0,0,0.7);
  animation: slideInRight 0.35s cubic-bezier(0.16,1,0.3,1);
  border-left: 1px solid rgba(178,58,42,0.35);
  transition: width 0.2s ease;
}
.rete-sidebar.rete-fullscreen {
  width: 100vw;
  border-left: none;
  animation: none;
}

/* Red spine running along the very left edge of the sidebar */
.rete-sidebar::before {
  content: ''; position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: linear-gradient(180deg, #B23A2A 0%, #8E2D20 100%);
  box-shadow: 0 0 12px -2px rgba(208,74,58,0.55);
  z-index: 1;
}

/* Header — institutional: shield glyph + classification + close */
.rete-sidebar-head {
  background: linear-gradient(180deg, rgba(178,58,42,0.10) 0%, transparent 100%);
  color: var(--paper);
  padding: 22px 24px 20px 28px;
  border-bottom: 1px solid rgba(178,58,42,0.32);
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 12px;
}
.rete-sidebar-glyph {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: rgba(178,58,42,0.10);
  border: 1px solid rgba(178,58,42,0.35);
  color: #E8B0A6;
}
.rete-sidebar-glyph svg {
  width: 22px; height: 22px;
  filter: drop-shadow(0 0 5px rgba(208,74,58,0.4));
}
.rete-sidebar-titles { min-width: 0; }
.rete-sidebar-eyebrow {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.30em; text-transform: uppercase;
  color: #E8A89E; font-weight: 500;
  margin-bottom: 5px;
  display: inline-flex; align-items: center; gap: 9px;
}
.rete-sidebar-eyebrow .alert-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alert-bright);
  box-shadow: 0 0 8px var(--alert-bright);
  animation: pulse 2s ease-in-out infinite;
}
.rete-sidebar-name {
  font-family: var(--f-display); font-weight: 600;
  font-size: 15px; color: var(--paper);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rete-sidebar-close {
  width: 32px; height: 32px;
  background: rgba(242,236,221,0.04);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-family: var(--f-mono);
  transition: all 0.2s ease;
}
.rete-sidebar-close:hover, .rete-sidebar-expand:hover {
  background: rgba(178,58,42,0.18);
  border-color: rgba(178,58,42,0.5);
  color: var(--paper);
}
.rete-sidebar-expand {
  width: 32px; height: 32px;
  background: rgba(242,236,221,0.04);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

/* Metadata strip below the header */
.rete-sidebar-meta {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 24px 11px 28px;
  border-bottom: 1px solid rgba(178,58,42,0.16);
  background: rgba(178,58,42,0.03);
  flex-wrap: wrap;
}
.rete-sidebar-meta .meta-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}
.rete-sidebar-meta .meta-item b {
  color: #E8A89E; font-weight: 600;
}
.rete-sidebar-meta .meta-divider {
  width: 1px; height: 10px;
  background: rgba(178,58,42,0.22);
}

.rete-sidebar-body {
  flex: 1; overflow-y: auto;
  padding: 22px 24px 24px 28px;
}

/* Section block — "Procedura" instructions */
.rete-section-label {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 600;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.rete-section-label::after {
  content: ''; flex: 1; height: 1px;
  background: rgba(178,58,42,0.18);
}

.rete-instruction {
  font-family: var(--f-display);
  font-size: 12px; line-height: 1.65;
  letter-spacing: 0.01em;
  color: var(--text-on-dark-soft);
  background: rgba(178,58,42,0.04);
  border: 1px solid rgba(178,58,42,0.18);
  border-left: 3px solid var(--alert);
  padding: 14px 16px;
  margin-bottom: 22px;
}
.rete-instruction strong {
  color: #F2D1CB; font-weight: 700;
}

#rete-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-dark-2);
  background: rgba(5,11,15,0.85);
  color: var(--text-on-dark);
  font-family: var(--f-body);
  font-size: 13.5px; line-height: 1.55;
  resize: vertical;
  outline: none;
  min-height: 130px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
#rete-input::placeholder { color: var(--text-on-dark-faint); font-style: italic; }
#rete-input:focus {
  border-color: rgba(208,74,58,0.65);
  background: rgba(5,11,15,1);
  box-shadow: 0 0 0 3px rgba(208,74,58,0.15);
}

.rete-input-hint {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px;
}
.rete-input-hint::before {
  content: '▸';
  color: #E8A89E;
}

#rete-btn {
  width: 100%;
  margin-top: 18px;
  padding: 14px 20px;
  background: rgba(208,74,58,0.14);
  color: #F2D1CB;
  font-family: var(--f-mono);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(208,74,58,0.5);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#rete-btn .btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1px solid currentColor;
  font-size: 11px;
  transition: transform 0.2s ease;
}
#rete-btn:hover:not(:disabled) {
  background: rgba(208,74,58,0.24);
  border-color: rgba(208,74,58,0.7);
  color: #FFE1DA;
}
#rete-btn:hover:not(:disabled) .btn-icon { transform: translateX(3px); }
#rete-btn:disabled {
  background: rgba(10,22,32,0.6);
  color: var(--text-on-dark-faint);
  cursor: progress;
  border-color: var(--line-dark-2);
}

/* Super Check — extended thinking option */
.rete-super-btn-full {
  width: 100%;
  margin-top: 8px;
  padding: 13px 20px;
  background: rgba(142,45,32,0.12);
  border: 1px solid rgba(142,45,32,0.45);
  color: #F2D1CB;
  font-family: var(--f-mono); font-size: 12px;
  letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.rete-super-btn-full .btn-icon { color: #E8A89E; }
.rete-super-btn-full:hover:not(:disabled) {
  background: rgba(142,45,32,0.25);
  border-color: rgba(208,74,58,0.65);
}
.rete-super-btn-full:disabled {
  cursor: progress;
  opacity: 0.6;
}

#rete-loading {
  display: none;
  text-align: center;
  padding: 32px 0;
}
#rete-loading.active { display: block; }

#rete-result { margin-top: 18px; }
.rete-result-frame {
  border: 1px solid var(--line-dark-2);
  position: relative;
}
.rete-result-head {
  padding: 11px 16px;
  background: linear-gradient(90deg, rgba(208,74,58,0.18), transparent 70%);
  color: var(--paper);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(208,74,58,0.4);
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
}
.rete-result-body { padding: 18px 22px; color: var(--text-on-dark); }
.rete-result-body .rendered { color: var(--text-on-dark); }
.rete-result-body .rendered h2 { color: #F2A89E; border-top-color: rgba(178,58,42,0.3); }
.rete-result-body .rendered h3 { color: #E8B0A6; }
.rete-result-body .rendered h3::before { background: var(--alert); }
.rete-result-body .rendered p { color: var(--text-on-dark-soft); }
.rete-result-body .rendered strong { color: #F2D1CB; }
.rete-result-body .rendered .bullet::before { color: var(--alert-bright); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .framed-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .framed-grid > .center-panel-frame {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 380px;
  }
  .framed-grid > .card-1 { grid-column: 1; grid-row: 2; }
  .framed-grid > .card-2 { grid-column: 2; grid-row: 2; }
  .framed-grid > .card-3 { grid-column: 1; grid-row: 3; }
  .framed-grid > .card-4 { grid-column: 2; grid-row: 3; }
  .framed-grid > .card-5 { grid-column: 1 / -1; grid-row: 4; }
}

@media (max-width: 880px) {
  .console { padding: 0 16px 20px; }
  .console-header { flex-direction: column; gap: 12px; padding: 22px 4px 18px; text-align: center; }
  .console-title .ct-main { font-size: 14px; letter-spacing: 0.32em; }
  .console-tagline { display: none; }
  .console-status { justify-content: center; gap: 16px; flex-wrap: wrap; }
  .brand-mark { justify-content: center; }
  .brand-mark { flex-direction: column; align-items: center; gap: 8px; }
  .brand-mark .b-title { font-size: 18px; white-space: normal; }
  .brand-mark .b-tricolor { width: 110px; }

  .framed-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 14px;
  }
  .framed-grid > * { grid-column: 1 !important; grid-row: auto !important; }
  .framed-grid > .center-panel-frame { min-height: 360px; }

  .cp-subbanner { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px 18px; }
  .cp-sub-item:nth-child(odd) { border-left: none; padding-left: 0; }

  .rete-bar { grid-template-columns: 4px 1fr; row-gap: 0; }
  .rete-bar > .rete-spine { grid-column: 1; grid-row: 1 / span 3; }
  .rete-bar > .rete-glyph { grid-column: 2; grid-row: 1; width: 100%; height: 56px; border-right: none; border-bottom: 1px solid rgba(178,58,42,0.18); }
  .rete-bar > .rete-text { grid-column: 2; grid-row: 2; padding: 18px 22px; }
  .rete-bar > .rete-action { grid-column: 2; grid-row: 3; border-left: none; border-top: 1px solid rgba(178,58,42,0.18); padding: 14px 22px; }
  .rete-cta { justify-self: stretch; justify-content: center; }

  .agent-header-inner { grid-template-columns: auto 1fr auto; gap: 12px; }
  .agent-header-id { display: none; }
  .agent-header-name { font-size: 19px; }
  .btn-back { padding: 8px 11px; font-size: 10px; letter-spacing: 0.1em; }
  .btn-back .full { display: none; }
  .workspace-inner { padding: 28px 20px 0; }
  .result-body { padding: 24px 22px; }
  .classification-inner { padding: 8px 16px; gap: 8px; }
  .classification { font-size: 9.5px; }
  .cls-left .cls-divider:nth-child(2) { display: none; }

  .console-foot { flex-direction: column; align-items: flex-start; gap: 8px; }

  .ac-name { font-size: 30px; }
  .ac-body { padding: 18px 20px 14px 22px; }
}

@media (max-width: 560px) {
  .console-status { font-size: 9.5px; }
  .console-status .stat-item b { font-size: 12px; }
  .history-item { grid-template-columns: 1fr; gap: 6px; }
  .history-time { font-size: 10px; }
  .rendered { font-size: 13.5px; }
  .verdict { font-size: 15px; padding: 12px 16px; }
  .rete-name { font-size: 19px; }
  .rete-glyph { width: 44px; height: 44px; font-size: 19px; }
  .cp-headline { font-size: 17px; }
  .cp-reticle { width: 160px; height: 160px; }
}

/* ============================================================
   LIGHT THEME — toggleable
   ============================================================ */
body.light {
  /* Cream/document palette */
  --ink-deep:      #F4EFDF;
  --ink:           #EBE5D0;
  --ink-2:         #E1DAC0;
  --ink-3:         #D5CCAF;
  --card:          #FBF6E8;
  --card-hover:    #F4EED7;
  --card-line:     rgba(56,116,76,0.32);
  --card-glow:     #38744C;

  --line-dark:     rgba(26,20,16,0.10);
  --line-dark-2:   rgba(26,20,16,0.18);

  --paper:         #1A1410;
  --paper-2:       #2A2218;
  --paper-warm:    #FFFFFF;

  --text:          #1A1410;
  --text-soft:     rgba(26,20,16,0.72);
  --text-muted:    rgba(26,20,16,0.55);
  --text-faint:    rgba(26,20,16,0.40);

  --text-on-dark:        #1A1410;
  --text-on-dark-soft:   rgba(26,20,16,0.66);
  --text-on-dark-faint:  rgba(26,20,16,0.44);

  --signal:        #2C7570;
  --signal-bright: #1F5853;
  --signal-deep:   #11433E;
  --signal-glow:   rgba(44,117,112,0.30);
  --signal-line:   rgba(44,117,112,0.30);
  --signal-soft:   rgba(44,117,112,0.10);
  --signal-faint:  rgba(44,117,112,0.05);

  --ok:            #357850;
  --ok-bright:     #2F6E48;
  --ok-soft:       rgba(53,120,80,0.16);
  --warn:          #A86E22;
  --warn-bright:   #8E5A14;
  --warn-soft:     rgba(168,110,34,0.14);
  --alert:         #B23A2A;
  --alert-bright:  #94251A;
  --alert-soft:    rgba(178,58,42,0.14);
  --critical:      #5C2A6E;
  --critical-soft: rgba(92,42,110,0.14);

  --brass-soft:    rgba(184,146,58,0.16);
}

/* Body + atmospheric layers */
body.light { background: var(--ink-deep); color: var(--text); }
body.light .bg-grid {
  background-image:
    linear-gradient(rgba(26,20,16,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,20,16,0.04) 1px, transparent 1px);
}
body.light .bg-vignette {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(184,146,58,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(56,116,76,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 0% 50%, rgba(184,146,58,0.06) 0%, transparent 70%);
}

/* Classification + tricolor */
body.light .classification { border-bottom: 1px solid var(--line-dark); color: var(--text-soft); }
body.light .cls-tag {
  background: rgba(178,58,42,0.08);
  color: #94251A;
  border-color: rgba(178,58,42,0.35);
}
body.light .cls-divider { background: rgba(26,20,16,0.18); }
body.light .cls-claim { color: var(--text-soft); }

/* Console header */
body.light .console-header { border-bottom: 1px solid rgba(26,20,16,0.18); }
body.light .console-title { color: var(--text); }
body.light .console-status { color: var(--text-soft); }
body.light .console-status .stat-divider { background: rgba(184,146,58,0.40); }

/* Product intro */
body.light .product-intro {
  background: linear-gradient(90deg, rgba(26,20,16,0.04), transparent 70%);
  border-color: rgba(26,20,16,0.14);
  border-left-color: var(--text);
}
body.light .product-intro-label { color: var(--text); }
body.light .product-intro-label::after { background: rgba(26,20,16,0.22); }
body.light .product-intro-text { color: var(--text-soft); }
body.light .product-intro-text b { color: var(--text); }
body.light .product-intro-text em { color: var(--text); }

/* Section divider */
body.light .section-divider-rule.left::before {
  background: linear-gradient(90deg, transparent, rgba(26,20,16,0.45) 50%, rgba(26,20,16,0.45));
}
body.light .section-divider-rule.right::before {
  background: linear-gradient(90deg, rgba(26,20,16,0.45), rgba(26,20,16,0.45) 50%, transparent);
}
body.light .section-divider-rule.left::after {
  background: linear-gradient(90deg, transparent, rgba(26,20,16,0.18) 50%, rgba(26,20,16,0.18));
}
body.light .section-divider-rule.right::after {
  background: linear-gradient(90deg, rgba(26,20,16,0.18), rgba(26,20,16,0.18) 50%, transparent);
}
body.light .section-divider-label {
  color: var(--text);
  border-color: rgba(26,20,16,0.32);
  background: rgba(255,255,255,0.45);
}
body.light .section-divider-label::before { background: var(--text); }
body.light .section-divider-label .arrow { color: var(--text); }
body.light .section-divider-label .step { color: var(--text-muted); border-color: rgba(26,20,16,0.25); }
body.light .section-divider[onclick]:hover .section-divider-label {
  border-color: rgba(26,20,16,0.45);
  background: rgba(255,255,255,0.55);
}

/* Rete bar — keep red identity but on cream surface */
body.light .rete-bar {
  background: linear-gradient(180deg, #FBEFEC 0%, #F3E2DC 100%);
  border-color: rgba(178,58,42,0.40);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 18px 30px -12px rgba(95,40,30,0.20),
    0 44px 80px -28px rgba(95,40,30,0.14);
}
body.light .rete-bar:hover {
  background: linear-gradient(180deg, #FEF2EE 0%, #F8E6DF 100%);
  border-color: rgba(178,58,42,0.55);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 26px 36px -12px rgba(95,40,30,0.25),
    0 60px 120px -30px rgba(95,40,30,0.18);
}
body.light .rete-glyph { background: rgba(178,58,42,0.08); border-right-color: rgba(178,58,42,0.18); color: #94251A; }
body.light .rete-tag { color: #94251A; }
body.light .rete-name { color: var(--text); }
body.light .rete-desc { color: var(--text-soft); }
body.light .rete-meta-item { color: var(--text-muted); }
body.light .rete-meta-item b { color: #94251A; }
body.light .rete-meta-divider { background: rgba(178,58,42,0.20); }
body.light .rete-action { background: rgba(178,58,42,0.04); border-left-color: rgba(178,58,42,0.18); }
body.light .rete-cta {
  color: #94251A;
  background: rgba(208,74,58,0.10);
  border-color: rgba(208,74,58,0.45);
}
body.light .rete-bar:hover .rete-cta {
  background: rgba(208,74,58,0.18);
  border-color: rgba(208,74,58,0.65);
  color: #6B1B11;
}
body.light .rete-spine { background: linear-gradient(180deg, #B23A2A 0%, #8E2D20 100%); }

/* Agent cards */
body.light .agent-card {
  background: var(--card);
  border-color: var(--card-line);
  box-shadow:
    0 0 0 1px rgba(56,116,76,0.06),
    inset 0 0 50px rgba(255,255,255,0.4),
    0 6px 20px -8px rgba(26,20,16,0.20);
}
body.light .agent-card:hover {
  background: var(--card-hover);
  border-color: rgba(56,116,76,0.50);
}
body.light .agent-card .ac-spine { background: var(--card-glow); box-shadow: 0 0 14px -1px rgba(56,116,76,0.40); }
body.light .agent-card::before, body.light .agent-card::after { border-color: var(--card-glow); filter: drop-shadow(0 0 3px rgba(56,116,76,0.35)); }
body.light .ac-head {
  background: linear-gradient(90deg, rgba(56,116,76,0.08), transparent 70%);
  border-bottom-color: rgba(56,116,76,0.20);
  color: var(--text-soft);
}
body.light .ac-head .ac-status { color: var(--ok); }
body.light .ac-head .ac-status .dot { background: var(--ok); box-shadow: 0 0 6px rgba(53,120,80,0.5); }
body.light .ac-name { color: var(--text); }
body.light .ac-role { color: var(--brass-deep); }
body.light .ac-desc { color: var(--text-soft); border-bottom-color: rgba(56,116,76,0.24); }
body.light .ac-mode {
  color: #1F5535;
  background: rgba(56,116,76,0.06);
  border-color: rgba(56,116,76,0.32);
}
body.light .ac-mode:hover {
  color: #154028 !important;
  background: rgba(56,116,76,0.18) !important;
  border-color: rgba(56,116,76,0.65) !important;
  box-shadow: 0 0 14px -2px rgba(56,116,76,0.4), inset 0 0 18px rgba(56,116,76,0.10);
}
body.light .agent-card:hover .ac-mode { background: rgba(56,116,76,0.10); border-color: rgba(56,116,76,0.45); }
body.light .ac-foot { background: rgba(255,255,255,0.4); border-top-color: rgba(56,116,76,0.20); color: var(--text-muted); }

/* Center panel */
body.light .center-panel-frame {
  filter:
    drop-shadow(0 18px 22px rgba(26,20,16,0.20))
    drop-shadow(0 50px 70px rgba(26,20,16,0.16));
}
body.light .center-panel-frame:hover {
  filter:
    drop-shadow(0 32px 36px rgba(26,20,16,0.25))
    drop-shadow(0 80px 130px rgba(26,20,16,0.20));
}
body.light .center-panel {
  background: #FFFEF6;
  border-color: rgba(184,146,58,0.42);
  box-shadow:
    0 0 0 1px rgba(184,146,58,0.08),
    inset 0 0 80px rgba(184,146,58,0.04),
    inset 0 1px 0 rgba(255,255,255,0.6);
}
body.light .center-panel-frame:hover .center-panel {
  background: #FFFFFF;
  border-color: rgba(184,146,58,0.65);
}
body.light .cp-head {
  background: linear-gradient(90deg, rgba(184,146,58,0.10), transparent 70%);
  border-bottom-color: rgba(184,146,58,0.32);
}
body.light .cp-title { color: var(--text); }
body.light .cp-title .pcode { color: var(--brass-deep); border-color: rgba(184,146,58,0.5); }
body.light .cp-status { color: var(--text-muted); }
body.light .cp-subbanner {
  background: linear-gradient(90deg, rgba(184,146,58,0.06), transparent 80%);
  border-bottom-color: rgba(184,146,58,0.24);
}
body.light .cp-sub-key { color: var(--text-muted); }
body.light .cp-sub-val { color: var(--text); }
body.light .cp-state { color: var(--brass-deep); border-color: rgba(184,146,58,0.5); background: rgba(184,146,58,0.10); }
body.light .cp-headline { color: var(--text); }
body.light .cp-sub { color: var(--text-soft); }
body.light .cp-feeders { border-top-color: rgba(184,146,58,0.30); }
body.light .cp-feeders-label { color: var(--text-muted); }
body.light .cp-feeder { color: var(--text-muted); border-color: rgba(44,117,112,0.22); }
body.light .cp-feeder:hover { color: var(--signal-bright); border-color: rgba(44,117,112,0.55); background: rgba(44,117,112,0.05); }
body.light .cp-feeder.is-rete { color: rgba(178,58,42,0.78); border-color: rgba(178,58,42,0.24); }
body.light .cp-feeder.is-rete:hover { color: #94251A; border-color: rgba(178,58,42,0.6); background: rgba(178,58,42,0.05); }
body.light .cp-feeder .num { color: var(--brass); }
body.light .cp-feeder.is-rete .num { color: rgba(178,58,42,0.85); }

/* Agent header (sticky bar on agent page) + workspace */
body.light .agent-header { background: var(--ink); border-bottom-color: rgba(26,20,16,0.16); }
body.light .agent-header-id { color: var(--brass-deep); }
body.light .agent-header-name { color: var(--text); }
body.light .agent-header-name .gly { color: var(--brass-deep); border-color: rgba(184,146,58,0.5); background: rgba(184,146,58,0.08); }
body.light .btn-back, body.light .btn-info { color: var(--text-soft); border-color: var(--line-dark-2); }
body.light .btn-back:hover { background: rgba(26,20,16,0.05); color: var(--text); }
body.light .workspace { background: var(--ink-deep); }

/* Briefing panel + onboard + tabs + input + run */
body.light .onboard {
  background: var(--card);
  border-color: rgba(56,116,76,0.30);
  box-shadow: 0 0 0 1px rgba(56,116,76,0.06), inset 0 0 30px rgba(255,255,255,0.5);
}
body.light .onboard-spine { background: var(--card-glow); }
body.light .onboard-label { color: var(--card-glow); }
body.light .onboard-text { color: var(--text-soft); }

body.light .briefing-panel {
  background: #FFFEF6;
  border-color: rgba(184,146,58,0.40);
  box-shadow:
    0 0 0 1px rgba(184,146,58,0.06),
    inset 0 0 40px rgba(184,146,58,0.04),
    0 6px 18px -6px rgba(26,20,16,0.18);
}
body.light .briefing-label { color: var(--brass-deep); }
body.light .briefing-label::after { background: rgba(184,146,58,0.32); }

body.light .mode-tab {
  background: rgba(255,255,255,0.65);
  border-color: rgba(26,20,16,0.16);
  color: var(--text);
}
body.light .mode-tab:hover { background: #FFFFFF; border-color: rgba(56,116,76,0.40); }
body.light .mode-tab.active {
  background: rgba(56,116,76,0.10);
  border-color: rgba(56,116,76,0.6);
  box-shadow: inset 3px 0 0 0 var(--card-glow);
}
body.light .mode-tab.active .mt-num { color: var(--card-glow); }
body.light .mode-tab.active .mt-name { color: var(--card-glow); }
body.light .mode-tab.active .mt-desc { color: var(--text); }
body.light .mode-tab.active .mt-arrow { color: var(--card-glow); }
body.light .mt-num { color: var(--brass); }
body.light .mt-name { color: var(--text); }
body.light .mt-desc { color: var(--text-soft); }
body.light .mt-arrow { color: var(--text-faint); }

body.light .input-label { color: var(--text-muted); }
body.light .input-label::after { background: rgba(26,20,16,0.20); }
body.light .input-field {
  background: #FFFFFF;
  border-color: rgba(26,20,16,0.18);
  color: var(--text);
}
body.light .input-field::placeholder { color: rgba(26,20,16,0.4); }
body.light .input-field:focus { border-color: var(--signal); box-shadow: 0 0 0 3px rgba(44,117,112,0.10); background: #FFFFFF; }

body.light .btn-run {
  background: rgba(44,117,112,0.10);
  border-color: rgba(44,117,112,0.45);
  color: var(--signal-bright);
}
body.light .btn-run::before, body.light .btn-run::after { border-color: var(--signal-bright); filter: none; }
body.light .btn-run:hover:not(:disabled) {
  background: rgba(44,117,112,0.18);
  color: var(--signal-deep);
}

/* Loading */
body.light .loading-spin::before { border-top-color: var(--signal); }
body.light .loading-spin::after { border-top-color: var(--brass); }
body.light .loading-text { color: var(--text-muted); }

/* Result */
body.light .result-frame {
  background: #FFFEF6;
  border-color: rgba(184,146,58,0.32);
  box-shadow: 0 0 0 1px rgba(184,146,58,0.04), inset 0 0 60px rgba(184,146,58,0.03), 0 6px 20px -8px rgba(26,20,16,0.20);
}
body.light .result-header {
  background: linear-gradient(90deg, rgba(184,146,58,0.10), transparent 70%);
  border-bottom-color: rgba(184,146,58,0.25);
  color: var(--text);
}
body.light .result-header .left .icon { color: var(--brass-deep); }
body.light .result-header .left .agent-name { color: var(--brass-deep); }
body.light .result-header .left .mode { color: var(--text-soft); }
body.light .result-header .left .div { background: rgba(184,146,58,0.32); }
body.light .btn-copy {
  color: var(--brass-deep);
  background: rgba(184,146,58,0.10);
  border-color: rgba(184,146,58,0.40);
}
body.light .btn-copy:hover { background: rgba(184,146,58,0.20); }
body.light .result-body { color: var(--text); }
body.light .result-disclaimer { color: var(--warn); border-top-color: rgba(168,110,34,0.20); background: rgba(168,110,34,0.06); }

/* Rendered markdown */
body.light .rendered { color: var(--text); }
body.light .rendered h2 { color: var(--text); border-top-color: rgba(184,146,58,0.32); }
body.light .rendered h3 { color: var(--text); }
body.light .rendered h3::before { background: var(--brass); }
body.light .rendered h4 { color: var(--brass-deep); }
body.light .rendered p { color: var(--text-soft); }
body.light .rendered strong { color: var(--text); }
body.light .rendered .bullet { color: var(--text-soft); }
body.light .rendered .bullet::before { color: var(--brass-deep); }
body.light .rendered .num-item { color: var(--text-soft); }
body.light .rendered .num-item .num { color: var(--brass); }
body.light .rendered hr.md-rule { background: linear-gradient(90deg, rgba(184,146,58,0.40), rgba(26,20,16,0.12) 50%, transparent); }
body.light .rendered .md-quote { background: rgba(184,146,58,0.06); border-left-color: var(--brass); color: var(--text); }
body.light .rendered .md-code-block { background: rgba(26,20,16,0.04); border-color: rgba(26,20,16,0.14); border-left-color: var(--signal); color: var(--text); }
body.light .rendered .md-inline-code { background: rgba(44,117,112,0.08); border-color: rgba(44,117,112,0.20); color: var(--signal-bright); }
body.light .rendered em { color: var(--text); }

/* History */
body.light .history-label { color: var(--text-muted); }
body.light .history-label::after { background: rgba(26,20,16,0.18); }
body.light .history-item {
  background: rgba(255,255,255,0.5);
  border-color: rgba(26,20,16,0.16);
  color: var(--text);
}
body.light .history-item:hover { background: #FFFFFF; border-color: rgba(56,116,76,0.40); }
body.light .history-delete { color: var(--text-faint); }
body.light .history-delete:hover { color: var(--alert); background: rgba(178,58,42,0.08); }
body.light .history-mode { color: var(--brass-deep); }
body.light .history-input { color: var(--text-soft); }
body.light .history-time { color: var(--text-faint); }

/* Rete sidebar */
body.light .rete-overlay { background: rgba(26,20,16,0.45); }
body.light .rete-sidebar {
  background: linear-gradient(180deg, #FAF5E8 0%, #F0E8D2 100%);
  border-left-color: rgba(178,58,42,0.40);
  box-shadow: -12px 0 60px rgba(26,20,16,0.25);
}
body.light .rete-sidebar-head {
  background: linear-gradient(180deg, rgba(178,58,42,0.08) 0%, transparent 100%);
  border-bottom-color: rgba(178,58,42,0.30);
  color: var(--text);
}
body.light .rete-sidebar-glyph { color: #94251A; background: rgba(178,58,42,0.10); border-color: rgba(178,58,42,0.35); }
body.light .rete-sidebar-eyebrow { color: #94251A; }
body.light .rete-sidebar-name { color: var(--text); }
body.light .rete-sidebar-close { background: rgba(26,20,16,0.05); border-color: rgba(26,20,16,0.18); color: var(--text-soft); }
body.light .rete-sidebar-meta { background: rgba(178,58,42,0.04); border-bottom-color: rgba(178,58,42,0.20); }
body.light .rete-sidebar-meta .meta-item { color: var(--text-muted); }
body.light .rete-sidebar-meta .meta-item b { color: #94251A; }
body.light .rete-sidebar-meta .meta-divider { background: rgba(178,58,42,0.22); }
body.light .rete-section-label { color: var(--text-muted); }
body.light .rete-section-label::after { background: rgba(178,58,42,0.20); }
body.light .rete-instruction {
  background: rgba(178,58,42,0.06);
  border-color: rgba(178,58,42,0.25);
  color: var(--text-soft);
}
body.light .rete-instruction strong { color: #94251A; }
body.light #rete-input {
  background: #FFFFFF;
  border-color: rgba(26,20,16,0.18);
  color: var(--text);
}
body.light #rete-input::placeholder { color: rgba(26,20,16,0.4); }
body.light #rete-input:focus { border-color: rgba(208,74,58,0.65); box-shadow: 0 0 0 3px rgba(208,74,58,0.15); }
body.light .rete-input-hint { color: var(--text-muted); }
body.light .rete-input-hint::before { color: #94251A; }
body.light #rete-btn {
  background: rgba(208,74,58,0.14);
  border-color: rgba(208,74,58,0.50);
  color: #94251A;
}
body.light #rete-btn:hover:not(:disabled) {
  background: rgba(208,74,58,0.24);
  border-color: rgba(208,74,58,0.7);
  color: #6B1B11;
}
body.light .rete-super-btn-full { background: rgba(142,45,32,0.08); border-color: rgba(142,45,32,0.40); color: #94251A; }
body.light .rete-super-btn-full:hover:not(:disabled) { background: rgba(142,45,32,0.16); border-color: rgba(142,45,32,0.55); }
body.light .rete-result-frame { background: #FFFFFF; border-color: rgba(26,20,16,0.16); }
body.light .rete-result-head {
  background: linear-gradient(90deg, rgba(208,74,58,0.12), transparent 70%);
  border-bottom-color: rgba(208,74,58,0.32);
  color: var(--text);
}
body.light .rete-result-body { color: var(--text); }

/* Verdict + badge — kept already mostly ok */

/* Theme toggle in classification bar */
.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--line-dark-2);
}
.theme-toggle button {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 9px;
  background: transparent;
  color: var(--text-on-dark-faint);
  border: none;
  cursor: pointer;
  transition: all 0.18s ease;
}
.theme-toggle button:hover:not(.active) { color: var(--text-on-dark); }
.theme-toggle button.active {
  background: var(--brass);
  color: #1A1410;
}
body.light .theme-toggle { border-color: rgba(26,20,16,0.22); }
body.light .theme-toggle button { color: var(--text-muted); }
body.light .theme-toggle button:hover:not(.active) { color: var(--text); }
body.light .theme-toggle button.active { background: var(--brass); color: #1A1410; }

/* Typewriter caret for the product-intro text */
.product-intro-text .caret {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  background: var(--brass);
  margin-left: 3px;
  vertical-align: -2px;
  animation: blink 0.9s steps(1) infinite;
}
body.light .product-intro-text .caret { background: var(--text); }

/* ============================================================
   IMAGE GENERATION — Alchimista Visual output
   ============================================================ */

.img-gen-section {
  margin-top: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* ---- Loading state ---- */
.img-gen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 50%, rgba(184,146,58,0.06) 0%, transparent 70%),
    var(--ink-2);
  border: 1px solid rgba(184,146,58,0.20);
  text-align: center;
}
.img-gen-loading-reticle {
  width: 100px;
  height: 100px;
  position: relative;
  margin-bottom: 28px;
}
.img-gen-loading-reticle::before,
.img-gen-loading-reticle::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px solid transparent;
  border-radius: 50%;
}
.img-gen-loading-reticle::before {
  border-top-color: var(--brass);
  border-right-color: rgba(184,146,58,0.3);
  animation: spin 2s cubic-bezier(0.45,0.05,0.55,0.95) infinite;
  filter: drop-shadow(0 0 6px rgba(184,146,58,0.4));
}
.img-gen-loading-reticle::after {
  inset: 12px;
  border-top-color: var(--signal-bright);
  border-left-color: rgba(95,216,206,0.25);
  animation: spin 1.4s linear infinite reverse;
  filter: drop-shadow(0 0 4px var(--signal-glow));
}
.img-gen-loading-dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--brass);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--brass);
  animation: glowPulse 2s ease-in-out infinite;
}
.img-gen-loading-label {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 8px;
}
.img-gen-loading-sub {
  font-family: var(--f-display);
  font-size: 12.5px;
  color: var(--text-on-dark-faint);
  letter-spacing: 0.01em;
}
.img-gen-loading-timer {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-on-dark-faint);
  margin-top: 18px;
  opacity: 0.6;
}
.img-gen-prompt {
  font-family: var(--f-mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-on-dark-faint);
  padding: 12px 18px;
  margin-top: 22px;
  background: rgba(5,13,20,0.55);
  border-left: 2px solid rgba(184,146,58,0.30);
  max-width: 520px;
  text-align: left;
}

/* ---- Done state ---- */
.img-gen-done {
  background: var(--ink-2);
  border: 1px solid rgba(184,146,58,0.30);
  animation: fadeUp 0.5s cubic-bezier(0.16,1,0.3,1) both;
}
.img-gen-done-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, rgba(184,146,58,0.10), transparent 60%);
  border-bottom: 1px solid rgba(184,146,58,0.20);
}
.img-gen-done-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.img-gen-done-label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--ok-bright);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--ok-bright);
}
.img-gen-result {
  padding: 22px;
  display: flex;
  justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(184,146,58,0.02) 0px, rgba(184,146,58,0.02) 8px, transparent 8px, transparent 16px);
}
.img-gen-output {
  width: 100%;
  max-width: 720px;
  height: auto;
  display: block;
  border: 2px solid rgba(184,146,58,0.25);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.16,1,0.3,1);
  box-shadow:
    0 12px 40px -12px rgba(0,0,0,0.65),
    0 0 0 1px rgba(184,146,58,0.08);
}
.img-gen-output:hover {
  border-color: var(--brass);
  transform: translateY(-2px);
  box-shadow:
    0 20px 60px -16px rgba(0,0,0,0.8),
    0 0 0 1px rgba(184,146,58,0.18),
    0 0 40px -8px rgba(184,146,58,0.12);
}
.img-gen-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid rgba(184,146,58,0.15);
  background: rgba(184,146,58,0.03);
}
.img-gen-download {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid rgba(184,146,58,0.35);
  background: rgba(184,146,58,0.06);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.img-gen-download:hover {
  background: rgba(184,146,58,0.16);
  border-color: var(--brass);
  color: #D4AF55;
}
.img-gen-open {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-on-dark-faint);
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid var(--line-dark-2);
  background: transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.img-gen-open:hover {
  color: var(--text-on-dark);
  border-color: var(--signal-line);
  background: rgba(95,216,206,0.04);
}

/* ---- Error state ---- */
.img-gen-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 32px;
  background: var(--ink-2);
  border: 1px solid rgba(208,74,58,0.30);
  text-align: center;
}
.img-gen-error-label {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--alert-bright);
  font-weight: 600;
  margin-bottom: 10px;
}
.img-gen-error-msg {
  font-family: var(--f-display);
  font-size: 13px;
  color: var(--text-on-dark-soft);
  max-width: 480px;
}

/* ---- Light theme ---- */
body.light .img-gen-loading { background: radial-gradient(ellipse 60% 40% at 50% 50%, rgba(184,146,58,0.08) 0%, transparent 70%), #FFFEF6; border-color: rgba(184,146,58,0.30); }
body.light .img-gen-loading-sub { color: var(--text-muted); }
body.light .img-gen-prompt { background: rgba(26,20,16,0.04); border-left-color: rgba(184,146,58,0.35); color: var(--text-muted); }
body.light .img-gen-done { background: #FFFEF6; border-color: rgba(184,146,58,0.35); }
body.light .img-gen-done-header { background: linear-gradient(90deg, rgba(184,146,58,0.08), transparent 60%); border-bottom-color: rgba(184,146,58,0.25); }
body.light .img-gen-result { background: repeating-linear-gradient(45deg, rgba(184,146,58,0.03) 0px, rgba(184,146,58,0.03) 8px, transparent 8px, transparent 16px); }
body.light .img-gen-output { border-color: rgba(184,146,58,0.30); box-shadow: 0 12px 40px -12px rgba(26,20,16,0.25); }
body.light .img-gen-actions { background: rgba(184,146,58,0.04); border-top-color: rgba(184,146,58,0.20); }
body.light .img-gen-download { color: var(--brass-deep); border-color: rgba(184,146,58,0.40); background: rgba(184,146,58,0.08); }
body.light .img-gen-open { color: var(--text-muted); border-color: rgba(26,20,16,0.16); }
body.light .img-gen-error { background: #FFFEF6; border-color: rgba(208,74,58,0.30); }
body.light .img-gen-error-label { color: var(--alert); }
body.light .img-gen-error-msg { color: var(--text-soft); }

/* ---- Channel optimizer — Alchimista drill-down ---- */
.channel-optimizer {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line-dark-2);
}
.channel-opt-header {
  margin-bottom: 14px;
}
.channel-opt-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}
.channel-opt-sub {
  font-family: var(--f-display);
  font-size: 12.5px;
  color: var(--text-on-dark-faint);
}
.channel-opt-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.channel-select {
  padding: 5px 28px 5px 10px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--brass);
  background: rgba(184,146,58,0.06);
  border: 1px solid rgba(184,146,58,0.30);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' fill='none'%3E%3Cpath d='M.5.5l3.5 4 3.5-4' stroke='%23B8923A' stroke-width='1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.channel-select:hover {
  border-color: var(--brass);
  background-color: rgba(184,146,58,0.12);
  color: #D4AF55;
}
.channel-select:focus {
  border-color: var(--brass);
  background-color: rgba(184,146,58,0.14);
  box-shadow: 0 0 0 2px rgba(184,146,58,0.10);
}
.channel-select option {
  background: var(--ink-2);
  color: var(--text-on-dark);
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 12px;
}
.channel-opt-btn {
  padding: 12px 22px;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  background: rgba(184,146,58,0.08);
  border: 1px solid rgba(184,146,58,0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.channel-opt-btn:hover:not(:disabled) {
  background: rgba(184,146,58,0.18);
  border-color: var(--brass);
  color: #D4AF55;
}
.channel-opt-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

/* Result frame for optimization output */
.channel-opt-frame {
  background: var(--ink-2);
  border: 1px solid rgba(184,146,58,0.25);
  margin-bottom: 8px;
}
.channel-opt-frame-header {
  padding: 12px 20px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  background: linear-gradient(90deg, rgba(184,146,58,0.08), transparent 60%);
  border-bottom: 1px solid rgba(184,146,58,0.18);
}
.channel-opt-frame .rendered {
  padding: 22px;
}
.channel-opt-actions {
  padding: 10px 20px;
  border-top: 1px solid rgba(184,146,58,0.15);
  background: rgba(184,146,58,0.03);
}

/* Light theme */
body.light .channel-optimizer { border-top-color: rgba(26,20,16,0.16); }
body.light .channel-opt-sub { color: var(--text-muted); }
body.light .channel-select { background: rgba(184,146,58,0.06); border-color: rgba(184,146,58,0.35); color: var(--brass-deep); }
body.light .channel-select:hover { background: rgba(184,146,58,0.12); border-color: var(--brass); }
body.light .channel-select:focus { border-color: var(--brass); box-shadow: 0 0 0 2px rgba(184,146,58,0.10); }
body.light .channel-select option { background: #FFFFFF; color: var(--text); }
body.light .channel-opt-btn { color: var(--brass-deep); border-color: rgba(184,146,58,0.40); background: rgba(184,146,58,0.08); }
body.light .channel-opt-frame { background: #FFFEF6; border-color: rgba(184,146,58,0.30); }
body.light .channel-opt-frame-header { background: linear-gradient(90deg, rgba(184,146,58,0.06), transparent 60%); }
body.light .channel-opt-actions { background: rgba(184,146,58,0.04); border-top-color: rgba(184,146,58,0.20); }

/* ---- Image gallery / history ---- */
.img-gallery {
  margin-top: 48px;
}
.img-gallery-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-on-dark-soft);
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.img-gallery-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-dark-2);
}
.img-gallery-label .count {
  font-family: var(--f-mono);
  color: var(--brass);
  background: var(--brass-soft);
  padding: 2px 8px;
  font-size: 10px;
  border: 1px solid rgba(184,146,58,0.3);
}
.img-gallery-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Card — image left, info right */
.img-gallery-card {
  display: grid;
  grid-template-columns: 260px 0fr;
  overflow: hidden;
  border: 1px solid var(--line-dark-2);
  background: var(--ink-2);
  transition: grid-template-columns 0.6s cubic-bezier(0.16,1,0.3,1),
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}
.img-gallery-card.revealed {
  grid-template-columns: 260px 1fr;
  border-color: rgba(184,146,58,0.25);
  box-shadow: 0 6px 24px -8px rgba(0,0,0,0.5);
}

/* Image side */
.img-gallery-card-img {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.img-gallery-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.img-gallery-card-img:hover img {
  transform: scale(1.05);
}

/* Info side — slides in from right */
.img-gallery-card-info {
  overflow: hidden;
  min-width: 0;
}
.img-gallery-card-info-inner {
  padding: 20px 22px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.4s ease 0.3s,
              transform 0.4s cubic-bezier(0.16,1,0.3,1) 0.3s;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.img-gallery-card.revealed .img-gallery-card-info-inner {
  opacity: 1;
  transform: translateX(0);
}

.img-gallery-card-lbl {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 8px;
}
.img-gallery-card-prompt {
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-on-dark-soft);
  margin-bottom: 16px;
  max-height: 140px;
  overflow-y: auto;
  padding-right: 8px;
}
.img-gallery-card-date {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-faint);
  margin-bottom: 18px;
}
.img-gallery-card-btns {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.img-gallery-card-dl,
.img-gallery-card-open {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 7px 14px;
  border: 1px solid;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.img-gallery-card-dl {
  color: var(--brass);
  border-color: rgba(184,146,58,0.35);
  background: rgba(184,146,58,0.06);
}
.img-gallery-card-dl:hover {
  background: rgba(184,146,58,0.16);
  border-color: var(--brass);
  color: #D4AF55;
}
.img-gallery-card-open {
  color: var(--text-on-dark-faint);
  border-color: var(--line-dark-2);
  background: transparent;
}
.img-gallery-card-open:hover {
  color: var(--text-on-dark);
  border-color: var(--signal-line);
  background: rgba(95,216,206,0.04);
}

/* Light theme gallery */
body.light .img-gallery-label { color: var(--text-muted); }
body.light .img-gallery-label::after { background: rgba(26,20,16,0.18); }
body.light .img-gallery-card { background: #FFFEF6; border-color: rgba(26,20,16,0.14); }
body.light .img-gallery-card.revealed { border-color: rgba(184,146,58,0.30); box-shadow: 0 6px 24px -8px rgba(26,20,16,0.18); }
body.light .img-gallery-card-prompt { color: var(--text-soft); }
body.light .img-gallery-card-date { color: var(--text-muted); }
body.light .img-gallery-card-dl { color: var(--brass-deep); border-color: rgba(184,146,58,0.40); background: rgba(184,146,58,0.08); }
body.light .img-gallery-card-open { color: var(--text-muted); border-color: rgba(26,20,16,0.16); }

@media (max-width: 700px) {
  .img-gallery-card { grid-template-columns: 1fr; }
  .img-gallery-card.revealed { grid-template-columns: 1fr; }
  .img-gallery-card-img { aspect-ratio: 4/3; }
}

/* ============================================================
   HERO — full-width image banner with diagonal gradient
   ============================================================ */

.hero {
  position: relative;
  width: 100%;
  height: clamp(320px, 42vh, 520px);
  overflow: hidden;
  margin-bottom: -1px;
}
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
}

/* Diagonal gradient: opaque ink-deep at bottom-left → transparent at top-right */
.hero-gradient {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top right,
      var(--ink-deep) 0%,
      rgba(5,13,20,0.92) 18%,
      rgba(5,13,20,0.72) 38%,
      rgba(5,13,20,0.40) 58%,
      rgba(5,13,20,0.12) 78%,
      rgba(5,13,20,0) 100%
    );
  z-index: 1;
}

/* Subtle brass / signal tint layered on top of the diagonal */
.hero-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5,13,20,0.25) 0%, rgba(5,13,20,0.70) 100%),
    linear-gradient(135deg, rgba(184,146,58,0.08) 0%, transparent 50%);
  pointer-events: none;
}

/* Content overlay — bottom-left aligned */
.hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 0 28px 32px;
  max-width: 1680px;
  margin: 0 auto;
}
.hero-eyebrow {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 1.5px;
  background: var(--brass);
}
.hero-title {
  font-family: var(--f-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text-on-dark);
  text-transform: uppercase;
  margin-bottom: 10px;
  text-shadow: 0 2px 24px rgba(0,0,0,0.5);
}
.hero-title em {
  color: var(--brass);
  font-style: normal;
}
.hero-subtitle {
  font-family: var(--f-display);
  font-size: clamp(12px, 1.5vw, 14.5px);
  line-height: 1.6;
  color: var(--text-on-dark-soft);
  max-width: 560px;
  letter-spacing: 0.01em;
}
.hero-rule {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--brass), rgba(184,146,58,0.18) 70%, transparent);
}

/* Tricolor accent pinned at bottom edge */
.hero-tricolor {
  position: absolute;
  bottom: 0;
  right: 28px;
  z-index: 3;
  display: flex;
  width: 100px;
  height: 4px;
}
.hero-tricolor i { flex: 1; display: block; }
.hero-tricolor i:nth-child(1) { background: var(--flag-green); }
.hero-tricolor i:nth-child(2) { background: var(--flag-white); }
.hero-tricolor i:nth-child(3) { background: var(--flag-red); }

/* Scanline effect for HUD feel */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(5,13,20,0.06) 2px,
    rgba(5,13,20,0.06) 4px
  );
  mix-blend-mode: multiply;
}

/* Light theme adjustments */
body.light .hero-gradient {
  background:
    linear-gradient(to top right,
      var(--ink-deep) 0%,
      rgba(244,239,223,0.92) 18%,
      rgba(244,239,223,0.72) 38%,
      rgba(244,239,223,0.40) 58%,
      rgba(244,239,223,0.12) 78%,
      rgba(244,239,223,0) 100%
    );
}
body.light .hero-gradient::after {
  background:
    linear-gradient(180deg, rgba(244,239,223,0.20) 0%, rgba(244,239,223,0.65) 100%),
    linear-gradient(135deg, rgba(184,146,58,0.06) 0%, transparent 50%);
}
body.light .hero-title {
  color: var(--text);
  text-shadow: 0 2px 16px rgba(244,239,223,0.6);
}
body.light .hero-subtitle { color: var(--text-soft); }
body.light .hero-rule {
  background: linear-gradient(90deg, var(--brass), rgba(184,146,58,0.24) 70%, transparent);
}
body.light .hero::after {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(244,239,223,0.04) 2px,
    rgba(244,239,223,0.04) 4px
  );
}

@media (max-width: 880px) {
  .hero { height: clamp(240px, 36vh, 380px); }
  .hero-content { padding: 0 16px 24px; }
  .hero-tricolor { right: 16px; }
}
@media (max-width: 560px) {
  .hero { height: clamp(200px, 32vh, 300px); }
  .hero-subtitle { display: none; }
}

.chat-mode-desc {
  font-family: var(--f-display);
  font-size: 12.5px;
  color: var(--brass);
  letter-spacing: 0.01em;
  margin-bottom: 14px;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */

.lightbox-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
  cursor: pointer;
}
.lightbox-img {
  max-width: 90vw; max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 20px; right: 28px;
  background: none; border: none;
  color: #fff; font-size: 36px; line-height: 1;
  cursor: pointer; opacity: 0.8;
  transition: opacity 0.15s;
}
.lightbox-close:hover { opacity: 1; }

/* ============================================================
   ADMIN — Centro di Controllo
   ============================================================ */

.admin-layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Tabs */
.admin-tabs {
  display: flex; gap: 2px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-dark-2);
  padding-bottom: 0;
}
.admin-tab {
  background: none; border: none;
  padding: 12px 20px;
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.admin-tab:hover { color: var(--text-on-dark-soft); }
.admin-tab.active {
  color: var(--signal-bright);
  border-bottom-color: var(--signal-bright);
}

/* Content */
.admin-content { min-height: 400px; }
.admin-loading { display: flex; justify-content: center; padding: 60px 0; }

/* Section */
.admin-section-head { margin-bottom: 24px; }
.admin-section-head h3 {
  font-family: var(--f-display); font-size: 18px; font-weight: 600;
  color: var(--text-on-dark); margin: 0 0 6px;
}
.admin-section-head p {
  font-size: 13px; color: var(--text-on-dark-soft); margin: 0;
}
.admin-divider {
  height: 1px; background: var(--line-dark-2);
  margin: 28px 0 20px;
}
.admin-section h4 {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brass); margin: 0 0 16px;
}

/* Form */
.admin-form { display: flex; flex-direction: column; gap: 18px; }
.admin-field { display: flex; flex-direction: column; gap: 6px; }
.admin-field label {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-on-dark-soft); font-weight: 600;
  line-height: 1.2;
  display: inline-flex; align-items: center; gap: 6px;
}
.admin-field label svg { width: 16px; height: 16px; flex-shrink: 0; }
.admin-prompt-agent svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }
.admin-agent-stat-name svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }
.admin-field input {
  padding: 10px 14px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.admin-field input:focus { border-color: var(--signal); }
.admin-field-hint {
  font-size: 11px; color: var(--text-on-dark-faint);
  font-style: italic;
}

.admin-save-btn {
  align-self: flex-start;
  padding: 12px 24px;
  background: var(--signal);
  border: none;
  color: var(--bg-deep);
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  transition: all 0.2s;
  font-weight: 600;
}
.admin-save-btn:hover { background: var(--signal-bright); }
.admin-save-btn:disabled { opacity: 0.6; cursor: default; }

/* Prompts */
.admin-prompt-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
}
.admin-prompt-nav {
  display: flex; flex-direction: column; gap: 4px;
}
.admin-prompt-agent {
  background: none; border: none;
  padding: 10px 14px;
  text-align: left;
  font-family: var(--f-mono); font-size: 11px;
  color: var(--text-on-dark-soft);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.admin-prompt-agent:hover { color: var(--text-on-dark); background: rgba(95,216,206,0.04); }
.admin-prompt-agent.active {
  color: var(--signal-bright);
  border-left-color: var(--signal-bright);
  background: rgba(95,216,206,0.06);
}

.admin-prompt-modes {
  display: flex; gap: 2px; margin-bottom: 12px;
}
.admin-prompt-mode {
  background: none; border: none;
  padding: 8px 14px;
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.admin-prompt-mode.active {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

.admin-prompt-textarea {
  width: 100%; min-height: 400px;
  padding: 16px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.admin-prompt-textarea:focus { border-color: var(--signal); }
.admin-prompt-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
}
.admin-prompt-footer-actions { display: flex; gap: 8px; }
.prompt-btn-secondary {
  background: rgba(255,255,255,0.06) !important;
  color: var(--text-on-dark-soft) !important;
}
.prompt-btn-secondary:hover { background: rgba(255,255,255,0.10) !important; }
.admin-prompt-charcount {
  font-family: var(--f-mono); font-size: 10px;
  color: var(--text-on-dark-faint);
}

/* Prompt full view — shows exactly what the AI receives */
.prompt-full-view { display: flex; flex-direction: column; gap: 8px; }
.prompt-block {
  border: 1px solid var(--line-dark-2);
  background: rgba(10,22,32,0.5);
}
.prompt-block-role {
  padding: 8px 14px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 600;
  border-bottom: 1px solid var(--line-dark-2);
  display: flex; align-items: center; justify-content: space-between;
}
.prompt-block-chars {
  font-weight: 400; opacity: 0.5; letter-spacing: 0.08em;
}
.prompt-block-meta .prompt-block-role { color: var(--text-on-dark-faint); background: rgba(255,255,255,0.02); }
.prompt-block-system .prompt-block-role { color: var(--brass); background: rgba(184,146,58,0.06); }
.prompt-block-history .prompt-block-role { color: var(--text-on-dark-faint); background: rgba(255,255,255,0.02); font-style: italic; }
.prompt-block-user .prompt-block-role { color: var(--signal-bright); background: rgba(95,216,206,0.06); }

.prompt-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px 14px;
}
.prompt-setting { display: flex; flex-direction: column; gap: 4px; }
.prompt-setting label {
  font-family: var(--f-mono); font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-on-dark-faint); font-weight: 600;
}
.prompt-setting-input {
  padding: 6px 10px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 11px;
  outline: none;
  width: 100%;
}
.prompt-setting-input:focus { border-color: var(--signal); }
.prompt-setting-input:disabled { opacity: 0.5; cursor: not-allowed; }
.prompt-setting-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
body.light .prompt-setting-input { background: #fff; border-color: rgba(26,20,16,0.16); color: var(--text); }

.prompt-block-editor {
  width: 100%; min-height: 350px;
  padding: 14px;
  background: transparent;
  border: none; border-top: none;
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.prompt-block-editor:focus { background: rgba(5,11,15,0.4); }

.prompt-block-preview {
  padding: 12px 14px;
  font-family: var(--f-mono); font-size: 11px;
  line-height: 1.5;
  color: var(--text-on-dark-faint);
  font-style: italic;
}

/* Logs */
.admin-logs-filters { margin-bottom: 16px; }
.admin-logs-filters select {
  padding: 8px 14px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 11px;
}

.admin-logs-table { font-size: 12px; }
.admin-logs-header, .admin-logs-row {
  display: grid;
  grid-template-columns: 80px 70px 1fr 100px 60px 60px 100px;
  gap: 10px;
  padding: 10px 14px;
  align-items: center;
}
.admin-logs-header {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  border-bottom: 1px solid var(--line-dark-2);
}
.admin-logs-row {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s;
}
.admin-logs-row:hover { background: rgba(95,216,206,0.04); }
.log-agent {
  font-family: var(--f-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--signal);
}
.log-mode { font-family: var(--f-mono); font-size: 10px; color: var(--brass); }
.log-input {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-on-dark-soft);
}
.log-model { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); }
.log-tokens { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); }
.log-duration { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); }
.log-date { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); }

/* Log detail */
.admin-log-detail { display: none; }
.admin-log-detail.open { display: block; }
.log-detail-inner {
  padding: 18px 20px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  border-top: none;
  margin-bottom: 8px;
}
.log-detail-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-bottom: 16px;
  font-family: var(--f-mono); font-size: 10px;
  color: var(--text-on-dark-faint);
  letter-spacing: 0.08em;
}
.log-detail-meta b { color: var(--text-on-dark-soft); }
.log-detail-label {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brass); font-weight: 600;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.log-detail-label::after { content: ''; flex: 1; height: 1px; background: rgba(184,146,58,0.2); }

.log-messages { display: flex; flex-direction: column; gap: 10px; }
.log-msg {
  border: 1px solid var(--line-dark-2);
  background: rgba(10,22,32,0.5);
}
.log-msg-role {
  padding: 8px 14px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 600;
  border-bottom: 1px solid var(--line-dark-2);
}
.msg-system .log-msg-role { color: var(--brass); background: rgba(184,146,58,0.06); }
.msg-user .log-msg-role { color: var(--signal-bright); background: rgba(95,216,206,0.06); }
.msg-assistant .log-msg-role { color: var(--text-on-dark-soft); background: rgba(255,255,255,0.02); }

.log-msg-content {
  padding: 12px 14px;
  max-height: 400px;
  overflow-y: auto;
}
.log-msg-content pre {
  font-family: var(--f-mono); font-size: 11px;
  line-height: 1.55; color: var(--text-on-dark-soft);
  white-space: pre-wrap; word-break: break-word;
  margin: 0;
}
.log-msg-footer {
  padding: 6px 14px;
  font-family: var(--f-mono); font-size: 9px;
  color: var(--text-on-dark-faint);
  border-top: 1px solid rgba(255,255,255,0.04);
  text-align: right;
}

.admin-load-more {
  display: block; width: 100%;
  margin-top: 16px; padding: 12px;
  background: rgba(95,216,206,0.06);
  border: 1px solid var(--line-dark-2);
  color: var(--signal);
  font-family: var(--f-mono); font-size: 11px;
  cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.14em;
}
.admin-load-more:hover { background: rgba(95,216,206,0.12); }

/* Costs */
.admin-stat-highlight .admin-stat-value { color: var(--brass); font-size: 32px; }
.admin-costs-table { font-size: 12px; }
.admin-costs-header, .admin-costs-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px 90px;
  gap: 10px; padding: 10px 14px; align-items: center;
}
.admin-costs-header {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  border-bottom: 1px solid var(--line-dark-2);
}
.admin-costs-row {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cost-agent { font-size: 12px; color: var(--text-on-dark-soft); }
.cost-agent svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }
.cost-model { font-family: var(--f-mono); font-size: 11px; color: var(--signal); }
.cost-num { font-family: var(--f-mono); font-size: 11px; color: var(--text-on-dark-faint); text-align: right; }
.cost-usd { font-family: var(--f-mono); font-size: 11px; color: var(--brass); font-weight: 600; text-align: right; }

.admin-daily-costs { display: flex; flex-direction: column; gap: 4px; }
.admin-daily-row {
  display: grid; grid-template-columns: 90px 1fr 70px 70px 80px;
  gap: 10px; align-items: center; padding: 6px 0;
}
.daily-date { font-family: var(--f-mono); font-size: 11px; color: var(--text-on-dark-soft); }
.admin-daily-bar-wrap {
  height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden;
}
.admin-daily-bar {
  height: 100%; background: var(--brass); border-radius: 3px;
  transition: width 0.4s ease;
}
.daily-calls { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); text-align: right; }
.daily-tokens { font-family: var(--f-mono); font-size: 10px; color: var(--text-on-dark-faint); text-align: right; }
.daily-cost { font-family: var(--f-mono); font-size: 11px; color: var(--brass); font-weight: 600; text-align: right; }

.admin-pricing-table { display: flex; flex-direction: column; gap: 4px; }
.admin-pricing-row {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
}
.pricing-model { font-family: var(--f-mono); font-size: 11px; color: var(--text-on-dark-soft); flex: 1; }
.pricing-val { font-family: var(--f-mono); font-size: 10px; color: var(--brass); }

/* Users */
.admin-user-create { margin-bottom: 8px; }
.admin-user-create-form {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.admin-user-create-form input[type="text"],
.admin-user-create-form input[type="password"] {
  padding: 10px 14px;
  background: rgba(5,11,15,0.85);
  border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark);
  font-family: var(--f-mono); font-size: 13px;
  outline: none; flex: 1; min-width: 140px;
}
.admin-user-create-form input:focus { border-color: var(--signal); }
.admin-checkbox {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 11px;
  color: var(--text-on-dark-soft);
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer;
}
.admin-users-list { display: flex; flex-direction: column; gap: 4px; }
.admin-user-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 16px; align-items: center;
  padding: 12px 16px;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
}
.admin-user-info { display: flex; align-items: center; gap: 10px; }
.admin-user-name {
  font-family: var(--f-mono); font-size: 13px;
  color: var(--text-on-dark); font-weight: 600;
}
.admin-user-badge {
  font-family: var(--f-mono); font-size: 9px;
  letter-spacing: 0.18em; text-transform: uppercase;
  padding: 2px 8px;
  background: rgba(95,216,206,0.12);
  border: 1px solid rgba(95,216,206,0.3);
  color: var(--signal-bright);
}
.admin-user-meta {
  font-family: var(--f-mono); font-size: 10px;
  color: var(--text-on-dark-faint);
}
.admin-user-actions { display: flex; gap: 6px; }
.admin-user-action {
  background: none; border: 1px solid var(--line-dark-2);
  color: var(--text-on-dark-faint);
  font-family: var(--f-mono); font-size: 10px;
  padding: 4px 10px; cursor: pointer;
  transition: all 0.15s;
}
.admin-user-action:hover { color: var(--signal); border-color: var(--signal-line); }
.admin-user-delete:hover { color: var(--alert); border-color: rgba(178,58,42,0.5); }

/* Stats */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.admin-stat-card {
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
  padding: 20px;
  text-align: center;
}
.admin-stat-value {
  font-family: var(--f-mono); font-size: 28px; font-weight: 700;
  color: var(--signal-bright);
  margin-bottom: 6px;
}
.admin-stat-label {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
}

.admin-agent-stats { display: flex; flex-direction: column; gap: 10px; }
.admin-agent-stat-row {
  display: grid; grid-template-columns: 140px 1fr 50px;
  gap: 14px; align-items: center;
}
.admin-agent-stat-name {
  font-size: 12px; color: var(--text-on-dark-soft);
}
.admin-agent-stat-bar {
  height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: hidden;
}
.admin-agent-stat-fill {
  height: 100%; background: var(--signal);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.admin-agent-stat-count {
  font-family: var(--f-mono); font-size: 12px;
  color: var(--brass); text-align: right;
}

.admin-config-list { display: flex; flex-direction: column; gap: 8px; }
.admin-config-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(10,22,32,0.55);
  border: 1px solid var(--line-dark-2);
}
.admin-config-item span {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--text-on-dark-soft); text-transform: uppercase;
  letter-spacing: 0.1em;
}
.admin-config-item code {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--signal);
}

/* Light theme */
body.light .admin-tab { color: var(--text-faint); }
body.light .admin-tab.active { color: var(--signal-bright); }
body.light .admin-section-head h3 { color: var(--text); }
body.light .admin-field input { background: #fff; border-color: rgba(26,20,16,0.16); color: var(--text); }
body.light .admin-prompt-textarea { background: #fff; border-color: rgba(26,20,16,0.16); color: var(--text); }
body.light .admin-stat-card { background: rgba(255,255,255,0.5); border-color: rgba(26,20,16,0.16); }
body.light .admin-logs-row:hover { background: rgba(56,116,76,0.06); }
body.light .admin-config-item { background: rgba(255,255,255,0.5); border-color: rgba(26,20,16,0.16); }

/* Responsive */
@media (max-width: 700px) {
  .admin-prompt-layout { grid-template-columns: 1fr; }
  .admin-prompt-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-logs-header, .admin-logs-row { grid-template-columns: 60px 1fr 60px; }
  .admin-logs-header span:nth-child(4),
  .admin-logs-header span:nth-child(5),
  .admin-logs-header span:nth-child(6),
  .admin-logs-row span:nth-child(4),
  .admin-logs-row span:nth-child(5),
  .admin-logs-row span:nth-child(6) { display: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }