@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Plus+Jakarta+Sans:wght@600;700&display=swap');

:root {
  --primary:       #1E3A8A;
  --primary-hover: #1e40af;
  --primary-light: #dbeafe;
  --navy:          #0F172A;
  --navy-800:      #1E293B;
  --navy-700:      #334155;
  --purple:        #6C47FF;
  --purple-light:  #EDE9FF;
  --green:         #16A34A;
  --green-light:   #DCFCE7;
  --red:           #DC2626;
  --red-light:     #FEE2E2;
  --amber:         #D97706;
  --amber-light:   #FEF3C7;
  --bg:            #F9FAFB;
  --grey:          #F8FAFC;
  --grey-200:      #E2E8F0;
  --grey-500:      #64748B;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --white:         #FFFFFF;
  --radius:        8px;
  --radius-lg:     14px;
  --shadow:        0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 16px rgba(15,23,42,0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  line-height: 1.25;
}

a { color: inherit; text-decoration: none; }

p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  cursor: pointer;
  transition: transform 120ms ease, background-color 180ms ease,
              color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

button:active { transform: scale(0.97); }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.container {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.tiny-btn { padding: 6px 10px; font-size: 12px; }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 1px 3px rgba(30,58,138,0.18);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(30,58,138,0.28);
  transform: translateY(-1px);
}

.btn-secondary {
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
}

.btn-secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary-hover);
}

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-pass     { background: var(--green-light);  color: #15803D; }
.badge-fail     { background: var(--red-light);    color: #B91C1C; }
.badge-flag     { background: var(--amber-light);  color: #B45309; }
.badge-risk     { background: var(--red-light);    color: #B91C1C; }
.badge-safe     { background: var(--green-light);  color: #15803D; }
.badge-override { background: #FFF7ED;             color: #C2410C; }

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow);
}

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-wrap { width: 100%; overflow: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead { background: #f1f5f9; }

th, td {
  border-bottom: 1px solid var(--grey-200);
  text-align: left;
  padding: 12px 10px;
  vertical-align: top;
}

th {
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ── Metric cards ────────────────────────────────────────────────────── */

.section-title { margin-bottom: 12px; font-size: 18px; }

.metric-grid { display: grid; gap: 14px; }

.metric-card { padding: 18px; }

.metric-label { color: var(--text-muted); font-size: 13px; font-weight: 500; }

.metric-value {
  margin-top: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Top nav (landing page) ──────────────────────────────────────────── */

.top-nav {
  width: 100%;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-text strong { display: block; font-size: 18px; }
.brand-text span   { font-size: 12px; color: #b1a5ff; }

.nav-links { display: flex; align-items: center; gap: 24px; }

.nav-links a {
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  padding-bottom: 4px;
  transition: color 180ms ease, border-color 180ms ease;
}

.nav-links a:hover {
  color: var(--white);
  border-bottom-color: #93c5fd;
}

/* ── Landing page ────────────────────────────────────────────────────── */

.landing-body {
  min-height: 100vh;
  background: var(--navy);
  color: var(--white);
}

.landing-main { padding: 0 0 72px; }

.live-ticker {
  background: #17233c;
  border-top: 1px solid #293a59;
  border-bottom: 1px solid #293a59;
  overflow: hidden;
  white-space: nowrap;
  color: #c4b5fd;
  font-size: 13px;
}

.live-ticker-track {
  display: inline-block;
  padding: 10px 0;
  animation: tickerMove 36s linear infinite;
}

.hero-block { padding: 48px 0 30px; text-align: center; }

.hero-block h1 {
  color: var(--white);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-block p {
  margin: 18px auto 0;
  color: #cbd5e1;
  max-width: 900px;
  font-size: 20px;
}

.hero-cta-row {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.stats-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  background: var(--white);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card h3 { margin-bottom: 5px; font-size: 30px; color: var(--primary); }

.feature-strip {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid #2d3f5d;
  border-radius: var(--radius-lg);
  padding: 10px;
}

.feature-item {
  border: 1px solid #2e3f5f;
  border-radius: var(--radius);
  background: #182641;
  text-align: center;
  color: #dbeafe;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 6px;
}

.trusted-wrap { margin-top: 20px; text-align: center; }
.trusted-wrap p { color: #b9c8df; margin-bottom: 10px; }

.trusted-badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.trusted-badge {
  background: #dbe3f0;
  color: #334155;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.how-works {
  margin-top: 24px;
  border: 1px solid #2e3f5f;
  border-radius: var(--radius-lg);
  padding: 20px;
}

.how-steps {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.how-step { position: relative; padding-right: 12px; }

.how-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  right: -9px;
  width: 18px;
  height: 1px;
  background: #4b5f82;
}

.how-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 8px;
}

.how-step h4 { color: #e2e8f0; font-size: 14px; margin-bottom: 6px; }
.how-step p  { color: #b9c8df; font-size: 13px; }

/* ── App shell (sidebar pages) ───────────────────────────────────────── */

.site-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-top { display: flex; flex-direction: column; gap: 24px; }

.sidebar .brand-text strong { color: var(--white); font-size: 17px; }
.sidebar .brand-text span   { color: #94a3b8; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.sidebar-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.07);
}

.sidebar-link.is-active {
  color: #93c5fd;
  border-left-color: #3b82f6;
  background: rgba(59,130,246,0.15);
}

.sidebar-link svg { width: 18px; height: 18px; stroke: currentColor; }

.version-tag {
  border-top: 1px solid rgba(148,163,184,0.22);
  color: #94a3b8;
  font-size: 12px;
  padding-top: 14px;
}

.main-content {
  min-height: 100vh;
  background: var(--bg);
  padding: 28px;
}

/* ── Page header ─────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  background: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h1 { font-size: 22px; color: var(--primary); }
.page-title p  { font-size: 14px; }

/* ── Step flow indicator ─────────────────────────────────────────────── */

.step-flow {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 22px;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.step-flow-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.step-flow-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--grey-200);
  background: var(--white);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}

.step-flow-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 200ms ease;
}

.step-flow-arrow {
  margin: 0 14px;
  color: var(--grey-200);
  font-size: 18px;
  flex-shrink: 0;
}

/* Active step */
.step-flow-item.active .step-flow-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step-flow-item.active .step-flow-label {
  color: var(--primary);
  font-weight: 600;
}

/* Completed step */
.step-flow-item.done .step-flow-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.step-flow-item.done .step-flow-label { color: var(--green); }

/* ── Upload loader ────────────────────────────────────────────────────── */

.upload-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}

.upload-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--grey-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.upload-loader-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.upload-loader-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  line-height: 1;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-sub { font-size: 14px; max-width: 320px; }

/* ── Floating badges ─────────────────────────────────────────────────── */

.demo-mode-badge {
  position: fixed;
  top: 12px;
  right: 18px;
  z-index: 45;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.judge-helper-btn {
  position: fixed;
  right: 20px;
  bottom: 44px;
  z-index: 45;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-size: 18px;
  font-weight: 700;
}

.judge-helper-btn:hover { background: var(--primary-hover); }

.judge-helper-popup {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 45;
  width: 260px;
  border: 1px solid var(--grey-200);
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 12px;
  font-size: 13px;
  color: #334155;
}

/* ── Toast ───────────────────────────────────────────────────────────── */

.toast-root {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 280px;
  border: 1px solid var(--grey-200);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 240ms ease;
}

.toast.success { border-color: #86efac; background: #f0fdf4; color: #166534; }
.toast.warn    { border-color: #fcd34d; background: #fffbeb; color: #92400e; }

/* ── Global settings button ─────────────────────────────────────────── */

#settings-btn {
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

#settings-btn:hover {
  background: rgba(30, 41, 59, 0.95);
}

/* ── Modal ───────────────────────────────────────────────────────────── */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 95;
}

.modal .modal-content {
  background: white;
  margin: 10% auto;
  padding: 20px;
  width: 400px;
  border-radius: 8px;
  color: #0f172a;
  position: relative;
}

#settings-close {
  cursor: pointer;
}

dialog.modal-overlay { border: 0; padding: 0; background: rgba(2,6,23,0.82); }

dialog.modal-overlay::backdrop { background: rgba(2,6,23,0.82); }

dialog.modal-overlay[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  position: fixed;
  z-index: 90;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  border: 0;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,0.82);
}

.modal-overlay.show { display: flex; }

.modal-card {
  width: min(1000px, calc(100% - 48px));
  max-height: calc(100vh - 80px);
  border: 1px solid #334155;
  border-radius: 14px;
  overflow: auto;
  position: relative;
  background: #0b1120;
  padding: 20px;
}

.modal-content {
  width: 90vw;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
}

.flowchart-svg { width: 100%; height: auto; min-height: 600px; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #64748b;
  background: transparent;
  color: #cbd5e1;
}

.modal-close:hover { background: rgba(100,116,139,0.2); }

/* ── Global footer hint ──────────────────────────────────────────────── */

.global-footer-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: rgba(15,23,42,0.94);
  color: #cbd5e1;
  text-align: center;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Animations ──────────────────────────────────────────────────────── */

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes tickerMove {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

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

.fade-in { animation: fadeInUp 300ms ease both; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .site-shell { grid-template-columns: 200px 1fr; }
  .hero-block h1 { font-size: 46px; }
  .feature-strip,
  .how-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .site-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    padding: 12px 16px;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .main-content { padding: 16px; }
  .step-flow { padding: 10px 14px; }
  .hero-block h1 { font-size: 34px; }
  .stats-row { grid-template-columns: 1fr; }
  .feature-strip { grid-template-columns: repeat(2, 1fr); }
  .how-steps { grid-template-columns: 1fr 1fr; }
}

/* ── Landing page overrides ──────────────────────────────────────────── */
.landing-body .brand-text strong { color: #ffffff; }
.how-title { color: #e2e8f0; }
