:root{
  --bg:#071018;
  --txt:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.68);
  --line:rgba(255,255,255,.12);

  --ok:#5fffd0;
  --cyan:#7dd3ff;
  --warn:#ff6a8a;
  --amber:#ffcc66;

  --crt:#9affd6;

  --red1:#ff315f;
  --red2:#ff6a8a;
  --org1:#ffb14a;
  --org2:#ffd36e;
  --grn1:#5fffd0;
  --grn2:#7dd3ff;
}

html, body{ height:100%; overflow:hidden; }
body{
  margin:0;
  background: radial-gradient(1200px 600px at 50% 0%, #0b1b23 0%, var(--bg) 60%);
  color:var(--txt);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.hidden{ display:none !important; }

/* Keep boot styles from v2 (index.html) */
.boot{ height:100vh; display:flex; align-items:stretch; }
.boot-inner{ width:100%; display:grid; grid-template-columns: 1.1fr 0.9fr; gap:18px; padding:22px; box-sizing:border-box; }
.frame{ background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding:18px; box-sizing:border-box; box-shadow: 0 30px 80px rgba(0,0,0,.45); position:relative; overflow:hidden; }
.boot-right{ display:flex; flex-direction:column; justify-content:flex-start; }
.boot-title{ margin:0; font-size:28px; letter-spacing:.08em; }
.boot-sub{ margin:6px 0 14px; color:var(--muted); }
.terminal{ margin-top:6px; background: rgba(0,0,0,.26); border:1px solid rgba(255,255,255,.10); border-radius: 14px; padding:14px; }
.term-line{ padding:4px 0; }
.term-line.warn{ color: rgba(255,120,150,.95); }
.term-line.dim{ color: rgba(255,255,255,.55); }
.progress{ height:8px; background: rgba(255,255,255,.08); border-radius: 999px; overflow:hidden; margin-top:12px; border:1px solid rgba(255,255,255,.10); }
.bar{ height:100%; width:0%; background: linear-gradient(90deg, var(--ok), var(--cyan)); }
.hint{ margin-top:10px; color:rgba(255,255,255,.55); font-size:12px; }

/* Boot photo cinematic */
.photo-wrap{ position: relative; overflow: hidden; border-radius: 18px; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 20px 60px rgba(0,0,0,.55); }
.photo-wrap img{ display:block; width:100%; height:auto; transform: scale(1.02); filter: saturate(1.05) contrast(1.05); }
.photo-wrap .wipe{ position:absolute; inset:-10%; background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.85) 45%, rgba(0,0,0,1) 55%, rgba(0,0,0,0) 100%); mix-blend-mode: multiply; opacity: .95; transform: translateX(-80%); animation: bootWipe 20s linear forwards; }
.photo-wrap .pixelwipe{ position:absolute; inset:-10%; background: repeating-linear-gradient(90deg, rgba(255,255,255,.00) 0px, rgba(255,255,255,.00) 6px, rgba(255,255,255,.08) 7px), repeating-linear-gradient(0deg, rgba(255,255,255,.00) 0px, rgba(255,255,255,.00) 8px, rgba(255,255,255,.06) 9px); opacity: .18; filter: blur(.2px); transform: translateX(-70%); animation: bootPixel 20s linear forwards; mix-blend-mode: screen; }
.photo-wrap .glitch{ position:absolute; inset:0; background: linear-gradient(90deg, rgba(0,255,200,.12), rgba(0,0,0,0) 30%, rgba(120,200,255,.10)), repeating-linear-gradient(0deg, rgba(255,255,255,.00) 0px, rgba(255,255,255,.00) 3px, rgba(255,255,255,.03) 4px); opacity: .0; mix-blend-mode: screen; animation: bootGlitch 2.2s steps(2,end) infinite; }
.photo-wrap .scanbeam{ position:absolute; left:-10%; right:-10%; height: 28%; top:-30%; background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(120,255,210,.05) 35%, rgba(120,255,210,.22) 50%, rgba(120,255,210,.05) 65%, rgba(0,0,0,0) 100%); filter: blur(8px); mix-blend-mode: screen; opacity: .8; animation: bootScan 1.8s linear infinite; }
.photo-wrap .stamp{ position:absolute; right: 14px; bottom: 12px; padding: 6px 10px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.9); font-size: 12px; letter-spacing: .08em; }
@keyframes bootWipe{ 0%{ transform: translateX(-85%); opacity:.95; } 65%{ transform: translateX(10%); opacity:.85; } 100%{ transform: translateX(120%); opacity:.0; } }
@keyframes bootPixel{ 0%{ transform: translateX(-80%); opacity:.22; } 75%{ transform: translateX(20%); opacity:.16; } 100%{ transform: translateX(120%); opacity:.0; } }
@keyframes bootGlitch{ 0%,60%{ opacity:0; transform: translateX(0); } 62%{ opacity:.22; transform: translateX(-6px); } 64%{ opacity:.10; transform: translateX(8px); } 66%{ opacity:.18; transform: translateX(-3px); } 68%{ opacity:0; transform: translateX(0); } 100%{ opacity:0; } }
@keyframes bootScan{ 0%{ top:-35%; opacity:.0; } 10%{ opacity:.9; } 60%{ top:110%; opacity:.8; } 100%{ top:140%; opacity:0; } }

/* HUB BG */
.bg-tech{
  position:fixed; inset:0; pointer-events:none; z-index:0; opacity:.90;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(125,211,255,.08), rgba(0,0,0,0) 35%),
    radial-gradient(circle at 80% 20%, rgba(95,255,208,.06), rgba(0,0,0,0) 40%),
    linear-gradient(0deg, rgba(255,255,255,.03), rgba(0,0,0,0));
}
.overlay-vignette{
  position:fixed; inset:0; pointer-events:none; z-index:1;
  background: radial-gradient(900px 500px at 50% 30%, rgba(0,0,0,0) 0%, rgba(0,0,0,.65) 70%, rgba(0,0,0,.85) 100%);
  opacity:.55;
}

.app{
  position:relative; z-index:2; height:100vh; box-sizing:border-box;
  padding:22px; display:flex; flex-direction:column; gap:14px;
}

/* Header */
.top{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:16px 18px; border-radius:18px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.10);
}
.brand .title{ font-size:18px; letter-spacing:.12em; }
.brand .sub{ margin-top:4px; color:var(--muted); font-size:12px; letter-spacing:.10em; }

.timer{ text-align:right; }
.timer-label{ font-size:11px; letter-spacing:.18em; color:var(--muted); }
.timer-value{ font-size:28px; letter-spacing:.08em; }
.timer-sub{ margin-top:2px; font-size:11px; letter-spacing:.14em; color:rgba(255,255,255,.55); }
.timer-big .timer-value{ font-size:36px; }
.timer-big .timer-label{ font-size:12px; }
.timer-big .timer-sub{ font-size:12px; }

/* Layout */
.layout{
  flex:1; display:grid; grid-template-columns: 1.2fr 0.8fr;
  gap:14px; overflow:hidden;
}

.panel{
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.10);
  border-radius:18px;
  padding:16px 18px;
  position:relative;
  overflow:hidden;
}
.panel h2{
  margin:0 0 10px;
  font-size:12px;
  letter-spacing:.18em;
  color: rgba(255,255,255,.88);
}

.sep{ border:0; border-top:1px solid rgba(255,255,255,.10); margin:14px 0; }

/* Validation emphasis */
.validate-panel{
  border-color: rgba(125,211,255,.16);
  box-shadow: 0 0 0 1px rgba(125,211,255,.05), 0 20px 60px rgba(0,0,0,.35);
}
.big-callout{
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(125,211,255,.18);
  background: rgba(125,211,255,.08);
  letter-spacing: .18em;
  font-size: 12px;
  color: rgba(180,235,255,.95);
}

/* Inputs */
.validate{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.validate-big{ margin-top:6px; }
.code{
  flex:1; min-width: 240px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  color: var(--txt);
  outline:none;
}
.code-big{ padding: 16px 14px; font-size: 16px; border-radius: 14px; }
.btn, button{
  cursor:pointer;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: var(--txt);
  font-weight: 800;
  letter-spacing: .08em;
}
.btn-big{ padding: 16px 16px; font-size: 14px; border-radius: 14px; }
button:disabled{ opacity:.45; cursor:not-allowed; }

.msg{ margin-top: 10px; min-height: 18px; }
.msg.ok{ color: var(--ok); }
.msg.bad{ color: var(--warn); }

.final-box{ margin-top:14px; padding-top:14px; border-top:1px solid rgba(255,255,255,.10); }
.final-title{ letter-spacing:.16em; opacity:.85; font-size:12px; }

/* ===== CRT monitor ===== */
.crt-shell{ padding:14px 14px 18px; }
.crt-topbar{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.crt-title{ letter-spacing:.16em; font-size:12px; color: rgba(255,255,255,.80); }
.crt-badges{ display:flex; gap:8px; flex-wrap:wrap; }
.pill{
  border-radius:999px;
  padding:8px 10px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  letter-spacing:.12em;
  font-size:12px;
  white-space: nowrap;
}
.pill-ok{
  border-color: rgba(95,255,208,.22);
  background: rgba(95,255,208,.10);
  color: rgba(200,255,240,.95);
}
.pill-bad{
  border-color: rgba(255,106,138,.25);
  background: rgba(255,106,138,.10);
  color: rgba(255,190,205,.95);
}

.crt-screen{
  position:relative;
  border-radius:22px;
  background: radial-gradient(900px 380px at 50% 20%, rgba(110,255,215,.10), rgba(0,0,0,0) 55%),
              radial-gradient(700px 420px at 50% 80%, rgba(125,211,255,.08), rgba(0,0,0,0) 60%),
              rgba(0,0,0,.50);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  overflow:hidden;
  padding:14px;
  transform: perspective(1200px) rotateX(1deg);
}
.crt-scanlines{
  position:absolute; inset:0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0px, rgba(255,255,255,.03) 1px, rgba(0,0,0,0) 3px);
  opacity:.18;
  pointer-events:none;
}
.crt-noise{
  position:absolute; inset:0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.20'/%3E%3C/svg%3E");
  opacity:.10;
  mix-blend-mode: overlay;
  pointer-events:none;
  animation: noiseShift 1.8s steps(2,end) infinite;
}
@keyframes noiseShift{ 0%{ transform: translate(0,0); } 100%{ transform: translate(-10px, 6px); } }
.crt-glow{
  position:absolute; inset:-20%;
  background: radial-gradient(closest-side at 50% 50%, rgba(110,255,215,.14), rgba(0,0,0,0) 55%);
  opacity:.55; pointer-events:none;
}
.crt-grid{
  position:relative; z-index:2;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
.crt-block{
  border-radius:16px;
  border:1px solid rgba(110,255,215,.12);
  background: rgba(0,0,0,.28);
  padding:12px;
  overflow:hidden;
}
.span2{ grid-column: 1 / -1; }
.crt-h{
  letter-spacing:.18em;
  font-size:11px;
  color: rgba(154,255,214,.92);
  margin-bottom:8px;
}
.crt-sub{
  margin-top:10px;
  color: rgba(154,255,214,.78);
  letter-spacing:.10em;
  font-size:12px;
}
.crt-kpis{
  margin-top:8px;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  color: rgba(154,255,214,.85);
  font-size:12px;
  letter-spacing:.10em;
}
.crt-canvas{
  width:100%;
  height:auto;
  display:block;
  border-radius:12px;
  border:1px solid rgba(110,255,215,.12);
  background: rgba(0,0,0,.22);
}
.crt-log{
  height: 140px;
  overflow:hidden;
  border-radius:12px;
  border:1px solid rgba(110,255,215,.12);
  background: rgba(0,0,0,.22);
  padding:10px;
  color: rgba(154,255,214,.82);
  letter-spacing:.08em;
  line-height: 1.5;
  font-size:12px;
}
.crt-stand{
  height: 16px;
  width: 70%;
  margin: 12px auto 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  filter: blur(.1px);
}

/* CRT meter */
.meter{
  height: 12px;
  border-radius: 999px;
  overflow:hidden;
  border: 1px solid rgba(110,255,215,.14);
  background: rgba(255,255,255,.06);
}
.meter-fill{
  height:100%;
  width:0%;
  border-radius:999px;
  background: linear-gradient(90deg, var(--red1), var(--red2));
  box-shadow: 0 0 18px rgba(255,49,95,.20);
  transition: width .35s ease, filter .35s ease, background .35s ease;
}
body.p-low  .meter-fill{ background: linear-gradient(90deg, var(--red1), var(--red2)); box-shadow:0 0 18px rgba(255,49,95,.18); }
body.p-mid  .meter-fill{ background: linear-gradient(90deg, var(--org1), var(--org2)); box-shadow:0 0 18px rgba(255,204,102,.18); }
body.p-high .meter-fill{ background: linear-gradient(90deg, var(--grn1), var(--grn2)); box-shadow:0 0 18px rgba(95,255,208,.20); }

/* Cards */
.grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.card{
  display:block;
  padding:12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.10);
  text-decoration:none;
  color: var(--txt);
  position:relative;
  overflow:hidden;
  background: rgba(255,255,255,.06);
  transform: translateZ(0);
}
.card-title{ font-weight:800; letter-spacing:.04em; }
.card-sub{ margin-top:4px; font-size:12px; color: var(--muted); letter-spacing:.10em; }
.card-state{
  position:absolute; right:10px; top:10px;
  font-size:10px; letter-spacing:.18em;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color: rgba(255,255,255,.75);
}
.state-locked{
  background: linear-gradient(180deg, rgba(255,49,95,.10), rgba(255,255,255,.04));
  border-color: rgba(255,49,95,.22);
  box-shadow: inset 0 0 0 1px rgba(255,49,95,.10);
}
.state-locked .card-state{
  border-color: rgba(255,49,95,.25);
  color: rgba(255,160,180,.90);
}
.state-active{
  background: linear-gradient(180deg, rgba(255,204,102,.12), rgba(255,255,255,.05));
  border-color: rgba(255,204,102,.22);
  box-shadow: inset 0 0 0 1px rgba(255,204,102,.10);
}
.state-active .card-state{
  border-color: rgba(255,204,102,.25);
  color: rgba(255,220,150,.95);
}
.state-done{
  background: linear-gradient(180deg, rgba(95,255,208,.12), rgba(255,255,255,.05));
  border-color: rgba(95,255,208,.22);
  box-shadow: inset 0 0 0 1px rgba(95,255,208,.10);
}
.state-done .card-state{
  border-color: rgba(95,255,208,.25);
  color: rgba(170,255,235,.98);
}
.card::after{
  content:"";
  position:absolute; inset:-60% -60%;
  opacity:.85;
  background: linear-gradient(120deg, rgba(255,255,255,0) 35%, rgba(125,211,255,.10) 50%, rgba(255,255,255,0) 65%);
  animation: sweep 6.8s linear infinite;
}
.state-locked::after{
  background: linear-gradient(120deg, rgba(255,49,95,0) 35%, rgba(255,49,95,.10) 50%, rgba(255,49,95,0) 65%);
  animation-duration: 7.8s;
}
.state-active::after{
  background: linear-gradient(120deg, rgba(255,204,102,0) 35%, rgba(255,204,102,.12) 50%, rgba(255,204,102,0) 65%);
  animation-duration: 4.9s;
}
.state-done::after{
  background: linear-gradient(120deg, rgba(95,255,208,0) 35%, rgba(95,255,208,.10) 50%, rgba(95,255,208,0) 65%);
  animation-duration: 6.2s;
}
@keyframes sweep{ 0%{ transform: translateX(-35%) translateY(-10%); } 100%{ transform: translateX(35%) translateY(10%); } }

/* FX */
body.fx-ok::before,
body.fx-bad::before{
  content:"";
  position:fixed; inset:0; pointer-events:none; z-index:9999; opacity:0;
}
body.fx-ok::before{
  background: radial-gradient(600px 300px at 50% 20%, rgba(90,255,200,.22), rgba(0,0,0,0) 65%);
  opacity:1;
}
body.fx-bad::before{
  background: radial-gradient(600px 300px at 50% 20%, rgba(255,90,120,.20), rgba(0,0,0,0) 65%);
  opacity:1;
}

.foot{
  padding:10px 14px;
  border-radius:16px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.60);
}

/* Responsive */
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .boot-inner{ grid-template-columns: 1fr; }
}
@media (max-width: 560px){
  .grid{ grid-template-columns: 1fr; }
}

/* ===== Cinematic boot terminal states ===== */
.term-line{ display:flex; gap:10px; align-items:center; }
.term-line .label{ min-width: 210px; }
.term-line .dots{ width: 80px; display:inline-block; letter-spacing:.18em; }
.term-line .status{ opacity:.9; letter-spacing:.12em; }

.term-pending{ color: rgba(255,255,255,.55); }
.term-working{ color: var(--amber); text-shadow: 0 0 12px rgba(255,204,102,.14); }
.term-ok{ color: rgba(200,255,240,.98); text-shadow: 0 0 14px rgba(95,255,208,.18); }
.term-bad{ color: rgba(255,190,205,.98); text-shadow: 0 0 14px rgba(255,106,138,.18); }

.cursor{
  display:inline-block;
  width: 10px;
  margin-left: 2px;
  color: rgba(154,255,214,.9);
  animation: cursorBlink .9s steps(2,end) infinite;
}
@keyframes cursorBlink{ 0%,40%{ opacity:1; } 50%,100%{ opacity:0; } }

/* Glitch-out at the end of boot */
body.glitch-out .frame{ animation: bootShake .14s steps(2,end) infinite; }
@keyframes bootShake{
  0%{ transform: translate(0,0); }
  25%{ transform: translate(1px,-1px); }
  50%{ transform: translate(-1px,1px); }
  75%{ transform: translate(2px,0); }
  100%{ transform: translate(0,0); }
}
body.glitch-out .photo-wrap img{ filter: saturate(1.15) contrast(1.20) hue-rotate(-8deg); }
body.glitch-out .photo-wrap .glitch{ opacity:.26; }
body.glitch-out::after{
  content:"";
  position:fixed; inset:0; z-index:9998; pointer-events:none;
  background: radial-gradient(800px 400px at 50% 25%, rgba(255,204,102,.12), rgba(0,0,0,0) 60%),
              radial-gradient(700px 300px at 50% 30%, rgba(255,106,138,.10), rgba(0,0,0,0) 65%);
  animation: bootFlash .18s steps(2,end) infinite;
  opacity:.55;
}
@keyframes bootFlash{
  0%{ opacity:.10; }
  50%{ opacity:.60; }
  100%{ opacity:.18; }
}
