:root {
  --bg: #04060a;
  --bg2: #060a12;
  --cyan: #3ee6ff;
  --cyan-dim: #1a7d94;
  --cyan-bright: #baf6ff;
  --amber: #ffb648;
  --danger: #ff4d5e;
  --glass: rgba(10, 22, 32, 0.55);
  --border: rgba(62, 230, 255, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 20%, #0a1622 0%, var(--bg) 60%, #010204 100%);
  color: var(--cyan-bright);
  font-family: "Segoe UI", "Consolas", monospace;
  overflow: hidden;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(62, 230, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62, 230, 255, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 10%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    rgba(62, 230, 255, 0.025) 0px,
    rgba(62, 230, 255, 0.025) 1px,
    transparent 2px,
    transparent 4px
  );
  opacity: 0.5;
}

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

.panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 24px rgba(62, 230, 255, 0.08), inset 0 0 30px rgba(62, 230, 255, 0.04);
}

/* ============ LOGIN ============ */

.login-box {
  width: min(420px, 90vw);
  padding: 40px 36px 32px;
  text-align: center;
}

.login-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--cyan-bright);
  text-shadow: 0 0 18px var(--cyan);
}

.login-sub {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cyan-dim);
}

.login-ring {
  width: 120px;
  height: 120px;
  margin: 28px auto;
  animation: spin 6s linear infinite;
}
.login-ring svg { width: 100%; height: 100%; }
.login-ring circle {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 2;
  stroke-dasharray: 12 10;
  opacity: 0.75;
  filter: drop-shadow(0 0 6px var(--cyan));
}

#password-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cyan-bright);
  font-size: 14px;
  letter-spacing: 2px;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
}
#password-input:focus { border-color: var(--cyan); box-shadow: 0 0 12px rgba(62,230,255,0.3); }

.login-error {
  margin-top: 12px;
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
  letter-spacing: 1px;
}

button {
  cursor: pointer;
  font-family: inherit;
}

#login-btn, .ctrl-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(180deg, rgba(62,230,255,0.18), rgba(62,230,255,0.06));
  border: 1px solid var(--cyan);
  border-radius: 6px;
  color: var(--cyan-bright);
  font-size: 13px;
  letter-spacing: 3px;
  font-weight: 600;
  transition: all 0.2s ease;
}
#login-btn:hover, .ctrl-btn:hover {
  background: linear-gradient(180deg, rgba(62,230,255,0.32), rgba(62,230,255,0.1));
  box-shadow: 0 0 18px rgba(62,230,255,0.45);
}
.ctrl-btn.ghost {
  background: transparent;
  border-color: var(--cyan-dim);
  color: var(--cyan-dim);
}
.ctrl-btn.ghost:hover { border-color: var(--cyan); color: var(--cyan-bright); }
.ctrl-btn.active {
  border-color: var(--danger);
  color: var(--danger);
}

/* ============ MAIN HUD ============ */

.hud-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 40px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--cyan-bright);
  text-shadow: 0 0 10px var(--cyan);
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.conn-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan-dim);
}
.conn-status.online .dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.conn-status.online { color: var(--cyan-bright); }
.conn-status.offline .dot { background: #555; }
.conn-status.offline { color: #667; }

.core-wrap {
  position: relative;
  width: min(58vh, 58vw);
  height: min(58vh, 58vw);
  display: flex;
  align-items: center;
  justify-content: center;
}
#core-canvas { width: 100%; height: 100%; }
.core-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.state-label {
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--cyan-bright);
  text-shadow: 0 0 10px var(--cyan);
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(4, 10, 16, 0.55);
}

.webcam-panel {
  position: absolute;
  top: 90px;
  right: 40px;
  width: 320px;
  padding: 12px 14px;
}
.webcam-panel .panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.webcam-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.4);
}
#webcam-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ============ MODALITA CREATIVA (schizzo vettoriale a tutto schermo) ============ */

.creative-screen {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 20%, #0a1622 0%, var(--bg) 60%, #010204 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.creative-screen.fade-in { opacity: 1; }
.creative-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 40px;
}
.creative-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--cyan-bright);
  text-shadow: 0 0 10px var(--cyan);
}
.creative-status {
  flex: 1;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--cyan-dim);
}
#creative-exit-btn { width: auto; padding: 8px 20px; font-size: 11px; }

.creative-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}
.creative-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.creative-step-caption {
  text-align: center;
  padding: 12px 40px 32px;
  min-height: 20px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--cyan-bright);
  opacity: 0.85;
}

.panels {
  position: absolute;
  bottom: 96px;
  left: 40px;
  right: 40px;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  pointer-events: none;
}
.side-panel {
  width: 320px;
  max-height: 220px;
  padding: 14px 16px;
  pointer-events: auto;
}
.panel-title {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cyan-dim);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.transcript, .tool-log {
  max-height: 160px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--cyan-bright);
  opacity: 0.9;
}
.transcript div, .tool-log div { margin-bottom: 6px; }
.tool-log .tool-name { color: var(--amber); }

.controls {
  position: absolute;
  bottom: 28px;
  display: flex;
  gap: 16px;
}
.controls .ctrl-btn { width: auto; padding: 10px 22px; }

/* ============ STANDBY ============ */

.standby-box { text-align: center; }
.standby-ring {
  width: 160px; height: 160px; margin: 0 auto 24px;
  animation: spin 10s linear infinite reverse;
}
.standby-ring svg { width: 100%; height: 100%; }
.standby-ring circle {
  fill: none; stroke: var(--cyan-dim); stroke-width: 1.5;
  stroke-dasharray: 4 14; opacity: 0.6;
}
.standby-text {
  font-size: 15px; letter-spacing: 5px; color: var(--cyan-dim);
  margin-bottom: 24px;
}

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

/* ============ NOTIFICHE PROATTIVE ============ */

.notify-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 84vw);
  pointer-events: none;
}

.notify-card {
  pointer-events: auto;
  padding: 12px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 24px rgba(62, 230, 255, 0.15);
  animation: notify-in 0.25s ease-out;
}
.notify-card .notify-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
  margin-bottom: 6px;
}
.notify-card .notify-close {
  cursor: pointer;
  color: var(--cyan-dim);
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.notify-card .notify-close:hover { color: var(--cyan-bright); }
.notify-card .notify-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--cyan-bright);
}
.notify-card.fade-out { animation: notify-out 0.3s ease-in forwards; }

@keyframes notify-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes notify-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

/* ============ PANNELLO STAMPA ============ */

.print-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 10, 0.65);
  backdrop-filter: blur(3px);
}

.print-panel {
  width: min(440px, 90vw);
  max-height: 82vh;
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.print-panel .panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.print-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
#print-search-input {
  flex: 1;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cyan-bright);
  font-size: 12.5px;
  outline: none;
}
#print-search-input:focus { border-color: var(--cyan); }

.print-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 10px 14px;
  font-size: 11px;
}

.print-results {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.print-result-item {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  color: var(--cyan-bright);
  opacity: 0.85;
  cursor: pointer;
}
.print-result-item:hover {
  background: rgba(62, 230, 255, 0.08);
  border-color: var(--border);
}
.print-result-item.selected {
  background: rgba(62, 230, 255, 0.14);
  border-color: var(--cyan);
  opacity: 1;
}
.print-result-empty {
  font-size: 12px;
  color: var(--cyan-dim);
  padding: 8px 2px;
}

.print-selected {
  margin-bottom: 14px;
  padding: 8px 10px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  font-size: 12px;
  color: var(--cyan-bright);
  background: rgba(62, 230, 255, 0.08);
}

.print-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.print-option-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.print-option-label {
  width: 84px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--cyan-dim);
}
.print-toggle {
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 1px;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  border-radius: 6px;
  color: var(--cyan-dim);
  transition: all 0.15s ease;
}
.print-toggle.active {
  border-color: var(--cyan);
  color: var(--cyan-bright);
  background: rgba(62, 230, 255, 0.12);
}
#print-printer-select {
  flex: 1;
  min-width: 140px;
  padding: 7px 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cyan-bright);
  font-size: 11.5px;
}

#print-submit-btn {
  width: 100%;
}
#print-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.print-status {
  margin-top: 10px;
  min-height: 16px;
  font-size: 12px;
  color: var(--cyan-bright);
  text-align: center;
}
.print-status.error { color: var(--danger); }
