:root {
  --ink: #1f2d3d;
  --deep: #255e72;
  --text: #243239;
  --muted: #6b7a85;
  --line: #d8e2e7;
  --canvas: #f5f8f9;
  --surface: #ffffff;
  --cyan: #2e7d8c;
  --sky: #8fd6e2;
  --lime: #a8cc22;
  --green: #789d13;
  --green-ink: #4e6a0b;
  --warning: #9b7200;
  --radius: 12px;
  color-scheme: light;
  font-family: Inter, Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--text); background: var(--canvas); font-size: 16px; line-height: 1.5; }
h1, h2, h3, legend { font-family: Montserrat, Inter, Arial, ui-sans-serif, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, fieldset:disabled button { cursor: not-allowed; opacity: .58; }
a { color: inherit; }
pre { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(143, 214, 226, .34);
}

.auth-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ink) 0, var(--ink) 350px, var(--canvas) 350px, var(--canvas) 100%);
}

.auth-page main {
  width: min(100% - 32px, 520px);
  margin: 8vh auto;
}

.auth-page main > form,
.auth-card,
.auth-page main > .panel {
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(31, 45, 61, .15);
}

.auth-hero { margin-bottom: 18px; color: #fff; }
.auth-brand { margin: 0 0 28px; padding: 0 0 24px; border-bottom: 1px solid var(--line); }
.auth-hero .auth-brand { border-bottom-color: rgba(255,255,255,.55); }
.auth-brand img { display: block; width: min(100%, 285px); height: auto; }

.auth-page h1 { margin: 0 0 12px; color: var(--ink); font-size: clamp(2rem, 7vw, 3rem); line-height: 1.05; }
.auth-hero h1 { color: #fff; }
.auth-hero p { margin: 0; color: #dceaf2; }
.auth-page label { display: grid; gap: 7px; margin: 18px 0 0; color: var(--ink); font-weight: 750; }
.auth-page input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 9px; }
.auth-page button { width: 100%; margin-top: 24px; padding: 14px; border: 0; border-radius: 9px; color: #fff; background: var(--cyan); font-weight: 800; }
.auth-page button:hover { background: var(--deep); }
.error, .inline-error { padding: 12px 14px; border: 2px solid #a71919; border-radius: 8px; color: #7d1010; background: #fff3f3; font-weight: 750; }

.wizard-page main { min-height: 100vh; }
.wizard-shell { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: 100vh; }
.wizard-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 24px;
  overflow-y: auto;
  color: #fff;
  background: var(--ink);
}
.brand { display: block; width: fit-content; color: #fff; text-decoration: none; }
.brand-logo { display: block; width: 222px; max-width: 100%; height: auto; }
.case-card { display: grid; gap: 3px; margin: 34px 0 16px; padding: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: var(--radius); background: rgba(255,255,255,.07); }
.case-card strong { color: #fff; font-size: 18px; }
.case-card span { color: #fff; opacity: .76; }
.assignment-card { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 17px 18px; border: 1px solid rgba(143,214,226,.42); border-radius: var(--radius); color: #fff; background: var(--deep); }
.assignment-card span, .assignment-card strong { color: #fff; }
.status-chip { grid-column: 1 / -1; justify-self: start; margin-top: 8px; padding: 4px 9px; border: 1px solid rgba(255,255,255,.45); border-radius: 99px; font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 12px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.wizard-sidebar .eyebrow { color: #fff; opacity: .68; }
.step-nav { display: grid; gap: 5px; margin-top: 28px; }
.step-link { display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 10px; width: 100%; padding: 10px 9px; border: 0; border-radius: 9px; color: #fff; background: transparent; text-align: left; opacity: .72; }
.step-link span { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; color: #fff; font-size: 11px; }
.step-link:hover, .step-link.is-active { color: #fff; background: rgba(143,214,226,.16); opacity: 1; }
.step-link.is-active span { border-color: var(--sky); color: var(--ink); background: var(--sky); font-weight: 900; }

.wizard-main { width: min(100%, 1100px); margin: 0 auto; padding: clamp(24px, 5vw, 64px); }
.wizard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.wizard-header h1 { max-width: 760px; margin: 0; color: var(--ink); font-size: clamp(2rem, 5vw, 4.4rem); line-height: .98; letter-spacing: -.045em; }
.wizard-header p:not(.eyebrow) { max-width: 680px; color: var(--muted); font-size: 18px; }
.button { min-height: 44px; padding: 11px 18px; border: 1px solid transparent; border-radius: 9px; font-weight: 800; }
.button-primary { color: #fff; background: var(--cyan); }
.button-primary:hover { background: #066983; }
.button-secondary { border-color: var(--line); color: var(--ink); background: var(--surface); }
.button-quiet { border-color: var(--line); color: var(--text); background: transparent; }
.wizard-header form { flex: none; }

.progress-region { margin: 32px 0 26px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.progress-copy { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 13px; }
.progress-copy strong { color: var(--green-ink); }
.progress-track { height: 8px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: #e3edf1; }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--lime)); transition: width .22s ease; }
.progress-track > .progress-17 { width: 17%; }
.progress-track > .progress-33 { width: 33%; }
.progress-track > .progress-50 { width: 50%; }
.progress-track > .progress-67 { width: 67%; }
.progress-track > .progress-83 { width: 83%; }
.progress-track > .progress-100 { width: 100%; }
.autosave { min-height: 21px; margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.autosave.is-unsaved { color: var(--warning); }
.autosave.is-saving { color: var(--cyan); }
.autosave.is-saved { color: var(--green-ink); }
.autosave.is-error { color: #8f1515; }
.mobile-step-nav { display: none; }

.wizard-panel { padding: clamp(22px, 4vw, 42px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 18px 55px rgba(7,19,31,.06); }
.wizard-panel fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.wizard-panel fieldset:disabled { opacity: .66; }
.wizard-panel legend { display: grid; gap: 4px; width: 100%; color: var(--ink); font-size: clamp(1.6rem, 4vw, 2.35rem); font-weight: 850; letter-spacing: -.025em; }
.wizard-panel legend span { color: var(--cyan); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.section-intro { max-width: 720px; margin: 7px 0 28px; color: var(--muted); }
.wizard-panel h2 { margin: 30px 0 12px; color: var(--ink); font-size: 17px; }
.wizard-panel label { display: grid; gap: 7px; color: var(--text); font-size: 14px; font-weight: 760; }
.wizard-panel input, .wizard-panel select, .wizard-panel textarea { width: 100%; min-height: 45px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); }
.wizard-panel textarea { min-height: 104px; resize: vertical; }
.wizard-panel input:invalid:not(:placeholder-shown), .wizard-panel textarea:invalid:not(:placeholder-shown) { border-color: #b51c1c; }
.wizard-panel input:disabled, .wizard-panel select:disabled, .wizard-panel textarea:disabled { color: var(--muted); background: #edf3f6; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.compact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-wide { grid-column: 1 / -1; }
.check-field { display: flex !important; align-items: center; gap: 10px; }
.check-field input { width: 20px; min-height: 20px; accent-color: var(--cyan); }
.repeatable { margin-top: 30px; }
.integration-choice { margin: 22px 0 30px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.integration-choice .section-intro { margin-top: 0; }
.repeatable-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.repeatable-heading h2, .repeatable-heading h3 { margin: 0; }
.repeatable-heading h3 { color: var(--muted); font-size: 14px; }
.repeatable-rows { display: grid; gap: 14px; }
.repeatable-row { padding: 18px !important; border: 1px solid var(--line) !important; border-radius: 10px; background: var(--canvas); }
.repeatable-row > legend { width: auto; padding: 0 7px; color: var(--muted); font-size: 13px; letter-spacing: .04em; }
.nested-repeatable { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.knowledge-ingest { margin: 24px 0; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.knowledge-source-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.knowledge-source-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.interval-rows { display: grid; gap: 10px; }
.interval-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; gap: 12px; }
.button-small { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.button-remove { justify-self: end; min-height: 36px; padding: 7px 11px; border-color: #d9a6a6; color: #861919; background: #fff8f8; font-size: 13px; }
.inline-error { margin: 18px 0 0; }
.panel-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.review-grid article { display: grid; gap: 5px; min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); }
.review-grid span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.review-grid strong { color: var(--ink); }
.review-confirm { margin: 24px 0 18px; padding: 15px; border: 1px solid var(--green); border-radius: 9px; background: #effcf6; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }

.admin-page main { min-height: 100vh; }
.admin-shell { min-height: 100vh; background: var(--canvas); }
.internal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 34px max(24px, calc((100vw - 1280px) / 2));
  color: #fff;
  background: var(--ink);
}
.internal-header .eyebrow { color: var(--sky); }
.internal-header h1 { margin: 0; color: #fff; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1; letter-spacing: -.035em; }
.internal-header p:not(.eyebrow) { max-width: 680px; margin: 12px 0 0; color: #dceaf2; }
.internal-brand { display: block; width: 235px; max-width: 100%; height: auto; margin: 0 0 26px; }
.internal-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.internal-nav a { min-height: 44px; padding: 10px 14px; border: 1px solid rgba(255,255,255,.35); border-radius: 9px; color: #fff; text-decoration: none; font-weight: 780; }
.internal-nav a:hover, .internal-nav a[aria-current="page"] { border-color: var(--sky); background: rgba(56,189,248,.18); }
.admin-content { display: grid; gap: 22px; width: min(100% - 32px, 1280px); margin: 0 auto; padding: 32px 0 64px; }
.admin-card { min-width: 0; padding: clamp(20px, 3vw, 32px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 15px 45px rgba(7,19,31,.06); }
.admin-card h2 { margin: 0; color: var(--ink); font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: -.02em; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.card-heading > strong { color: var(--cyan); font-size: 2rem; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.meta-grid dt, .meta-grid dd { min-width: 0; margin: 0; padding: 13px 14px; background: var(--surface); overflow-wrap: anywhere; }
.meta-grid dt { color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.meta-grid dd { color: var(--ink); font-weight: 740; }
.meta-grid.compact { grid-template-columns: minmax(110px, .5fr) minmax(0, 1fr); margin-bottom: 22px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.admin-form { display: grid; gap: 16px; }
.admin-form label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 760; }
.admin-form input, .admin-form textarea, .admin-form select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); }
.admin-form textarea { min-height: 120px; resize: vertical; }
.admin-form fieldset { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; }
.admin-form .check-field { display: flex; margin-top: 8px; }
.admin-form .check-field input { width: 20px; min-height: 20px; }
.filter-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); align-items: end; }
.filter-grid .button { align-self: end; }
.admin-card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-card th { padding: 12px; color: var(--ink); background: #eaf3f5; text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.admin-card td { min-width: 120px; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.admin-card tbody tr:hover { background: #f6fafc; }
.status-pill { display: inline-flex; align-items: center; width: fit-content; margin: 3px 0; padding: 4px 9px; border: 1px solid #8bbfa8; border-radius: 99px; color: var(--green-ink); background: #effcf6; font-size: 11px; font-weight: 850; letter-spacing: .035em; }
.agent-number { color: #05627d; font-size: 17px; font-weight: 850; }
.muted { color: var(--muted); }
.data-details { margin-top: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); }
.data-details summary { min-height: 44px; padding: 11px 14px; color: var(--ink); cursor: pointer; font-weight: 780; }
.data-details pre { margin: 0; padding: 16px; border-top: 1px solid var(--line); color: var(--text); background: #eef4f7; font-size: 13px; }
.source-list { display: grid; gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.source-list > li { padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); }
.source-list > li > strong { margin-right: 10px; color: var(--ink); }
.approval-card { border-left: 5px solid var(--cyan); }
.notice { margin: 0; padding: 13px 16px; border: 1px solid #c99a00; border-radius: 9px; color: #644d00; background: #fff9dc; font-weight: 750; }
.empty-state { margin: 0; padding: 24px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); text-align: center; }
.pagination { display: flex; gap: 12px; margin-top: 20px; }
.pagination a { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); font-weight: 760; text-decoration: none; }

@media (max-width: 820px) {
  .wizard-shell { display: block; }
  .wizard-sidebar { position: static; height: auto; padding: 20px; }
  .brand-logo { width: 196px; }
  .case-card, .assignment-card, .step-nav { display: none; }
  .wizard-main { padding: 24px 16px 44px; }
  .wizard-header { display: block; }
  .wizard-header form { position: absolute; top: 11px; right: 16px; }
  .wizard-header .button { color: #fff; border-color: rgba(255,255,255,.45); }
  .wizard-header h1 { margin-top: 24px; }
  .mobile-step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
  .mobile-step-nav .button { padding-inline: 12px; }
  .field-grid, .compact-grid, .review-grid { grid-template-columns: 1fr; }
  .repeatable-heading { align-items: flex-start; flex-direction: column; }
  .interval-row { grid-template-columns: 1fr; }
  .button-remove { justify-self: start; }
  .wizard-panel { padding: 23px 18px; }
  .internal-header { display: block; padding: 24px 16px; }
  .internal-brand { width: 205px; margin-bottom: 22px; }
  .internal-nav { margin-top: 22px; }
  .internal-nav a { flex: 1 1 auto; text-align: center; }
  .admin-content { width: min(100% - 24px, 1280px); padding: 20px 0 44px; }
  .admin-grid, .filter-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: minmax(100px, .6fr) minmax(0, 1fr); }
  .card-heading { align-items: flex-start; }
  .registry-card { padding-inline: 16px; }
}

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