/* ============================================================
 * Plugspace CRT Design System — Bloomberg green phosphor
 * Extracted from globals.css for prototype reproduction
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core CRT palette */
  --bg: #020602;
  --bg-screen: #040b04;
  --green: #2bff5e;
  --green-bright: #8dffb0;
  --green-dim: #1aa343;
  --green-faint: #0f6e2c;
  --amber: #ffb000;
  --red: #ff5555;
  --foreground: #c8ffc8;

  /* Semantic tokens */
  --surface: #040b04;
  --muted: #0a1a0a;
  --border: #0f6e2c;
  --radius: 0.375rem;

  /* Fonts */
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-pixel: 'VT323', ui-monospace, monospace;
}

html, body { height: 100%; }

html {
  font-size: clamp(9.75px, 0.833vw, 15.75px);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-bright); }

button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  background: transparent;
  border: none;
  color: var(--green-bright);
  outline: none;
}

@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ---- Typography ---- */

.wordmark {
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

.phosphor {
  text-shadow:
    0.6px 0 0 rgba(255, 60, 60, 0.4),
    -0.6px 0 0 rgba(60, 160, 255, 0.4),
    0 0 2px rgba(43, 255, 94, 0.7),
    0 0 7px rgba(43, 255, 94, 0.4);
}

.phosphor-strong {
  text-shadow:
    1.2px 0 0 rgba(255, 60, 60, 0.45),
    -1.2px 0 0 rgba(60, 160, 255, 0.45),
    0 0 3px rgba(141, 255, 176, 0.9),
    0 0 12px rgba(43, 255, 94, 0.65),
    0 0 28px rgba(43, 255, 94, 0.4);
}

/* ---- CRT Screen Shell ---- */

.crt-screen {
  position: relative;
  border-radius: 18px / 14px;
  background: var(--bg-screen);
  box-shadow:
    0 0 60px rgba(43, 255, 94, 0.12),
    inset 0 0 80px rgba(0, 0, 0, 0.75),
    inset 0 0 18px rgba(43, 255, 94, 0.08);
  overflow: hidden;
}

.crt-scanlines::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px, rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.35) 2px, rgba(0, 0, 0, 0.35) 3px
  );
  z-index: 30;
  mix-blend-mode: multiply;
}

.crt-grille::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to right,
    rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02) 1px,
    rgba(0, 0, 255, 0.04) 2px, rgba(0, 0, 0, 0) 3px
  );
  z-index: 30;
}

.crt-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 31;
  background: radial-gradient(
    ellipse 100% 100% at center,
    rgba(43, 255, 94, 0.05) 0%,
    rgba(0, 0, 0, 0) 42%,
    rgba(0, 0, 0, 0.45) 88%,
    rgba(0, 0, 0, 0.7) 100%
  );
}

@keyframes sweep {
  0% { transform: translateY(-20%); }
  100% { transform: translateY(120%); }
}

.crt-sweep {
  position: absolute;
  left: 0; right: 0;
  height: 14%;
  z-index: 32;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(43, 255, 94, 0) 0%,
    rgba(43, 255, 94, 0.05) 50%,
    rgba(43, 255, 94, 0) 100%
  );
  animation: sweep 7s linear infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  88% { opacity: 1; }
  89% { opacity: 0.82; }
  90% { opacity: 1; }
  95% { opacity: 0.9; }
  96% { opacity: 1; }
}

.crt-flicker { animation: flicker 5s infinite; }

/* Power-on */
@keyframes powerOn {
  0% { transform: scale(1.3, 0.001); filter: brightness(6); opacity: 0; }
  35% { transform: scale(1.3, 0.004); filter: brightness(6); opacity: 1; }
  60% { transform: scale(1, 0.02); filter: brightness(4); }
  100% { transform: scale(1, 1); filter: brightness(1); opacity: 1; }
}
.power-on { animation: powerOn 0.9s ease-out; transform-origin: center; }

/* Cursor */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.cursor-block {
  display: inline-block;
  width: 0.55em; height: 0.95em;
  background: var(--green);
  margin-left: 2px;
  vertical-align: baseline;
  animation: blink 1.1s step-end infinite;
  box-shadow: 0 0 8px rgba(43, 255, 94, 0.7);
}

/* Line fade-in */
@keyframes lineIn {
  from { opacity: 0; transform: translateX(-2px); }
  to { opacity: 1; transform: translateX(0); }
}
.line-in { animation: lineIn 0.1s ease-out; }

/* Scrollbar */
.term-scroll::-webkit-scrollbar { width: 8px; }
.term-scroll::-webkit-scrollbar-track { background: transparent; }
.term-scroll::-webkit-scrollbar-thumb { background: var(--green-faint); border-radius: 0; }

/* ---- Radar ---- */

.radar {
  position: relative;
  width: 200px; height: 200px;
  border-radius: 50%;
  border: 2px solid var(--green-faint);
  background:
    repeating-radial-gradient(circle at center,
      rgba(43, 255, 94, 0.12) 0, rgba(43, 255, 94, 0.12) 1px,
      transparent 1px, transparent 33px),
    radial-gradient(circle at center, rgba(43, 255, 94, 0.07), rgba(0, 0, 0, 0.5));
  box-shadow: 0 0 22px rgba(43, 255, 94, 0.28), inset 0 0 28px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.radar::before, .radar::after {
  content: ""; position: absolute;
  background: rgba(43, 255, 94, 0.22); z-index: 1;
}
.radar::before { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px); }
.radar::after { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-0.5px); }

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

.radar-sweep {
  position: absolute; inset: 0; z-index: 2;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(43, 255, 94, 0.6), rgba(43, 255, 94, 0.14) 40deg,
    transparent 75deg, transparent 360deg);
  animation: radarSpin 2.4s linear infinite;
  mix-blend-mode: screen;
}

.blip {
  position: absolute; z-index: 3;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 9px rgba(43, 255, 94, 0.95);
  animation: blink 1.8s step-end infinite;
}

/* ---- Panel boot ---- */
@keyframes panelBoot {
  0% { opacity: 0; transform: translateY(8px) scaleY(0.96); filter: brightness(1.6); }
  60% { filter: brightness(1.15); }
  100% { opacity: 1; transform: translateY(0) scaleY(1); filter: brightness(1); }
}

.panel-boot {
  animation: panelBoot 0.45s ease-out both;
  will-change: opacity, transform, filter;
}

/* ---- Drawer ---- */
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-in { animation: drawerIn 0.22s ease-out; }

/* ---- Panel loading effects ---- */

@keyframes panelBreathe {
  0%, 100% { border-color: var(--green-faint); box-shadow: inset 0 0 0 rgba(43,255,94,0), 0 0 0 rgba(43,255,94,0); }
  50% { border-color: var(--green-bright); box-shadow: inset 0 0 16px rgba(43,255,94,0.28), 0 0 18px 1px rgba(43,255,94,0.45); }
}

@keyframes haloPulse {
  0%, 100% { border-color: var(--green); box-shadow: 0 0 0 1px rgba(43,255,94,0.6), 0 0 18px 2px rgba(43,255,94,0.45); }
  50% { border-color: var(--green-bright); box-shadow: 0 0 0 1px rgba(141,255,176,1), 0 0 34px 8px rgba(43,255,94,0.8), 0 0 70px 18px rgba(43,255,94,0.45); }
}

@keyframes holoShimmer {
  0% { background-position: -130% 0, 0 0; }
  100% { background-position: 230% 0, 0 0; }
}

/* ---- Utility classes ---- */

.text-green { color: var(--green); }
.text-green-bright { color: var(--green-bright); }
.text-green-dim { color: var(--green-dim); }
.text-green-faint { color: var(--green-faint); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-fg { color: var(--foreground); }
.text-bg { color: var(--bg); }

.bg-bg { background: var(--bg); }
.bg-screen { background: var(--bg-screen); }
.bg-green-dim { background: var(--green-dim); }

.border-green { border-color: var(--green); }
.border-green-faint { border-color: var(--green-faint); }
.border-amber { border-color: var(--amber); }

/* ---- Shared Shell ---- */

.shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

@media (min-width: 640px) { .shell { padding: 3rem 1rem; } }

.shell-ambient {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at top, rgba(43,255,94,0.07), transparent 60%);
}

.shell-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 48rem;
}

.shell-centered .shell-body { display: flex; flex-direction: column; flex: 1; justify-content: center; }

.shell-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(15, 110, 44, 0.4);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--green-dim);
}

.shell-header {
  text-align: center;
  margin-bottom: 2rem;
}

@media (min-width: 640px) { .shell-header { margin-bottom: 2.5rem; } }

.shell-title {
  font-family: var(--font-pixel);
  font-size: clamp(3rem, 8vw, 5rem);
  letter-spacing: 0.3em;
  color: var(--green-bright);
  line-height: 1;
}

.shell-subtitle {
  margin-top: 0.75rem;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  color: var(--green);
}

.shell-footer {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
  font-size: 0.9375rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-faint);
}

/* ---- Terminal chrome ---- */

.terminal-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.75rem;
  border-bottom: 1px solid rgba(15, 110, 44, 0.5);
  font-size: 0.9375rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-dim);
}

.terminal-body {
  height: clamp(320px, 52vh, 560px);
  overflow-y: auto;
  padding: 0.75rem 1rem;
  font-size: 1.125rem;
  line-height: 1.35;
}

@media (min-width: 640px) { .terminal-body { font-size: 1.25rem; } }

.terminal-line { white-space: pre-wrap; word-wrap: break-word; }
.terminal-line.kind-out { color: var(--green); }
.terminal-line.kind-in { color: var(--green-bright); }
.terminal-line.kind-ok { color: var(--green-bright); }
.terminal-line.kind-warn { color: var(--amber); }
.terminal-line.kind-err { color: var(--red); }
.terminal-line.kind-dim { color: var(--green-faint); }
.terminal-line.kind-accent { color: var(--amber); }

.terminal-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  color: var(--green-bright);
}

.terminal-prompt label { color: var(--green-dim); }

.terminal-prompt input {
  flex: 1;
  min-width: 12ch;
  margin-left: 0.5rem;
  padding: 0;
  color: var(--green-bright);
  caret-color: var(--green-bright);
}

/* ---- CTA Buttons ---- */

.btn-primary {
  border: 1px solid var(--green);
  background: rgba(43, 255, 94, 0.15);
  padding: 0.5rem 1.5rem;
  font-size: 1.125rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-bright);
  transition: background 0.2s;
}
.btn-primary:hover { background: rgba(43, 255, 94, 0.25); }

.btn-secondary {
  border: 1px solid var(--green-dim);
  padding: 0.5rem 1.5rem;
  font-size: 1.125rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
  transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(43, 255, 94, 0.1); }

.btn-sm {
  border: 1px solid var(--green);
  background: rgba(43, 255, 94, 0.1);
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green-bright);
  transition: all 0.2s;
}
.btn-sm:hover { background: var(--green); color: var(--bg); }

.btn-amber {
  border: 1px solid var(--amber);
  background: rgba(255, 176, 0, 0.1);
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  transition: all 0.2s;
}
.btn-amber:hover { background: var(--amber); color: var(--bg); }

/* ---- Auth form ---- */

.auth-input {
  width: 100%;
  border-bottom: 1px solid var(--green-dim);
  padding-bottom: 0.25rem;
  font-size: 18px;
  color: var(--green-bright);
  transition: border-color 0.2s;
}
.auth-input::placeholder { color: rgba(15, 110, 44, 0.6); }
.auth-input:focus { border-color: var(--green); }

.auth-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green-dim);
}

/* ---- Dashboard layout ---- */

.dash-header {
  position: relative;
  z-index: 50;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(15, 110, 44, 0.6);
  background: rgba(4, 11, 4, 0.8);
}

.dash-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 0.75rem;
}

.dash-ticker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0.75rem;
  border-top: 1px solid rgba(15, 110, 44, 0.3);
  font-size: 0.875rem;
}

.dash-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

@media (min-width: 768px) { .dash-body { flex-direction: row; } }

.dash-panels {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem;
}

@media (min-width: 768px) { .dash-panels { overflow: hidden; } }

.dash-sidebar {
  flex-shrink: 0;
  padding: 0.5rem;
  height: 42vh;
}

@media (min-width: 768px) {
  .dash-sidebar { height: auto; width: 340px; }
}

/* Panel grid */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  height: 100%;
}

@media (min-width: 768px) {
  .panel-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}

.panel-span-2 { grid-column: span 1; }
@media (min-width: 768px) { .panel-span-2 { grid-column: span 2; } }

/* ---- Panel widget ---- */

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(15, 110, 44, 0.7);
  background: rgba(4, 11, 4, 0.6);
}

.panel-header {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.125rem 0.5rem;
  background: var(--green-dim);
  color: var(--bg);
}

.panel-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem;
}

.panel-footer {
  flex-shrink: 0;
  padding: 0.5rem;
  border-top: 1px solid rgba(15, 110, 44, 0.3);
}

/* ---- Stat boxes ---- */

.stat-box {
  border: 1px solid rgba(15, 110, 44, 0.4);
  padding: 0.375rem 0.5rem;
}

.stat-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green-dim);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--green-bright);
}

/* ---- Badge ---- */

.badge {
  display: inline-block;
  border: 1px solid;
  padding: 0 0.25rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
}

.badge-amber { border-color: rgba(255,176,0,0.5); color: var(--amber); }
.badge-green { border-color: rgba(43,255,94,0.5); color: var(--green); }
.badge-red { border-color: rgba(255,85,85,0.5); color: var(--red); }
.badge-pro {
  border-color: var(--green);
  background: rgba(43,255,94,0.1);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--green-bright);
}

/* ---- Admin layout ---- */

.admin-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--green);
}

@media (min-width: 1024px) {
  .admin-layout { flex-direction: row; }
}

.admin-sidebar {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid var(--green-faint);
}

@media (min-width: 1024px) {
  .admin-sidebar {
    width: 224px;
    height: 100vh;
    position: sticky;
    top: 0;
    border-bottom: none;
    border-right: 1px solid var(--green-faint);
  }
}

.admin-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* ---- Table ---- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green-dim);
  border-bottom: 1px solid var(--green-faint);
}

.data-table td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid rgba(15, 110, 44, 0.3);
  color: var(--foreground);
}

.data-table tr:hover td { background: rgba(43, 255, 94, 0.03); }

/* ---- Sparkline ---- */

.sparkline {
  display: flex;
  align-items: end;
  gap: 1px;
  height: 24px;
}

.sparkline-bar {
  flex: 1;
  background: var(--green);
  opacity: 0.7;
  min-height: 2px;
}

/* ---- Area chart placeholder ---- */

.area-chart {
  position: relative;
  height: 80px;
  background: linear-gradient(to top, rgba(43,255,94,0.12) 0%, transparent 100%);
  border-bottom: 1px solid var(--green-faint);
  overflow: hidden;
}

.area-chart svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
