:root {
  color-scheme: light;
  --ink: #17223b;
  --muted: #68738a;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --line: #dce3e4;
  --green: #0b7a62;
  --green-dark: #075f4d;
  --green-soft: #e8f5f1;
  --amber: #a75a09;
  --amber-soft: #fff4df;
  --red: #b33a3a;
  --red-soft: #fff0f0;
  --shadow: 0 18px 50px rgba(23, 34, 59, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 0%, rgba(11, 122, 98, 0.09), transparent 30rem),
    var(--canvas);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(11, 122, 98, 0.25);
  outline-offset: 3px;
}

.shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 28px; }
.topbar { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 26px; }
.brand-mark {
  display: grid; place-items: center; flex: 0 0 52px; height: 52px; border-radius: 16px;
  background: var(--ink); color: white; font-size: 13px; font-weight: 800; letter-spacing: -0.04em;
  box-shadow: 0 10px 28px rgba(23, 34, 59, 0.18);
}
.eyebrow, .step-label { margin: 0 0 5px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 21px; line-height: 1.25; letter-spacing: -0.02em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }

.ca-reminder {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 18px 20px; border: 1px solid #efd39e; border-radius: 18px; background: var(--amber-soft); margin-bottom: 22px;
}
.ca-reminder h2 { color: #7b4307; font-size: 17px; }
.ca-reminder p { margin: 4px 0 0; color: #6f573a; line-height: 1.45; }
.reminder-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #e8a536; color: white; font-weight: 900; }

.workflow-switch {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  width: min(680px, 100%); margin: 0 0 14px; padding: 5px; border: 1px solid var(--line);
  border-radius: 17px; background: rgba(255,255,255,.68);
}
.workflow-tab {
  display: grid; grid-template-columns: 34px 1fr; gap: 11px; align-items: center; min-width: 0;
  padding: 11px 14px; border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  text-align: left; cursor: pointer;
}
.workflow-tab:hover:not(:disabled) { background: rgba(255,255,255,.75); color: var(--ink); }
.workflow-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 5px 16px rgba(23,34,59,.09); }
.workflow-tab:disabled { cursor: wait; opacity: .7; }
.workflow-tab-number {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: #edf1f2; color: var(--muted); font-size: 14px; font-weight: 850;
}
.workflow-tab.is-active .workflow-tab-number { background: var(--green-soft); color: var(--green-dark); }
.workflow-tab strong, .workflow-tab small { display: block; }
.workflow-tab strong { font-size: 14px; }
.workflow-tab small { margin-top: 2px; color: inherit; font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .8fr); gap: 22px; align-items: start; }
.main-panel, .progress-panel { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.main-panel { padding: 28px; }
.progress-panel { padding: 24px; position: sticky; top: 18px; }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 20px; }
.section-heading.compact { margin-bottom: 16px; }

.connection-state { display: flex; align-items: center; gap: 9px; padding: 11px 13px; margin-bottom: 18px; border-radius: 12px; background: #f2f4f7; color: var(--muted); font-size: 14px; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.connection-state.loading .state-dot { animation: pulse 1.2s ease-in-out infinite; }
.connection-state.ready { background: var(--green-soft); color: var(--green-dark); }
.connection-state.error { background: var(--red-soft); color: var(--red); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

.field-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 750; }
select, input, textarea {
  width: 100%; border: 1px solid #cbd5d7; border-radius: 12px; background: white; color: var(--ink); padding: 12px 13px;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(11, 122, 98, .1); outline: none; }
select:disabled, input:disabled { background: #f5f6f7; color: #8a93a4; }
input[aria-invalid="true"] { border-color: var(--red); background: #fffafa; }

.test-data-notice {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: -4px 0 18px; padding: 13px 15px;
  border: 1px solid #f0d8ad; border-radius: 13px; background: #fffaf0; color: #71502d;
}
.test-data-notice strong { font-size: 13px; }
.test-data-notice strong::before { content: "!"; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 50%; background: #e8a536; color: white; font-size: 11px; }
.test-data-notice p { grid-column: 2; margin: -1px 0 0; font-size: 12px; line-height: 1.5; }

.profile-selector {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px;
  min-width: 0; margin: 0 0 23px; padding: 0; border: 0;
}
.profile-option { position: relative; min-width: 0; cursor: pointer; }
.profile-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.profile-option > span {
  display: block; min-height: 72px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px;
  background: #fafbfb; transition: border-color .15s, background .15s, box-shadow .15s;
}
.profile-option:hover > span { border-color: #a9c9c1; }
.profile-option.is-selected > span { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 3px rgba(11,122,98,.08); }
.profile-option input:focus-visible + span { outline: 3px solid rgba(11,122,98,.25); outline-offset: 3px; }
.profile-option strong, .profile-option small { display: block; }
.profile-option strong { font-size: 16px; }
.profile-option small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.3; }

.form-section { padding: 20px 0; border-top: 1px solid var(--line); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-heading { display: grid; grid-template-columns: 34px 1fr; gap: 11px; align-items: start; margin-bottom: 15px; }
.form-section-heading h3, .subject-preview h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.form-section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.section-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: #f0f3f4; color: var(--green-dark); font-size: 11px; font-weight: 850;
}
.identifier-validation-option {
  display: flex; gap: 10px; align-items: flex-start; margin: -2px 0 15px; padding: 11px 13px;
  border: 1px solid #d8e4e1; border-radius: 12px; background: #f8fbfa; cursor: pointer;
}
.identifier-validation-option input {
  width: 17px; height: 17px; margin: 1px 0 0; padding: 0; flex: none; accent-color: var(--green);
}
.identifier-validation-option strong, .identifier-validation-option small { display: block; }
.identifier-validation-option strong { font-size: 12px; }
.identifier-validation-option small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-field { min-width: 0; }
.form-field.full-width { grid-column: 1 / -1; }
.form-field > label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 12px; font-weight: 750; }
.form-field > label > span:not(.optional) { color: var(--red); }
.optional { color: var(--muted); font-size: 10px; font-weight: 500; }
.field-note, .field-error { margin: 6px 1px 0; font-size: 10px; line-height: 1.4; }
.field-note { min-height: 14px; color: var(--muted); }
.field-error { min-height: 14px; color: var(--red); font-weight: 650; }
.number-parts b { display: inline-block; min-width: 17px; padding: 1px 4px; border-radius: 5px; background: #eef2f3; color: var(--ink); text-align: center; }

.optional-fields { margin: 0 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.optional-fields summary { cursor: pointer; padding: 14px 0; font-size: 13px; font-weight: 750; }
.optional-fields summary span { color: var(--muted); font-weight: 500; }
.optional-fields-grid { padding-bottom: 16px; }

.subject-preview { margin: 4px 0 20px; padding: 17px; border: 1px solid #cfe2dc; border-radius: 15px; background: #f9fcfb; }
.subject-preview > div:first-child { margin-bottom: 14px; }
.subject-preview dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.subject-preview details { margin-top: 15px; padding-top: 12px; border-top: 1px solid #dcece7; }
.subject-preview summary { cursor: pointer; color: var(--green-dark); font-size: 11px; font-weight: 750; }
.subject-preview code { display: block; margin-top: 9px; padding: 10px; border-radius: 9px; background: #eef5f2; color: #315047; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.certificate-card { margin: 16px 0; padding: 18px; border: 1px solid #cfe2dc; border-radius: 16px; background: #f9fcfb; }
.certificate-card.is-empty { color: var(--muted); border-style: dashed; background: #fafbfb; }
.certificate-card.is-empty p, .certificate-card.is-empty { margin-bottom: 0; }
.certificate-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.certificate-heading strong { min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.status-badge { flex: none; padding: 5px 9px; border-radius: 999px; background: #eef1f4; color: #596579; font-size: 11px; font-weight: 800; }
.status-badge.expired { background: var(--red-soft); color: var(--red); }
.status-badge.warning { background: var(--amber-soft); color: var(--amber); }
.status-badge.valid { background: var(--green-soft); color: var(--green-dark); }
dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
dl div { min-width: 0; }
dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
dd { margin: 4px 0 0; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }

.pin-settings { margin: 14px 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pin-settings summary { cursor: pointer; padding: 13px 0; font-size: 14px; font-weight: 720; }
.pin-settings summary span { color: var(--muted); font-weight: 500; }
.pin-content { padding: 0 0 14px; }
.pin-content p, .duration-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.primary-button, .secondary-button, .text-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; cursor: pointer; text-decoration: none; font-weight: 750;
}
.primary-button { width: 100%; min-height: 49px; padding: 12px 18px; border-radius: 13px; background: var(--green); color: white; box-shadow: 0 10px 24px rgba(11, 122, 98, .2); }
.primary-button:hover:not(:disabled) { background: var(--green-dark); }
.primary-button:disabled { cursor: not-allowed; background: #abb7b5; box-shadow: none; }
.secondary-button { min-height: 40px; padding: 9px 13px; border: 1px solid rgba(23,34,59,.14); border-radius: 11px; background: rgba(255,255,255,.72); color: var(--ink); font-size: 13px; }
.secondary-button:hover { background: white; }
.text-button { padding: 5px 0; background: transparent; color: var(--green-dark); font-size: 13px; }
.text-button:hover { text-decoration: underline; }

.progress-list { display: grid; gap: 2px; padding: 0; margin: 0; list-style: none; }
.progress-list li { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 11px; min-height: 60px; color: #8a93a4; }
.progress-list li:not(:last-child)::after { content: ""; position: absolute; left: 15px; top: 34px; width: 2px; height: 27px; background: var(--line); }
.progress-list li > span { display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--line); border-radius: 50%; background: white; font-size: 12px; font-weight: 800; }
.progress-list strong, .progress-list small { display: block; }
.progress-list strong { color: var(--ink); font-size: 14px; }
.progress-list small { margin-top: 3px; font-size: 12px; line-height: 1.35; }
.progress-list li.active > span { border-color: var(--green); color: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.progress-list li.done > span { border-color: var(--green); background: var(--green); color: white; }
.progress-list li.failed > span { border-color: var(--red); background: var(--red); color: white; }

.result-message { margin-top: 6px; padding: 13px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.result-message.idle { background: #f2f4f7; color: var(--muted); }
.result-message.working { background: #eef5fa; color: #2c5b7d; }
.result-message.success { background: var(--green-soft); color: var(--green-dark); }
.result-message.error { background: var(--red-soft); color: #8d2727; }
.recovery-actions { display: grid; gap: 12px; margin-top: 12px; }
.recovery-actions details { border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.recovery-actions summary { cursor: pointer; font-size: 13px; font-weight: 750; }
.recovery-actions p { color: var(--muted); margin: 9px 0; font-size: 12px; line-height: 1.45; }
.recovery-actions textarea { min-height: 100px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.fallback-buttons { display: flex; justify-content: space-between; gap: 14px; margin-top: 8px; }
footer { padding: 20px 4px 0; color: var(--muted); font-size: 12px; text-align: center; }
footer p { margin-bottom: 0; }

[hidden] { display: none !important; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .progress-panel { position: static; }
  .ca-reminder { grid-template-columns: auto 1fr; }
  .ca-reminder .secondary-button { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 24px; }
  .brand-mark { flex-basis: 44px; height: 44px; border-radius: 13px; }
  .main-panel, .progress-panel { padding: 19px; border-radius: 17px; }
  .ca-reminder { padding: 15px; }
  dl { grid-template-columns: 1fr; }
  .certificate-heading { align-items: flex-start; flex-direction: column; }
  .fallback-buttons { align-items: flex-start; flex-direction: column; }
  .workflow-switch { width: 100%; }
  .workflow-tab { grid-template-columns: 28px 1fr; padding: 9px; }
  .workflow-tab-number { width: 28px; height: 28px; }
  .profile-selector, .form-grid.two-columns, .form-grid.three-columns, .subject-preview dl { grid-template-columns: 1fr; }
  .profile-option > span { min-height: 0; }
  .test-data-notice { grid-template-columns: 1fr; }
  .test-data-notice p { grid-column: 1; }
}
