:root {
  --primary: #087fb8;
  --primary-hover: #066d9f;
  --primary-deep: #075779;
  --primary-soft: #edf8fc;
  --page: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #dfe8ed;
  --line-strong: #c8d8e1;
  --text: #18394d;
  --text-strong: #0d4667;
  --muted: #6f8593;
  --muted-2: #8ca0ab;
  --success: #167a4f;
  --warning: #8a6713;
  --danger: #b63d3d;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-panel: 0 12px 32px rgba(26, 69, 93, .075);
  --shadow-hover: 0 10px 24px rgba(26, 69, 93, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(229, 240, 246, .48) 0, rgba(244, 247, 249, 0) 250px),
    var(--page);
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.container { width: min(1240px, calc(100% - 48px)); margin-inline: auto; }

/* Header */
.site-header {
  position: relative;
  color: #fff;
  background: #087fb8;
  border-bottom: 1px solid rgba(0, 72, 108, .12);
  box-shadow: 0 4px 16px rgba(8, 82, 122, .10);
  overflow: hidden;
}
.site-header::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -95px;
  width: 370px;
  height: 250px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  pointer-events: none;
}
.header-inner {
  min-height: 96px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 21px;
  padding-block: 12px;
  position: relative;
  z-index: 1;
}
.brand-logo { width: 68px; height: 68px; object-fit: contain; }
.youth-logo { width: 61px; height: 61px; object-fit: contain; }
.brand-copy { min-width: 0; }
.brand-copy h1 {
  margin: 0;
  font-size: clamp(23px, 2.15vw, 30px);
  line-height: 1.08;
  letter-spacing: -.015em;
  font-weight: 750;
}
.brand-copy p {
  margin: 6px 0 0;
  font-size: clamp(12.5px, 1.25vw, 15px);
  line-height: 1.35;
  font-style: italic;
  opacity: .92;
}

/* Main panel */
.page-shell { padding: 0 0 42px; }
.control-panel {
  position: relative;
  margin-top: 24px;
  padding: 25px 26px 22px;
  background: rgba(255,255,255,.98);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.panel-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 0 0 19px;
  border-bottom: 1px solid #e8eef2;
}
.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: #6c8290;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .145em;
}
.panel-intro h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(22px, 2vw, 27px);
  line-height: 1.16;
  letter-spacing: -.012em;
  font-weight: 750;
}
.intro-note {
  margin: 0 0 2px;
  max-width: 470px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

/* Customer lookup */
.lookup-row {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 20px 0 19px;
}
.input-label {
  display: block;
  margin: 0 0 7px;
  color: #36566a;
  font-size: 12.5px;
  font-weight: 700;
}
.lookup-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 11px;
  align-items: stretch;
}
.input-wrap { position: relative; display: block; min-width: 0; }
.input-wrap svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #6f8796;
  font-size: 19px;
  pointer-events: none;
}
.input-wrap input {
  width: 100%;
  height: 52px;
  padding: 0 16px 0 47px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: none;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  letter-spacing: .018em;
  box-shadow: inset 0 1px 0 rgba(17, 68, 94, .02);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.input-wrap input::placeholder { color: #91a2ad; }
.input-wrap input:hover { border-color: #b9ccd7; }
.input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(8, 127, 184, .10);
}
.input-wrap input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(182, 61, 61, .08);
}
.input-help {
  min-height: 17px;
  display: block;
  margin-top: 6px;
  color: #748a98;
  font-size: 11.5px;
  line-height: 1.35;
}
.primary-action {
  height: 52px;
  min-width: 190px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 21px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-size: 13.5px;
  font-weight: 720;
  letter-spacing: -.005em;
  cursor: pointer;
  box-shadow: 0 7px 16px rgba(8, 127, 184, .18);
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.primary-action svg { font-size: 18px; }
.primary-action:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 9px 20px rgba(8, 127, 184, .22);
  transform: translateY(-1px);
}
.primary-action:active { transform: translateY(0); }
.primary-action:focus-visible,
.survey-type:focus-visible,
.frame-button:focus-visible,
.iframe-slow-hint button:focus-visible {
  outline: 3px solid rgba(8, 127, 184, .20);
  outline-offset: 2px;
}
.primary-action:disabled { opacity: .58; cursor: wait; box-shadow: none; transform: none; }

/* Survey type selector */
.survey-types {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.survey-type {
  position: relative;
  min-height: 72px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 19px;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfd;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.survey-type:hover {
  transform: translateY(-1px);
  border-color: #bfd2dc;
  background: #fff;
  box-shadow: var(--shadow-hover);
}
.survey-type.active {
  border-color: #9fcede;
  background: var(--primary-soft);
  box-shadow: 0 6px 16px rgba(25, 104, 141, .07);
}
.type-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #eaf4f8;
  color: var(--primary);
  font-size: 21px;
  transition: background .16s ease, color .16s ease;
}
.survey-type.active .type-icon { background: var(--primary); color: #fff; }
.type-copy { min-width: 0; display: grid; align-content: center; gap: 3px; }
.type-title { font-size: 13.5px; font-weight: 740; line-height: 1.18; }
.type-sub { color: var(--muted); font-size: 11.25px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-check {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid #ccdce5;
  border-radius: 50%;
  color: transparent;
  font-size: 12px;
  background: #fff;
  transition: all .16s ease;
}
.survey-type.active .type-check { border-color: var(--primary); background: var(--primary); color: #fff; }
.loading-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  overflow: hidden;
  opacity: 0;
}
.loading-bar::after {
  content: "";
  display: block;
  width: 32%;
  height: 100%;
  background: var(--primary);
  transform: translateX(-110%);
}
.loading-bar.show { opacity: 1; }
.loading-bar.show::after { animation: loading 1s ease-in-out infinite; }
@keyframes loading { to { transform: translateX(325%); } }

/* Survey content */
.survey-section { padding-top: 23px; }
.section-heading {
  min-height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  padding-inline: 2px;
}
.section-heading h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(20px, 1.75vw, 24px);
  line-height: 1.18;
  letter-spacing: -.01em;
  font-weight: 750;
}
.status-chip {
  margin-bottom: 2px;
  padding: 6px 10px;
  border: 1px solid #c9e4d5;
  border-radius: 999px;
  background: #f0f8f4;
  color: var(--success);
  font-size: 11.25px;
  font-weight: 740;
}
.status-chip.loading { border-color: #c7dfeb; background: #eef7fb; color: var(--primary-deep); }
.status-chip.warning { border-color: #ead9ad; background: #fff9ea; color: var(--warning); }
.result {
  min-height: 342px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}
.empty-state {
  min-height: 342px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 38px;
  text-align: center;
}
.empty-visual {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 17px;
  border-radius: 18px;
  background: #eef7fb;
  color: var(--primary);
  font-size: 28px;
}
.empty-ring { position: absolute; inset: -6px; border: 1px solid #deebf1; border-radius: 23px; }
.empty-state h3 { margin: 0 0 7px; color: #24495e; font-size: 17px; font-weight: 720; }
.empty-state p { max-width: 520px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.loading-state {
  min-height: 342px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 13px;
  color: #587485;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #d8e5eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .72s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state {
  min-height: 318px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 34px;
  text-align: center;
}
.error-state h3 { margin: 0 0 8px; color: #9f3535; font-size: 17px; }
.error-state p { margin: 0; max-width: 560px; color: var(--muted); line-height: 1.55; font-size: 13px; }

/* Iframe workspace */
.iframe-toolbar {
  position: relative;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 15px;
  border-bottom: 1px solid #e4ebef;
  background: #f8fafb;
}
.frame-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #3a5c70;
  font-size: 12.25px;
  font-weight: 700;
}
.frame-title svg { flex: 0 0 auto; color: var(--primary); font-size: 18px; }
.frame-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-actions { display: flex; gap: 6px; }
.frame-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid #cbd9e1;
  border-radius: 8px;
  background: #fff;
  color: #3b6074;
  font-size: 11.5px;
  font-weight: 680;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.frame-button:hover { background: #f0f6f9; border-color: #aac5d3; color: var(--primary-deep); }
.frame-button svg { font-size: 15px; }
.iframe-stage {
  position: relative;
  min-height: 620px;
  background: #fff;
}
.iframe-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  color: #587485;
  background: #fff;
  transition: opacity .18s ease, visibility .18s ease;
}
.iframe-loading strong { color: #24495e; font-size: 15px; }
.iframe-loading > span { color: var(--muted); font-size: 12.5px; }
.iframe-slow-hint {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #7b6a38;
  font-size: 12px;
}
.iframe-slow-hint[hidden] { display: none; }
.iframe-slow-hint button {
  padding: 6px 10px;
  border: 1px solid #c7d9e3;
  border-radius: 8px;
  background: #fff;
  color: var(--primary-deep);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.iframe-stage.loaded .iframe-loading { opacity: 0; visibility: hidden; pointer-events: none; }
.survey-frame {
  width: 100%;
  height: max(620px, min(78vh, 900px));
  min-height: 620px;
  display: block;
  border: 0;
  background: #fff;
  opacity: 0;
  transition: opacity .18s ease;
}
.iframe-stage.loaded .survey-frame { opacity: 1; }
.iframe-stage:fullscreen .survey-frame { height: 100vh; min-height: 100vh; }
.iframe-stage:fullscreen { background: #fff; }

/* Toasts */
.toast-wrap {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  z-index: 9999;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  width: min(360px, calc(100vw - 28px));
  padding: 11px 13px;
  border-radius: 10px;
  color: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
  font-size: 13px;
  line-height: 1.4;
  animation: toast-in .18s ease;
}
.toast.info { background: #286f98; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* Responsive */
@media (max-width: 960px) {
  .container { width: min(100% - 30px, 1240px); }
  .survey-types { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .intro-note { max-width: 360px; }
}

@media (max-width: 720px) {
  .header-inner { min-height: 88px; gap: 12px; padding-block: 10px; }
  .brand-logo { width: 60px; height: 60px; }
  .youth-logo { width: 52px; height: 52px; }
  .brand-copy h1 { font-size: clamp(17px, 4.5vw, 22px); }
  .brand-copy p { margin-top: 4px; font-size: 11.5px; }
  .control-panel { margin-top: 15px; padding: 20px 17px 17px; border-radius: 15px; }
  .panel-intro { display: block; padding-bottom: 15px; }
  .intro-note { margin-top: 7px; max-width: none; text-align: left; }
  .lookup-row { padding-block: 16px; }
  .lookup-controls { grid-template-columns: 1fr; gap: 9px; }
  .primary-action { width: 100%; min-width: 0; }
  .survey-section { padding-top: 18px; }
  .result, .empty-state, .loading-state { min-height: 330px; }
  .iframe-toolbar { align-items: flex-start; }
  .frame-title { padding-top: 7px; }
  .frame-button .button-label { display: none; }
  .iframe-stage { min-height: 560px; }
  .survey-frame { min-height: 560px; height: 72vh; height: 72dvh; }
}

@media (max-width: 520px) {
  .container { width: min(100% - 20px, 1240px); }
  .site-header::after { display: none; }
  .header-inner { grid-template-columns: auto 1fr; }
  .youth-logo { display: none; }
  .brand-logo { width: 54px; height: 54px; }
  .brand-copy h1 { font-size: 16px; }
  .brand-copy p { font-size: 10.75px; line-height: 1.35; }
  .panel-intro h2 { font-size: 20px; }
  .survey-types { grid-template-columns: 1fr 1fr; gap: 7px; }
  .survey-type { min-height: 68px; grid-template-columns: 36px minmax(0,1fr); gap: 9px; padding: 9px 10px; }
  .type-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 19px; }
  .type-check { display: none; }
  .type-title { font-size: 12.5px; }
  .type-sub { font-size: 10.5px; }
  .section-heading { align-items: center; min-height: 43px; }
  .status-chip { display: none; }
  .empty-state { padding: 28px 20px; }
  .iframe-stage { min-height: 520px; }
  .survey-frame { min-height: 520px; height: 70vh; height: 70dvh; }
}

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