:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Theme: Light */
  --bg-base: #f8fafc;
  --bg-canvas: #f1f5f9;
  --text-main: #0f172a;
  --text-bright: #020617;
  --text-dim: #64748b;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(226, 232, 240, 0.85);
  --card-hover: rgba(255, 255, 255, 0.98);
  --glass-border: rgba(148, 163, 184, 0.2);
  --glass: rgba(255, 255, 255, 0.65);

  --cyan: #0284c7;
  --cyan-dim: rgba(2, 132, 199, 0.12);
  --mint: #059669;
  --mint-dim: rgba(5, 150, 105, 0.12);
  --amber: #d97706;
  --amber-dim: rgba(217, 119, 6, 0.12);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.12);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.12);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg-base: #090d16;
  --bg-canvas: #040711;
  --text-main: #94a3b8;
  --text-bright: #f1f5f9;
  --text-dim: #64748b;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(30, 41, 59, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass: rgba(15, 23, 42, 0.4);

  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.15);
  --mint: #34d399;
  --mint-dim: rgba(52, 211, 153, 0.15);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.15);
  --purple: #c084fc;
  --purple-dim: rgba(192, 132, 252, 0.15);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.15);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-main);
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.bg-canvas { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 0; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.25; }
.orb1 { width: 500px; height: 500px; background: #0284c7; top: -100px; left: -100px; }
.orb2 { width: 450px; height: 450px; background: #7c3aed; bottom: 10%; right: -50px; }
.orb3 { width: 400px; height: 400px; background: #059669; top: 40%; left: 30%; }

.grid-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-image: linear-gradient(var(--glass-border) 1px, transparent 1px), linear-gradient(90deg, var(--glass-border) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0.3; z-index: 0; pointer-events: none;
}

.main { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.topbar-left { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.ctrl-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.55rem 1rem;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px;
  color: var(--text-bright); font-family: var(--font-mono); font-size: 0.8rem; font-weight: 500;
  text-decoration: none; cursor: pointer; backdrop-filter: blur(12px); box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}
.ctrl-btn:hover { border-color: var(--cyan); color: var(--cyan); transform: translateY(-2px); }
.ctrl-btn.highlight { background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim)); border-color: var(--cyan); font-weight: 600; }
.ctrl-btn.highlight:hover { background: var(--cyan); color: #fff; }
.ctrl-btn svg { width: 16px; height: 16px; }

/* Hero */
.hero { margin-bottom: 2rem; }
.hero-org {
  display: inline-block; font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600;
  color: var(--cyan); background: var(--cyan-dim); border: 1px solid rgba(2, 132, 199, 0.2);
  padding: 0.35rem 0.9rem; border-radius: 100px; margin-bottom: 0.8rem;
}
.hero-unit { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.5rem; }
.hero h1 { font-size: 2.6rem; font-weight: 900; color: var(--text-bright); line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 0.6rem; }
.hero h1 .g { background: linear-gradient(135deg, var(--cyan), var(--purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-family: var(--font-mono); font-size: 0.9rem; color: var(--cyan); font-weight: 500; margin-bottom: 0.8rem; }
.hero-desc { max-width: 840px; font-size: 1rem; color: var(--text-dim); margin-bottom: 1.5rem; }

/* Tabs */
.suite-tabs {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.8rem;
  background: var(--card-bg); padding: 0.5rem; border-radius: 16px; border: 1px solid var(--card-border);
}
.s-tab-btn {
  padding: 0.7rem 1.2rem; background: transparent; border: none; border-radius: 12px;
  font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text-main);
  cursor: pointer; transition: all 0.2s ease;
}
.s-tab-btn:hover { color: var(--cyan); background: var(--glass); }
.s-tab-btn.active { background: var(--cyan); color: #fff; box-shadow: 0 4px 12px var(--cyan-dim); }

.qc-section { display: none; }
.qc-section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.qc-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px;
  padding: 1.8rem; backdrop-filter: blur(20px); box-shadow: var(--shadow-md);
}

.card-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  border-bottom: 1px solid var(--glass-border); padding-bottom: 1.2rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.card-header h2 { font-size: 1.35rem; font-weight: 800; color: var(--text-bright); }
.card-sub { font-size: 0.85rem; color: var(--text-dim); }

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.8rem; }
@media (max-width: 900px) { .grid-2col { grid-template-columns: 1fr; } }

.input-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.rep-inputs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.input-group { display: flex; flex-direction: column; gap: 0.3rem; }
.input-group label { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--text-bright); }
.input-group input, .input-group select {
  padding: 0.65rem 0.85rem; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 10px; color: var(--text-bright); font-family: var(--font-mono); font-size: 0.9rem; outline: none;
}
.input-group input:focus, .input-group select:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim);
}

.summary-box {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px;
  padding: 1.4rem; display: flex; flex-direction: column; gap: 0.8rem;
}
.summary-title {
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  color: var(--cyan); border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem;
}
.summary-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; }
.summary-row strong { font-family: var(--font-mono); font-size: 0.95rem; }

.status-pill {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; padding: 0.25rem 0.6rem;
  border-radius: 100px;
}
.status-pass { background: var(--mint-dim); color: var(--mint); border: 1px solid rgba(5, 150, 105, 0.3); }
.status-fail { background: var(--red-dim); color: var(--red); border: 1px solid rgba(220, 38, 38, 0.3); }

.verdict-banner {
  margin-top: 0.8rem; padding: 1rem; border-radius: 12px; text-align: center;
  background: var(--mint-dim); border: 1px solid rgba(5, 150, 105, 0.3); color: var(--mint);
}
.verdict-banner.fail { background: var(--red-dim); border-color: rgba(220, 38, 38, 0.3); color: var(--red); }
.verdict-title { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; }
.verdict-text { font-size: 0.95rem; font-weight: 800; margin-top: 0.2rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  background: var(--glass); text-align: left; padding: 0.65rem 0.85rem; font-family: var(--font-mono);
  font-size: 0.75rem; text-transform: uppercase; color: var(--text-dim); border-bottom: 1px solid var(--glass-border);
}
.data-table td { padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--glass-border); font-family: var(--font-mono); }
.tbl-input {
  width: 100%; padding: 0.4rem 0.6rem; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 6px; color: var(--text-bright); font-family: var(--font-mono); font-size: 0.85rem; outline: none;
}

/* Control Chart View */
.chart-container-box {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; padding: 1.5rem;
}
.chart-canvas-wrap { width: 100%; height: 320px; }
.qc-svg { width: 100%; height: 100%; }
.chart-legend {
  display: flex; gap: 1.5rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim);
}
.leg-item { display: flex; align-items: center; gap: 0.4rem; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; }

.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }

.footer {
  margin-top: 4rem; text-align: center; font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--text-dim); padding: 2rem; border-top: 1px solid var(--glass-border);
}
