:root {
  color-scheme: light;
  --ink: #17213b;
  --muted: #68718a;
  --line: #dfe4ef;
  --line-strong: #c9d1e1;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --navy: #10162b;
  --navy-soft: #1b2544;
  --accent: #3859e8;
  --accent-dark: #2845c7;
  --cyan: #18b7c9;
  --green: #17856b;
  --amber: #ae6a0b;
  --red: #b64054;
  --shadow: 0 18px 48px rgba(24, 37, 67, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #edf1f8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  color: #fff;
  background: rgba(16, 22, 43, 0.98);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -0.01em; }
.brand small { color: #aeb8d4; font-size: 0.78rem; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.status-pill, .mockup-badge, .chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill {
  padding: 7px 10px;
  color: #c7d2ef;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f4b84f; }

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 750;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(56,89,232,0.32); outline-offset: 2px; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line-strong); }
.topbar .button-secondary { color: #fff; background: transparent; border-color: rgba(255,255,255,0.24); }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 76px); }

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  height: calc(100vh - 76px);
  padding: 28px 18px;
  color: #d9e1f5;
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow-y: auto;
}

.sidebar-label {
  padding: 0 12px 9px;
  color: #7f8baa;
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav-list { display: grid; gap: 6px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  color: #aeb8d4;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 680;
  cursor: pointer;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.is-active { color: #fff; background: var(--navy-soft); border-color: rgba(92,120,255,0.28); box-shadow: inset 3px 0 0 #5c78ff; }
.nav-icon { color: #7f8baa; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; }
.nav-item.is-active .nav-icon { color: #8fa5ff; }

.sidebar-note {
  margin-top: 34px;
  padding: 15px;
  color: #aeb8d4;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.sidebar-note strong { color: #fff; font-size: 0.84rem; }
.sidebar-note p { margin: 7px 0 0; font-size: 0.78rem; line-height: 1.5; }

.main-content { min-width: 0; padding: 26px clamp(20px, 4vw, 54px) 48px; }

.notice {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto 28px;
  padding: 12px 16px;
  background: #fff7e8;
  border: 1px solid #f1d29d;
  border-radius: 12px;
  color: #6f4a0e;
}
.notice p { margin: 0; font-size: 0.9rem; }
.notice-label { flex: none; padding: 4px 8px; color: #fff; background: #9a6211; border-radius: 6px; font-size: 0.68rem; font-weight: 850; letter-spacing: 0.08em; }

.panel { max-width: 1280px; margin: 0 auto; }
.panel:not(.is-active) { display: none; }

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: clamp(28px, 5vw, 76px);
  align-items: end;
  margin: 8px 0 32px;
}
.page-heading.compact { align-items: center; }

.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 0.75rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.11em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { max-width: 900px; margin: 0; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1.08; letter-spacing: -0.045em; }
.compact h1 { font-size: clamp(2rem, 3.4vw, 3rem); }
h2 { margin: 0; font-size: 1.28rem; line-height: 1.25; letter-spacing: -0.025em; }
h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.lead { max-width: 920px; margin: 18px 0 0; color: var(--muted); font-size: 1.04rem; }

.project-state {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.project-state span, .project-state strong, .project-state small { display: block; }
.project-state span { color: var(--muted); font-size: 0.75rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; }
.project-state strong { margin: 5px 0 3px; }
.project-state small { color: var(--muted); }

.mockup-badge { justify-self: end; padding: 8px 11px; color: #5b3a08; background: #fff4df; border: 1px solid #f0cf94; font-size: 0.78rem; font-weight: 800; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 8px 28px rgba(24,37,67,0.045); }
.metric-card span, .metric-card strong, .metric-card small { display: block; }
.metric-card span { color: var(--muted); font-size: 0.76rem; font-weight: 760; text-transform: uppercase; letter-spacing: 0.06em; }
.metric-card strong { margin: 7px 0 1px; font-size: 1.22rem; }
.metric-card small { color: var(--muted); }

.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 34px rgba(24,37,67,0.05); }
.card.span-2 { grid-column: span 2; }
.card.span-3 { grid-column: 1 / -1; }
.card > p:not(.eyebrow):not(.card-footnote) { color: var(--muted); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.chip { padding: 5px 9px; color: #304aad; background: #edf1ff; border: 1px solid #d4dcff; font-size: 0.72rem; font-weight: 800; }

.workflow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 8px 0 0; padding: 0; list-style: none; }
.workflow li { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 9px; padding: 4px 12px 4px 0; }
.workflow li:not(:last-child)::after { content: ""; position: absolute; top: 20px; left: 33px; right: 0; height: 1px; background: var(--line-strong); }
.workflow li > span { position: relative; z-index: 1; width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 10px; font-size: 0.78rem; font-weight: 800; }
.workflow strong, .workflow small { display: block; }
.workflow strong { margin-top: 5px; }
.workflow small { margin-top: 7px; color: var(--muted); line-height: 1.45; }

.check-list, .data-list { display: grid; gap: 10px; margin: 18px 0 0; padding: 0; list-style: none; }
.check-list li, .data-list li { position: relative; padding-left: 24px; color: var(--muted); }
.check-list li::before, .data-list li::before { position: absolute; left: 0; top: 0.05em; font-weight: 900; }
.check-list li::before, .data-list.allowed li::before { content: "✓"; color: var(--green); }
.data-list.blocked li::before { content: "×"; color: var(--red); font-size: 1.1rem; }

.function-list { display: grid; gap: 13px; margin-top: 18px; }
.function-list > div { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; padding-top: 13px; border-top: 1px solid var(--line); }
.function-tag { padding: 4px 6px; color: var(--accent); background: #edf1ff; border-radius: 5px; text-align: center; font-size: 0.64rem; font-weight: 850; letter-spacing: 0.06em; }
.function-list p { margin: 0; }
.function-list strong, .function-list small { display: block; }
.function-list small { margin-top: 2px; color: var(--muted); }

.form-layout { grid-template-columns: minmax(0, 1.7fr) minmax(270px, 0.8fr); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label > span { display: block; margin-bottom: 6px; color: #3a435b; font-size: 0.8rem; font-weight: 760; }
label small { display: block; margin-top: 4px; color: var(--muted); font-size: 0.75rem; }
input, select { width: 100%; min-height: 44px; padding: 10px 11px; color: var(--ink); background: #fbfcff; border: 1px solid var(--line-strong); border-radius: 9px; }
input[readonly] { color: #5b647c; background: #f1f4f9; }
.full-row { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.helper-text { color: var(--muted); font-size: 0.78rem; }
.validation-result { margin-top: 18px; padding: 13px 15px; color: #125d4b; background: #ebf8f4; border: 1px solid #b8e5d8; border-radius: 10px; }
.validation-result strong, .validation-result span { display: block; }
.validation-result span { margin-top: 3px; font-size: 0.82rem; }

.control-list { display: grid; gap: 15px; margin: 18px 0 0; padding: 0; list-style: none; }
.control-list li { display: grid; grid-template-columns: 62px 1fr; gap: 10px; }
.control-state { align-self: start; padding: 4px 6px; color: var(--green); background: #ebf8f4; border-radius: 5px; text-align: center; font-size: 0.65rem; font-weight: 850; text-transform: uppercase; }
.control-list strong, .control-list small { display: block; }
.control-list small { margin-top: 3px; color: var(--muted); }

.builder-grid { grid-template-columns: minmax(280px, 0.8fr) repeat(2, minmax(0, 1fr)); }
.stacked-fields { display: grid; gap: 14px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.ad-preview { padding: 20px; background: #fbfcff; border: 1px solid var(--line); border-radius: 12px; }
.ad-label { color: #4f5a71; font-size: 0.78rem; }
.ad-preview h3 { margin-top: 8px; color: #2c50c6; font-size: 1.28rem; }
.ad-preview p { margin: 5px 0 0; color: #414b62; }
.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.asset-grid > div { padding: 12px; background: var(--surface-soft); border-radius: 10px; }
.asset-grid span, .asset-grid strong, .asset-grid small { display: block; }
.asset-grid span { color: var(--muted); font-size: 0.72rem; font-weight: 760; text-transform: uppercase; }
.asset-grid strong { margin: 5px 0 2px; font-size: 0.88rem; }
.asset-grid small { color: var(--muted); }
.validation-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.validation-strip span { padding: 5px 8px; color: var(--green); background: #ecf8f4; border-radius: 7px; font-size: 0.72rem; font-weight: 750; }

.sequence-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.sequence-grid > div { padding: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.sequence-grid span, .sequence-grid strong, .sequence-grid small { display: block; }
.sequence-grid span { color: var(--accent); font-size: 0.7rem; font-weight: 850; }
.sequence-grid strong { margin: 6px 0 3px; }
.sequence-grid small { color: var(--muted); }

.recommendation-list { display: grid; gap: 14px; }
.recommendation { padding: 18px; background: #fbfcff; border: 1px solid var(--line); border-radius: 12px; }
.recommendation-main { display: grid; grid-template-columns: 88px 1fr; gap: 12px; }
.recommendation-main p { margin: 5px 0 0; color: var(--muted); }
.risk-badge { align-self: start; padding: 5px 7px; border-radius: 6px; text-align: center; font-size: 0.7rem; font-weight: 850; }
.risk-badge.low { color: var(--green); background: #eaf8f3; }
.risk-badge.medium { color: var(--amber); background: #fff3df; }
.recommendation dl { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin: 14px 0; }
.recommendation dl div { padding: 9px; background: #f0f3f9; border-radius: 8px; }
.recommendation dt { color: var(--muted); font-size: 0.7rem; font-weight: 760; text-transform: uppercase; }
.recommendation dd { margin: 4px 0 0; font-size: 0.8rem; font-weight: 700; }
.simulation-box { margin-top: 20px; padding: 13px; color: #4c5670; background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: 10px; font-size: 0.82rem; }
.simulation-box.is-success { color: #125d4b; background: #ebf8f4; border-style: solid; border-color: #b8e5d8; }

.table-card { padding-bottom: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); background: var(--surface-soft); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table-status { padding: 4px 7px; color: var(--green); background: #ebf8f4; border-radius: 999px; font-size: 0.7rem; font-weight: 800; }
.table-status.muted { color: #69728a; background: #eef1f6; }
.audit-list { display: grid; gap: 12px; margin-top: 18px; }
.audit-list > div { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.audit-time { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.74rem; font-weight: 750; }
.audit-list p { margin: 0; }
.audit-list strong, .audit-list small { display: block; }
.audit-list small { color: var(--muted); }

.data-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 12px; align-items: center; }
.data-flow > div { min-height: 140px; padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
.flow-number { width: 28px; height: 28px; display: grid; place-items: center; margin-bottom: 12px; color: #fff; background: var(--accent); border-radius: 8px; font-size: 0.75rem; font-weight: 850; }
.data-flow strong, .data-flow small { display: block; }
.data-flow small { margin-top: 4px; color: var(--muted); }
.flow-arrow { color: var(--accent); font-size: 1.2rem; font-weight: 900; }
.card-footnote { margin: 15px 0 0; color: var(--muted); font-size: 0.8rem; }
.security-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.security-grid > div { padding: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.security-grid strong, .security-grid small { display: block; }
.security-grid small { margin-top: 4px; color: var(--muted); }
.reviewer-card { display: flex; align-items: center; justify-content: space-between; gap: 30px; border-left: 5px solid var(--accent); }
.reviewer-card p:last-child { margin-bottom: 0; }
.reviewer-card .button { flex: none; }

footer { max-width: 1280px; display: flex; justify-content: space-between; gap: 20px; margin: 28px auto 0; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line-strong); font-size: 0.78rem; }
footer p { margin: 0; }
footer p + p { margin-top: 4px; }
.footer-links { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 8px 16px; }
.footer-links a { color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

.legal-page { background: #edf1f8; }
.legal-topbar { position: relative; }
.legal-container { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 54px 0 44px; }
.legal-heading { margin-bottom: 28px; }
.legal-heading h1 { max-width: none; font-size: clamp(2.3rem, 6vw, 4rem); }
.legal-meta { margin: 16px 0 0; color: var(--muted); font-size: 0.9rem; }
.legal-content { padding: clamp(22px, 4vw, 42px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.legal-content section + section { margin-top: 34px; padding-top: 30px; border-top: 1px solid var(--line); }
.legal-content h2 { font-size: 1.35rem; }
.legal-content p, .legal-content li { color: #4b556d; }
.legal-content p { margin: 12px 0 0; }
.legal-content ul { margin: 12px 0 0; padding-left: 24px; }
.legal-content li + li { margin-top: 7px; }
.legal-content a { color: var(--accent-dark); font-weight: 700; }
.legal-footer { margin-top: 28px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 380px; padding: 13px 16px; color: #fff; background: var(--navy); border: 1px solid rgba(255,255,255,0.14); border-radius: 11px; box-shadow: 0 18px 48px rgba(0,0,0,0.22); font-size: 0.86rem; }

@media (max-width: 1100px) {
  .workflow { grid-template-columns: 1fr; gap: 9px; }
  .workflow li { grid-template-columns: 34px 1fr; }
  .workflow li:not(:last-child)::after { top: 33px; bottom: -10px; left: 16px; right: auto; width: 1px; height: auto; }
  .content-grid, .builder-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card.span-3 { grid-column: 1 / -1; }
  .sequence-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .security-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .topbar { position: relative; align-items: flex-start; padding: 14px 18px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .status-pill { display: none; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; overflow: visible; }
  .sidebar-label, .sidebar-note { display: none; }
  .nav-list { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { flex: 0 0 auto; width: auto; }
  .main-content { padding: 20px 16px 36px; }
  .page-heading, .page-heading.compact { grid-template-columns: 1fr; align-items: start; gap: 16px; }
  .mockup-badge { justify-self: start; }
  .metric-grid, .metric-grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-layout { grid-template-columns: 1fr; }
  .card.span-2 { grid-column: 1 / -1; }
  .data-flow { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; }
  .reviewer-card { display: block; }
  .reviewer-card .button { margin-top: 16px; }
}

@media (max-width: 580px) {
  .topbar { display: block; }
  .topbar-actions { justify-content: flex-start; margin-top: 12px; }
  .topbar .button { flex: 1; }
  .notice { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 2.1rem; }
  .metric-grid, .metric-grid.three, .content-grid, .builder-grid, .form-grid, .asset-grid, .two-col, .recommendation dl, .sequence-grid, .security-grid { grid-template-columns: 1fr; }
  .card, .metric-card { padding: 17px; }
  .recommendation-main { grid-template-columns: 1fr; }
  .risk-badge { justify-self: start; }
  .form-actions { align-items: stretch; flex-direction: column; }
  footer { flex-direction: column; }
  .footer-links { justify-content: flex-start; }
  .legal-topbar .button { margin-top: 12px; }
  .legal-container { padding-top: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
