/* B2B Tool Studio — Design System v2 (WCAG AA contrast, responsive 390/768/1280/1440, mobile 44px targets) */
:root {
  --bg: #070b14;
  --surface: #0f1626;
  --surface-alt: #162036;
  --border: #24324d;
  --text: #f1f5f9;
  --muted: #9fb0cc;
  --accent: #38bdf8;
  --accent-strong: #0369a1;
  --accent-2: #4338ca;
  --gold: #f59e0b;
  --ok: #22c55e;
  --danger: #ef4444;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.09), transparent 45%), var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: clip;
}
main { flex: 1; width: 100%; }

a {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
a:hover { text-decoration: underline; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Sticky Header & Collapsible Mobile Nav */
header {
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.94);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 8px 0;
  position: relative;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.04rem;
  color: var(--text);
  letter-spacing: -0.02em;
  min-height: 44px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
.nav-links a {
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 6px;
  min-height: 36px;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

/* Typography & Hero */
.hero { padding: 48px 0 28px; }
.hero h1 { font-size: clamp(1.9rem, 3.8vw, 2.85rem); line-height: 1.12; margin: 12px 0 14px; letter-spacing: -0.03em; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 720px; margin: 0 0 22px; }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.65rem); letter-spacing: -0.02em; margin: 28px 0 14px; }
h3 { font-size: 1.1rem; margin: 0 0 6px; }

/* Split-pane Hero Playground */
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.15fr);
  gap: 28px;
  align-items: start;
  padding: 40px 0 28px;
}
.hero-split > * { min-width: 0; }
.playground {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.pg-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.pg-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-tab {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.pg-tab.active, .pg-tab:hover {
  color: #fff;
  background: rgba(67, 56, 202, 0.35);
  border-color: rgba(99, 102, 241, 0.6);
}
.pg-body { padding: 14px; }
.pg-latency { font-size: 0.78rem; color: #86efac; font-family: var(--mono); }
.pg-preview {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #060911;
  padding: 10px 12px;
  font-size: 0.82rem;
}
.pg-row {
  padding: 8px 0;
  border-bottom: 1px solid rgba(36, 50, 77, 0.6);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.pg-row:last-child { border-bottom: 0; }

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.badge-gold { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }
.badge-ok { background: rgba(34, 197, 94, 0.16); color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.badge-danger, .badge-breaking { background: rgba(239, 68, 68, 0.18); color: #fecaca; border-color: rgba(239, 68, 68, 0.5); }
.badge-warn { background: rgba(245, 158, 11, 0.18); color: #fde68a; border-color: rgba(245, 158, 11, 0.5); }

/* Stage & Severity Pills (Dark-mode accessible) */
.stage-pill, .tier-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.stage-FINAL_PERIOD { background: rgba(34, 197, 94, 0.18); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.4); }
.stage-BRIDGED, .tier-HIGH { background: rgba(245, 158, 11, 0.18); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.45); }
.stage-VEHICLE_SUNSET, .tier-MEDIUM { background: rgba(99, 102, 241, 0.22); color: #c7d2fe; border: 1px solid rgba(99, 102, 241, 0.5); }
.stage-OPTION_DECISION, .tier-LOW { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.35); }
.stage-TOO_LATE, .tier-CRITICAL { background: rgba(239, 68, 68, 0.2); color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.5); }

/* Buttons (WCAG AA >= 4.5:1) */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.93rem;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.25;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, #4338ca, #0369a1);
  border-color: rgba(125, 211, 252, 0.35);
  color: #ffffff;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger {
  background: #991b1b;
  border-color: #ef4444;
  color: #ffffff;
}
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.84rem; border-radius: 6px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Grids & Cards (min-width: 0 prevents grid overflow) */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin: 20px 0 36px; }
.grid > *, .two-col > *, .form-row > *, .kpi-grid > * { min-width: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.card h3 { margin: 0; font-size: 1.12rem; }
.muted { color: var(--muted); font-size: 0.94rem; margin: 0; }
.icon-row { display: flex; align-items: center; gap: 12px; }
.icon-row img { width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin: 20px 0;
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
label { display: block; font-size: 0.84rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #080d18;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
}
input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  accent-color: var(--accent);
}
textarea { min-height: 200px; resize: vertical; }
textarea, pre, code { font-family: var(--mono); }
code { word-break: break-word; }
pre {
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  max-width: 100%;
  overflow-x: auto;
  font-size: 0.84rem;
  color: #dbeafe;
  margin: 10px 0;
}

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--surface-alt); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi-card { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.kpi-val { font-size: 1.4rem; font-weight: 700; line-height: 1.15; }
.kpi-lbl { font-size: 0.78rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.two-col textarea { min-height: 240px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.quota-pill { font-size: 0.84rem; color: var(--muted); }
ul.clean { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }

details { margin-top: 12px; }
details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 4px 6px;
}

.alert-banner { padding: 14px 16px; border-radius: 10px; margin: 14px 0; font-size: 0.94rem; }
.alert-danger { background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.5); color: #fecaca; }
.alert-ok { background: rgba(34, 197, 94, 0.14); border: 1px solid rgba(34, 197, 94, 0.5); color: #bbf7d0; }
.upgrade-card {
  background: linear-gradient(135deg, rgba(67, 56, 202, 0.22), rgba(3, 105, 161, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 18px;
  margin: 14px 0;
}
.upgrade-card h3 { margin: 0 0 6px; font-size: 1.08rem; }

/* Mobile Card Variants for Flagships */
.recompete-cards, .sec-cards { display: none; }
.rc-card, .sec-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-alt);
  color: var(--text);
}
.rc-card-head, .sec-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.rc-meta, .sec-meta { font-size: 0.86rem; color: var(--muted); margin: 3px 0; }
.why-list { margin: 6px 0 0 18px; font-size: 0.86rem; color: var(--muted); }
.meta-strip { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 0.88rem; color: var(--muted); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 48px;
  color: var(--muted);
  font-size: 0.88rem;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
}
footer a {
  padding: 4px 6px;
  min-height: 32px;
}

/* Tablet Breakpoint */
@media (max-width: 960px) {
  .hero-split { grid-template-columns: 1fr; padding: 28px 0 20px; }
}

/* Mobile Breakpoint (<= 640px): sticky <=64px header, 44px tap targets everywhere, card lists */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .nav { min-height: 58px; padding: 6px 0; flex-wrap: nowrap; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: -16px;
    right: -16px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 16px 14px;
    background: rgba(7, 11, 20, 0.98);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55);
  }
  .nav.nav-open .nav-links { display: flex; }
  .nav-links a {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 12px;
    width: 100%;
  }

  /* Enforce >= 44x44px touch targets across main, header, nav, footer on mobile */
  main a, main button, main summary, footer a, header a, header button, .pg-tab, .btn-sm {
    min-height: 44px;
    min-width: 44px;
  }
  footer a { padding: 10px 8px; }
  main a:not(.btn) { padding: 8px 4px; }
  details summary { padding: 10px 6px; }
  input[type="checkbox"] { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }

  .hero { padding: 28px 0 18px; }
  .panel { padding: 16px; }
  .card { padding: 16px; }
  .recompete-table-wrap, .sec-table-wrap { display: none; }
  .recompete-cards, .sec-cards { display: grid; gap: 12px; }
}
