:root {
  --navy: #102a43;
  --blue: #1768e5;
  --blue-dark: #0d55c7;
  --ink: #1b2a3a;
  --muted: #65758b;
  --line: #dce3ec;
  --soft: #f5f8fc;
  --green: #168a5b;
  --red: #c53b46;
  --shadow: 0 20px 50px rgba(16, 42, 67, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #edf2f7; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: radial-gradient(circle at 50% -15%, #fff 0, #f7f9fc 45%, #edf2f7 100%); }
button, input { font: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.shell { width: min(1100px, calc(100% - 36px)); margin: 24px auto; background: #fff; border: 1px solid rgba(208, 218, 230, .9); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.topbar { height: 70px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 750; letter-spacing: -.01em; color: var(--navy); }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; background: var(--navy); color: #fff; }
.brand-mark svg { width: 21px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px; color: #6f7f92; background: transparent; transition: .18s ease; }
.icon-button:hover { background: var(--soft); color: var(--navy); }
.icon-button svg { width: 20px; }
.content { width: min(900px, calc(100% - 64px)); margin: 0 auto; padding: 56px 0 28px; }
.intro { max-width: 680px; margin-bottom: 48px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--blue); text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 800; }
.eyebrow > span { width: 19px; height: 2px; background: var(--blue); border-radius: 3px; }
h1 { margin: 14px 0 12px; color: var(--navy); font-family: Georgia, 'Times New Roman', serif; font-size: clamp(36px, 5vw, 52px); font-weight: 500; letter-spacing: -.035em; line-height: 1.04; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.form-section { display: grid; gap: 26px; }
.section-heading { display: flex; align-items: flex-start; gap: 15px; }
.section-number { flex: none; width: 29px; height: 29px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 50%; font-size: 12px; font-weight: 800; }
.section-heading h2 { margin: 0 0 4px; color: var(--navy); font-size: 18px; letter-spacing: -.01em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field { display: grid; gap: 8px; color: var(--navy); font-size: 13px; font-weight: 700; }
.field input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #cdd7e3; border-radius: 8px; outline: 0; background: #fff; color: var(--ink); font-size: 14px; font-weight: 500; transition: border .18s, box-shadow .18s; }
.field input::placeholder { color: #9aa7b6; }
.field input:hover { border-color: #aebdce; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 104, 229, .12); }
.field.invalid input { border-color: var(--red); box-shadow: 0 0 0 3px rgba(197, 59, 70, .09); }
.field small { min-height: 0; color: var(--muted); font-weight: 500; line-height: 1.4; }
.field small:empty { display: none; }
.field .error { color: var(--red); }
.divider { height: 1px; margin: 38px 0; background: var(--line); }
.tip { display: flex; align-items: flex-start; gap: 13px; padding: 15px 17px; border: 1px solid #dce8f7; border-radius: 9px; background: #f7faff; color: #47627f; }
.tip svg { flex: none; width: 20px; color: var(--blue); }
.tip div { display: grid; gap: 3px; font-size: 12px; line-height: 1.5; }
.tip strong { color: var(--navy); font-size: 12px; }
.form-actions { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.form-actions p { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 11px; }
.form-actions p svg { width: 15px; }
.primary-button, .secondary-button { min-height: 45px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 750; font-size: 13px; transition: .18s ease; }
.primary-button { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(23, 104, 229, .2); }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .65; cursor: wait; transform: none; }
.primary-button svg { width: 17px; }
.primary-button.full { width: 100%; }
.secondary-button { color: var(--navy); background: #fff; border-color: #cdd7e3; }
.secondary-button:hover { background: var(--soft); }
footer { height: 58px; padding: 0 32px; display: flex; align-items: center; justify-content: center; border-top: 1px solid var(--line); color: #8794a3; background: #fbfcfe; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }

dialog { width: min(520px, calc(100% - 28px)); padding: 28px; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 28px 90px rgba(9, 30, 55, .27); }
dialog::backdrop { background: rgba(10, 30, 50, .5); backdrop-filter: blur(3px); }
.success-dialog { max-width: 420px; text-align: center; }
.success-icon { width: 58px; height: 58px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: #eaf8f2; }
.success-icon svg { width: 30px; stroke-width: 2.3; }
.success-dialog h2 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.success-dialog > p { margin: 8px 0 20px; color: var(--muted); font-size: 14px; }
.receipt { margin: 0 0 22px; padding: 14px; border-radius: 9px; background: var(--soft); color: var(--navy); font-size: 12px; line-height: 1.7; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-header h2 { margin: 8px 0 0; color: var(--navy); font-family: Georgia, serif; font-size: 29px; font-weight: 500; }
.settings-copy { margin: 13px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.connection-state { margin-top: 12px; color: var(--muted); font-size: 12px; }
.connection-state.connected { color: var(--green); }
details { margin: 22px 0; border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
summary { cursor: pointer; color: var(--navy); font-size: 13px; font-weight: 750; }
details ol { padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
pre { max-height: 200px; overflow: auto; padding: 13px; border-radius: 7px; color: #d8e7fa; background: #102a43; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.settings-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0; border: 1px solid var(--line); border-radius: 9px; }
.settings-stats div { padding: 14px 16px; display: grid; gap: 2px; }
.settings-stats div + div { border-left: 1px solid var(--line); }
.settings-stats strong { color: var(--navy); font-size: 21px; }
.settings-stats span { color: var(--muted); font-size: 11px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 8px; color: #fff; background: var(--navy); box-shadow: 0 10px 30px rgba(16,42,67,.25); font-size: 12px; opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .shell { width: 100%; min-height: 100vh; margin: 0; border: 0; border-radius: 0; }
  .topbar { padding: 0 20px; }
  .content { width: calc(100% - 40px); padding-top: 38px; }
  .intro { margin-bottom: 38px; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions p { justify-content: center; }
  .primary-button { width: 100%; }
}

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