:root {
  --background: #f2f5f4;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-subtle: #f7f8f7;
  --text-primary: #18211e;
  --text-secondary: #66716d;
  --border: #dce2e0;
  --border-strong: #c8d0cd;
  --brand-accent: #4a7fd1;
  --interaction-accent: #4a7fd1;
  --accent: var(--interaction-accent);
  --accent-hover: #5b8ed8;
  --accent-soft: color-mix(in srgb, var(--accent) 7%, transparent);
  --text-eyebrow: var(--text-secondary);
  --success: var(--accent);
  --warning: #946b2c;
  --danger: #a7433d;
  --danger-soft: #f8e8e6;
  --focus: var(--accent);
  --input-background: #fafbfa;
  --disabled: #8b9690;
  --disabled-background: #eceeeb;
  --on-accent: #081226;
  --text-inverse: #ffffff;
  --header-background: rgba(255, 255, 255, 0.94);
  --sticky-background: rgba(242, 245, 244, 0.96);
  --overlay-background: rgba(15, 17, 19, 0.58);
  --signature-canvas-background: #ffffff;
  --signature-ink: #18211e;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-soft: 0 18px 48px rgba(15, 17, 19, 0.08);
  --shadow-small: 0 8px 24px rgba(15, 17, 19, 0.07);
  --shadow-dialog: 0 24px 80px rgba(15, 17, 19, 0.24);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  --background: #0f1113;
  --surface: #16191c;
  --surface-elevated: #1c1f22;
  --surface-subtle: #191c1f;
  --text-primary: #f3f5f4;
  --text-secondary: #a6aeaa;
  --border: #30363b;
  --border-strong: #484f55;
  --accent-hover: #5b8ed8;
  --accent-soft: color-mix(in srgb, var(--accent) 7%, transparent);
  --text-eyebrow: #a6b0ba;
  --success: var(--accent);
  --warning: #d0a861;
  --danger: #e1847c;
  --danger-soft: #351f20;
  --focus: var(--accent);
  --input-background: #202428;
  --disabled: #737b80;
  --disabled-background: #23272a;
  --on-accent: #081226;
  --text-inverse: #0f1113;
  --header-background: rgba(15, 17, 19, 0.94);
  --sticky-background: rgba(15, 17, 19, 0.96);
  --overlay-background: rgba(6, 7, 8, 0.76);
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.24);
  --shadow-small: 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-dialog: 0 24px 80px rgba(0, 0, 0, 0.46);
  color-scheme: dark;
}

:root[data-theme="dark"] .choice-card:not([aria-pressed="true"]):not(:disabled):hover,
:root[data-theme="dark"] .module-card:not([aria-pressed="true"]):not(:disabled):hover {
  background: var(--surface-elevated);
}

:root[data-theme="dark"] .button-secondary {
  background: var(--surface);
}

:root[data-theme="dark"] .button-secondary:hover:not(:disabled) {
  background: var(--surface-elevated);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
  color: var(--text-primary);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  overflow-x: hidden;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
[data-theme-trigger]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--text-primary);
  color: var(--text-inverse);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  min-height: 60px;
  padding: 8px max(24px, env(safe-area-inset-right)) 8px max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--header-background);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.brand-name {
  max-width: min(50vw, 340px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

[data-saas-navigation] { min-width: 0; margin-left: 8px; flex: 1 1 auto; }

.header-preferences {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-right: 10px;
  border-right: 1px solid var(--border);
}

.account-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-menu {
  position: relative;
}

.account-menu-trigger {
  max-width: min(220px, 32vw);
  min-height: 38px;
  padding: 0 30px 0 12px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
  list-style: none;
  white-space: nowrap;
}

.account-menu-trigger::-webkit-details-marker { display: none; }
.account-menu-trigger span { overflow: hidden; text-overflow: ellipsis; }
.account-menu-trigger::after { content: "▾"; position: absolute; right: 11px; color: var(--text-secondary); }
.account-menu[open] .account-menu-trigger,
.account-menu-trigger:focus-visible { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); outline-offset: 2px; }

.account-menu-popover,
.administration-popover {
  position: absolute;
  z-index: 95;
  top: calc(100% + 7px);
  min-width: 240px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-dialog);
}

.account-menu-popover { right: 0; }
.account-menu-popover a,
.account-menu-popover button,
.administration-menu-link {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 630;
  text-align: left;
  text-decoration: none;
}
.account-menu-popover a:hover,
.account-menu-popover a:focus-visible,
.account-menu-popover button:hover,
.account-menu-popover button:focus-visible,
.administration-menu-link:hover,
.administration-menu-link:focus-visible { background: var(--surface-subtle); }
.account-menu-separator { height: 1px; margin: 6px 4px; background: var(--border); }
.account-menu-popover .account-menu-logout { color: var(--danger); }

.account-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.account-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 13px;
}

.header-link {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.settings-link {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.logout-link {
  background: transparent;
}

.auth-layout,
.admin-layout {
  width: min(100% - 32px, 1120px);
  margin: 0 auto;
  padding: clamp(32px, 7vw, 88px) 0;
}

.auth-layout {
  display: grid;
  place-items: start center;
}

.auth-card,
.admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.auth-card {
  width: min(100%, 460px);
  padding: clamp(24px, 5vw, 42px);
}

.auth-card h1,
.admin-heading h1 {
  margin: 5px 0 10px;
  letter-spacing: -0.035em;
}

.auth-hint,
.admin-heading p {
  color: var(--text-secondary);
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.auth-field {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
}

.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--input-background);
  color: var(--text-primary);
}

.auth-submit {
  width: 100%;
}

.form-error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
}

.form-error-inline {
  margin-top: 0;
}

.form-success {
  margin-bottom: 20px;
  padding: 13px 15px;
  display: grid;
  gap: 5px;
  border: 1px solid color-mix(in srgb, var(--success) 42%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
  color: var(--text-primary);
}

.form-success span {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.admin-heading {
  margin-bottom: 28px;
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(160px, 190px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.settings-navigation {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.settings-navigation-item {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border-radius: 11px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 670;
}

.settings-navigation-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-content {
  min-width: 0;
}

.admin-section-heading {
  margin-bottom: 20px;
}

.admin-section-heading h2 {
  margin: 0 0 5px;
}

.admin-section-heading p {
  margin: 0;
  color: var(--text-secondary);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.4fr);
  gap: 24px;
  align-items: start;
}

.admin-card {
  padding: clamp(20px, 3vw, 30px);
}

.admin-card h2,
.admin-card h3 {
  margin-top: 0;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.user-row-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
}

.user-update-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(112px, 1fr) minmax(112px, 1fr) minmax(88px, auto);
  gap: 16px;
  align-items: center;
}

.user-update-controls .user-choice-field,
.user-update-controls .user-choice { min-width: 0; width: 100%; }

.user-save-button { white-space: nowrap; }

.user-identity {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-identity span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
}

.user-actions-menu {
  position: relative;
  align-self: stretch;
}

.user-actions-menu summary {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
  white-space: nowrap;
  height: 100%;
  display: grid;
  place-items: center;
}

.user-actions-menu summary::-webkit-details-marker { display: none; }
.user-actions-menu summary::after { content: " ▾"; color: var(--text-secondary); }

.user-actions-popover {
  position: absolute;
  z-index: 70;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  min-width: 230px;
  max-width: min(280px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-small);
}

.user-actions-popover button {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.user-actions-popover button:hover,
.user-actions-popover button:focus-visible { background: var(--surface-subtle); }

.user-choice {
  position: relative;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
}

.user-choice-trigger {
  width: 100%;
  min-height: 46px;
  padding: 10px 36px 10px 12px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--input-background);
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  position: relative;
}

.user-choice-trigger::-webkit-details-marker { display: none; }

.user-choice-trigger::after {
  content: "▾";
  position: absolute;
  right: 12px;
  color: var(--text-secondary);
  transition: transform 150ms ease;
}

.user-choice[open] > .user-choice-trigger::after { transform: rotate(180deg); }

.user-choice-trigger:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }

.user-choice-trigger:focus-visible,
.user-choice[open] > .user-choice-trigger {
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.user-choice.is-disabled .user-choice-trigger {
  cursor: not-allowed;
  opacity: 0.66;
}

.user-choice.is-disabled .user-choice-trigger::after { display: none; }

.user-choice-popover {
  position: absolute;
  z-index: 75;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 180px);
  max-width: min(240px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-small);
}

.user-choice-popover button {
  width: 100%;
  min-height: 40px;
  padding: 9px 30px 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  text-align: left;
  white-space: nowrap;
}

.user-choice-popover button:hover,
.user-choice-popover button:focus-visible { background: var(--surface-subtle); }

.user-choice-popover button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.user-choice-popover button[aria-checked="true"]::after {
  content: "✓";
  position: absolute;
  right: 10px;
}

.user-password-reset {
  width: min(100%, 600px);
  padding: 16px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
  box-shadow: var(--shadow-soft);
}

.user-password-reset[hidden] { display: none; }

.user-password-reset form {
  display: grid;
  gap: 12px;
}

.user-password-reset-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.user-password-reset-heading span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
}

.user-password-reset .form-error,
.user-password-reset .form-success { margin: 0; }

.user-password-reset .form-error[hidden],
.user-password-reset .form-success[hidden] { display: none; }

.user-password-reset-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.password-input-control {
  position: relative;
  min-width: 0;
}

.password-input-control input {
  width: 100%;
  padding-right: 48px;
}

.password-visibility-button {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  width: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.password-visibility-button:hover,
.password-visibility-button:focus-visible {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.password-visibility-icon,
.password-visibility-icon svg {
  width: 20px;
  height: 20px;
}

.password-visibility-icon { display: grid; place-items: center; }

.password-visibility-icon svg {
  grid-area: 1 / 1;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 900px) {
  .account-name { display: none; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-navigation { width: min(100%, 320px); }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .user-row-toolbar { grid-template-columns: 1fr; }
  .user-actions-menu { width: fit-content; }
  .user-actions-popover { right: auto; left: 0; }
}

@media (max-width: 600px) {
  .app-header { padding-inline: 12px; gap: 8px; flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .header-preferences { padding-right: 0; border-right: 0; }
  .account-navigation { flex-basis: 100%; justify-content: flex-end; gap: 4px; }
  .account-controls { gap: 4px; }
  .header-link { padding-inline: 9px; }
  .user-update-controls { grid-template-columns: 1fr; }
  .user-actions-menu { width: 100%; }
  .user-actions-menu summary { height: auto; min-height: 44px; text-align: center; }
  .user-actions-popover { position: static; margin-top: 6px; }
  .user-actions-popover button { min-height: 44px; }
  .user-choice-popover { position: static; width: 100%; max-width: none; margin-top: 6px; }
  .user-choice-popover button { min-height: 44px; }
  .user-password-reset { width: 100%; padding: 14px; }
  .user-password-reset-buttons { display: grid; grid-template-columns: 1fr; }
  .password-visibility-button { width: 42px; }
}

.theme-switch {
  position: relative;
}

.theme-trigger {
  min-width: 94px;
  height: 36px;
  padding: 0 9px;
  display: inline-grid;
  grid-template-columns: 18px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 670;
}

.theme-trigger-icon,
.theme-option-icon {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.theme-trigger-icon svg,
.theme-option-icon svg {
  width: 17px;
  height: 17px;
}

.theme-trigger-chevron {
  color: var(--text-secondary);
  font-size: 13px;
  transform: translateY(-1px);
}

.theme-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 7px);
  right: 0;
  width: 178px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-small);
}

.theme-popover[hidden] {
  display: none;
}

.theme-option {
  width: 100%;
  min-height: 44px;
  padding: 0 9px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
  text-align: left;
}

.theme-option:hover {
  background: var(--surface-subtle);
}

.theme-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-option-check {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.language-switch button {
  min-width: 34px;
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.08em;
}

.language-switch button[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--text-inverse);
}

.main-content {
  width: 100%;
  min-height: calc(100vh - 61px);
  padding: 0 max(24px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.wizard-container {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 34px 0 0;
}

.progress-wrap {
  width: min(100%, 760px);
  margin: 0 auto 46px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.025em;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-step-1 span { width: 25%; }
.progress-step-2 span { width: 50%; }
.progress-step-3 span { width: 75%; }
.progress-step-4 span { width: 100%; }

.wizard-step {
  animation: step-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--text-eyebrow);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

.wizard-step > h1,
.case-created > h1,
.error-state h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(34px, 4.3vw, 58px);
  font-weight: 620;
  line-height: 1.06;
  letter-spacing: -0.045em;
}

#step-title:focus {
  outline: none;
}

.lead {
  max-width: 650px;
  margin: 18px 0 0;
  color: var(--text-secondary);
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.55;
}

.object-grid {
  margin-top: 38px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.choice-card,
.module-card {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.choice-card:hover,
.module-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.choice-card[aria-pressed="true"],
.module-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-card:disabled {
  border-color: var(--disabled);
  background: var(--disabled-background);
  color: var(--disabled);
  cursor: not-allowed;
  transform: none;
}

.object-card {
  min-height: 148px;
  padding: 18px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.choice-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--surface-subtle);
  color: var(--accent);
}

.choice-icon svg {
  width: 28px;
  height: 28px;
}

.choice-label {
  margin-top: auto;
  padding-top: 18px;
  font-size: 15px;
  font-weight: 660;
  line-height: 1.3;
  letter-spacing: -0.012em;
}

.unavailable-label {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.choice-indicator {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: transparent;
  font-size: 13px;
}

[aria-pressed="true"] > .choice-indicator {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.process-grid {
  max-width: 820px;
  margin-top: 38px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.process-card {
  min-height: 78px;
  padding: 16px 52px 16px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.process-card .choice-label {
  margin: 0;
  padding: 0;
  font-size: 17px;
}

.process-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--border-strong);
}

.process-card[aria-pressed="true"] .process-dot {
  background: var(--accent);
}

.module-picker {
  margin-top: 46px;
  max-width: 720px;
}

.section-heading {
  min-height: 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.section-heading h2,
.created-modules h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 710;
  letter-spacing: -0.012em;
}

.section-heading span {
  color: var(--text-secondary);
  font-size: 13px;
}

.available-heading {
  margin-top: 32px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.module-card {
  min-height: 72px;
  padding: 14px 14px 14px 52px;
  border-radius: 14px;
  text-align: left;
}

.module-card.is-selected {
  display: flex;
  align-items: stretch;
  padding: 0;
  border-color: var(--accent);
  background: var(--accent-soft);
  overflow: hidden;
}

.module-card.is-required:hover {
  transform: none;
}

/*
 * The dragged card is pulled out of grid flow, reparented onto <body>, and
 * follows the pointer directly via an inline translate3d() transform (set by
 * app.js) instead of being moved through the DOM — see the
 * pointerdown/pointermove handlers. This is purely the "picked up" visual
 * treatment for that floating card; it must NOT declare its own `transform`
 * here, since that would fight the inline positioning transform app.js sets.
 */
.module-card.is-dragging {
  box-shadow: var(--shadow-dialog);
  border-color: var(--accent);
  z-index: 50;
  pointer-events: none;
  transition: none;
}

/* The empty grid slot the dragged card will land in if dropped now. Sized to
 * match the dragged card (see app.js) so surrounding cards reflow exactly as
 * they will once the drop is committed. */
.module-card.is-drop-placeholder {
  opacity: 0.55;
  pointer-events: none;
}

/*
 * While actively dragging a module card, the pointer sweeps across other cards
 * in the grid, which would otherwise trigger their own :hover transform/transition
 * (translateY + a 160ms ease). Reading getBoundingClientRect() on a card mid-way
 * through that transition returns an interpolated (still-animating) position, not
 * its resting grid slot, which makes 2-column hit-testing miscalculate the nearest
 * card while dragging. Suppressing hover motion for the drag's duration keeps every
 * card's measured position exactly equal to its actual grid layout.
 */
body.is-reordering-modules .module-card:hover {
  transform: none;
  transition: none;
}

.module-drag-handle {
  flex: 0 0 auto;
  width: 44px;
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.module-drag-handle:active {
  cursor: grabbing;
}

.module-drag-handle svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.module-toggle {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 72px;
  padding: 14px 14px 14px 52px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.module-check {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-secondary);
  transform: translateY(-50%);
}

.module-card[aria-pressed="true"] .module-check,
.module-toggle[aria-pressed="true"] .module-check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.module-title {
  display: block;
  font-size: 14px;
  font-weight: 640;
  line-height: 1.3;
}

.required-label {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.empty-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.summary-list,
.created-modules ol {
  padding: 0;
  margin: 18px 0 0;
  list-style: none;
}

.summary-list li > span,
.created-modules li > span {
  color: var(--text-secondary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.summary-card {
  max-width: 820px;
  margin-top: 46px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.summary-primary {
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.summary-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}

.summary-icon svg {
  width: 28px;
  height: 28px;
}

.summary-primary h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.summary-primary p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.summary-list {
  margin: 0;
  padding: 13px 28px 20px;
  columns: 2;
  column-gap: 38px;
}

.summary-list li {
  min-height: 44px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  break-inside: avoid;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 590;
}

.wizard-nav {
  margin-top: 56px;
  padding: 22px 0 max(22px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
}

.button {
  min-height: 54px;
  padding: 0 22px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 680;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  min-width: 155px;
  background: var(--accent);
  color: var(--on-accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.button-danger-subtle {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
  background: var(--surface);
  color: var(--danger);
}

.button-danger-subtle:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.button:disabled {
  border-color: var(--disabled);
  background: var(--disabled-background);
  color: var(--disabled);
  cursor: not-allowed;
}

.case-created {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 80px 0;
}

.success-mark {
  width: 52px;
  height: 52px;
  margin-bottom: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 20px;
}

.case-meta {
  margin: 44px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.internal-reference {
  margin: 24px 0 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 11px;
}

.internal-reference span {
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.internal-reference code {
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.case-meta > div {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-elevated);
}

.case-meta dt {
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.case-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 640;
}

.created-modules {
  margin: 28px 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
}

.created-modules ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}

.created-modules li {
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.app-shell.is-editor .main-content {
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.editor-shell {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 30px 0 0;
}

.editor-context {
  min-width: 0;
  padding: 0 0 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  border-bottom: 1px solid var(--border);
}

.editor-context-copy {
  min-width: 0;
}

.editor-context h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 630;
  line-height: 1.08;
  letter-spacing: -0.038em;
}

.editor-context-tags {
  margin-top: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-context-tags span {
  min-height: 30px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.editor-case-number {
  min-width: 190px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.editor-case-number span,
.editor-case-number small,
.editor-case-number-label {
  display: block;
  color: var(--text-secondary);
  font-size: 10px;
}

.editor-case-number span,
.editor-case-number-label {
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-case-number strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 18px;
  font-weight: 650;
}

.editor-case-number input {
  width: 100%;
  min-width: 0;
  margin-top: 4px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
}

.editor-save-state {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.save-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.editor-save-state.is-saving .save-state-dot {
  background: var(--warning);
  animation: pulse 900ms ease-in-out infinite alternate;
}

.editor-save-state.is-saved .save-state-dot,
.editor-save-state.is-idle .save-state-dot {
  background: var(--success);
}

.editor-save-state.is-error {
  color: var(--danger);
}

.editor-save-state.is-error .save-state-dot {
  background: var(--danger);
}

.editor-conflict {
  margin: 14px 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface-elevated));
}

.editor-conflict strong {
  font-size: 14px;
}

.editor-conflict p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.editor-conflict .button {
  min-height: 44px;
  flex: 0 0 auto;
}

.editor-document-actions {
  min-width: 0;
  /* Now the last thing in the editor shell (moved below .editor-layout so the
   * final PDF/download section reads as the end of the workflow instead of
   * competing with the header for attention) — margin on both sides gives it
   * breathing room from the module content above it. */
  margin: 22px 0;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-elevated);
}

.editor-document-copy {
  min-width: 0;
}

.editor-document-copy .eyebrow {
  margin: 0 0 5px;
}

.editor-document-copy h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.editor-document-copy > p:last-child,
.editor-document-copy > h2 + p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.editor-document-copy .editor-document-error {
  color: var(--danger);
}

.signature-missing-notice {
  margin: 8px 0 0;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 32%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warning) 9%, var(--surface-elevated));
  color: var(--warning);
  font-size: 12.5px;
  line-height: 1.45;
}

.editor-document-copy .signature-missing-notice {
  margin-top: 5px;
}

.editor-document-controls {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-document-controls .button {
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}

.editor-finalized-banner {
  margin: 0 0 16px;
  padding: 14px 16px;
  display: flex;
  align-items: baseline;
  gap: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-subtle);
}

.editor-finalized-banner strong {
  flex: 0 0 auto;
}

.editor-finalized-banner span {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.editor-shell.is-finalized .editor-module :disabled {
  cursor: not-allowed;
}

/* The read-only summary renders inside the canonical finalization dialog
 * (see renderFinalizationDialog() in app.js) — there is no separate summary
 * dialog. .finalization-summary-list/-row below are the row styling shared
 * by every context that has ever hosted them; the .finalization-review-*
 * rules further down are the dialog-specific overrides that make this
 * particular dialog visually echo the wizard's own start-overview step
 * (renderSummaryStep() in ui.js / .summary-card, reused as-is here). */
.finalization-summary-list {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.finalization-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.finalization-summary-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.finalization-summary-row dt {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.finalization-summary-row dd {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: 13.5px;
  font-weight: 620;
}

.finalization-summary-row dd span {
  display: block;
}

.finalization-summary-row dd span + span {
  margin-top: 2px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
}

.change-history {
  min-width: 0;
  margin: 0 0 22px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-elevated);
}

.change-history h2 {
  margin: 0 0 14px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.change-history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.change-history-entry {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.change-history-entry-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.change-history-entry-header span {
  color: var(--text-secondary);
}

.change-history-step {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.change-history-step.change-history-open {
  color: var(--warning);
}

.change-history-changed-label {
  margin: 8px 0 2px;
  font-size: 13px;
  font-weight: 650;
}

.change-history-changes {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.reopen-dialog-reason-label {
  display: block;
  margin: 18px 0 6px;
  font-size: 13px;
  font-weight: 650;
}

.reopen-dialog-reason {
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

body.finalization-dialog-open {
  overflow: hidden;
}

.finalization-dialog-overlay {
  position: fixed;
  z-index: 120;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: var(--overlay-background);
}

.finalization-dialog {
  width: min(100%, 520px);
  max-height: min(90vh, 720px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-dialog);
  overflow-y: auto;
}

.finalization-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.finalization-dialog-header .eyebrow {
  margin-bottom: 8px;
}

.finalization-dialog-header h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 28px);
  letter-spacing: -0.025em;
}

.finalization-dialog-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.finalization-dialog > p:not(.lead) {
  margin: 18px 0 24px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.finalization-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.finalization-dialog-actions .button {
  min-height: 44px;
}

/* The full-page finalization review (see final-review-ui.js) is a real page
 * inside #main-content, not a dialog — it reuses .wizard-container/
 * .wizard-step/.eyebrow/.lead/.summary-card/.wizard-nav exactly as the
 * wizard's own start-overview step (renderSummaryStep() in ui.js) already
 * does, so the two checkpoints of the same workflow share one visual
 * language automatically, with no redefinition of those base classes here —
 * the wizard's own steps are completely unaffected. Only the review's own
 * multi-card layout and card-internal content below are new. */
#finalization-review-title:focus {
  outline: none;
}

.review-card-grid {
  margin-top: 38px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.review-card {
  max-width: none;
  margin-top: 0;
  padding: 24px 28px;
}

.review-card-primary {
  padding: 0;
}

.review-card-header h2,
.review-card > h2 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 660;
  letter-spacing: -0.02em;
}

.review-card-subtitle {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.review-field-list {
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
}

.review-field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}

.review-field-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.review-field-row dt {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-weight: 610;
}

.review-field-row dd {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-weight: 600;
}

.review-module-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.review-module {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.review-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-module-name {
  font-size: 14px;
  font-weight: 640;
}

/* Reuses .editor-status-badge as-is (see editor-ui.js's own module header —
 * the same read-only dot+text status indicator, never a button/control
 * there either) so the final review's section statuses read as plain
 * information, not as an interactive chip/toggle. Only size is tightened
 * here for this denser list context; the dot coloring per status
 * (.editor-status-badge.status-complete/.status-in_progress > span) is
 * inherited unchanged. */
.review-module-status {
  min-height: 22px;
  padding: 2px 10px;
  font-size: 10.5px;
}

.review-item-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-item {
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.review-item strong {
  display: block;
  font-weight: 630;
}

.review-item span {
  display: block;
  color: var(--text-secondary);
}

.review-item.is-defect strong {
  color: var(--danger);
}

/* Small, read-only thumbnails per section on the final review page — a
   deliberately more compact variant of .photo-grid/.photo-card (no remove
   button, no footer, smaller minimum tile size), never full-size originals. */
.review-photo-grid {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  max-width: 360px;
}

.review-photo-thumb-item {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-background);
  display: grid;
  place-items: center;
}

.review-photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.review-photo-thumb-unavailable {
  color: var(--accent);
  font-size: 16px;
}

.review-photo-thumb-unavailable[hidden] {
  display: none;
}

.review-remark {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.review-photo-count {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.review-empty-hint {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.review-defect-group + .review-defect-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.review-defect-group h3,
.review-card h3 {
  margin: 18px 0 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.review-card h3:first-of-type {
  margin-top: 14px;
}

.editor-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.editor-sidebar {
  position: sticky;
  top: 18px;
  min-width: 0;
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
}

.editor-sidebar-heading {
  min-height: 34px;
  padding: 0 4px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-sidebar-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
}

.editor-sidebar-heading span {
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.editor-area-nav {
  display: grid;
  gap: 5px;
}

.editor-area-link {
  width: 100%;
  min-height: 58px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.editor-area-link:hover {
  background: var(--surface-subtle);
}

.editor-area-link[aria-current="step"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.editor-area-number {
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.editor-area-copy {
  min-width: 0;
}

.editor-area-copy strong,
.editor-area-copy small {
  display: block;
}

.editor-area-copy strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 660;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-area-copy small {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 10px;
}

.editor-area-status {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 800;
}

.editor-area-link.status-in_progress .editor-area-status {
  border-color: var(--warning);
  background: var(--warning);
}

.editor-area-link.status-complete .editor-area-status {
  border-color: var(--success);
  background: var(--success);
}

.editor-mobile-select {
  display: none;
}

.editor-area-chip-mobile,
.editor-mobile-navigation {
  display: none;
}

.editor-module {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.editor-module-header {
  min-width: 0;
  padding: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.editor-module-header > div {
  min-width: 0;
}

.editor-module-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 630;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.editor-module-header p:last-child {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.editor-status-badge {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 690;
}

.editor-status-badge > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.editor-status-badge.status-in_progress > span {
  background: var(--warning);
}

.editor-status-badge.status-complete > span {
  background: var(--success);
}

.editor-status-controls {
  padding: 18px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.editor-status-controls button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 660;
}

.editor-status-controls button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.editor-placeholder {
  min-height: 300px;
  margin: 28px;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.editor-placeholder-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--surface);
  color: var(--accent);
  font-size: 15px;
  font-weight: 750;
  box-shadow: var(--shadow-small);
}

.editor-placeholder h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 680;
}

.editor-placeholder p {
  max-width: 480px;
  margin: 7px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.schema-form {
  padding: 0 28px;
}

.schema-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.schema-section > h3,
.schema-section-heading h3 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.schema-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.schema-section-heading span {
  color: var(--text-secondary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.schema-context dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.schema-context dl > div {
  min-height: 70px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.schema-context dt {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.schema-context dd {
  margin: 7px 0 0;
  font-size: 14px;
  font-weight: 650;
}

.schema-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.schema-field.is-wide {
  grid-column: 1 / -1;
}

.schema-field-label {
  margin-bottom: 7px;
  display: block;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 660;
}

.schema-field.is-disabled .schema-field-label {
  color: var(--text-secondary);
}

.schema-field-label-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.schema-field input,
.schema-field textarea,
.schema-field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--input-background);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}

.schema-field textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
}

/* A short integer quantity (e.g. "Anzahl Schlüssel", max 3 digits) has no
 * business stretching across the full content column the way a text field or
 * a remark textarea does — see isCompactQuantityField() in schema-form-ui.js. */
.schema-field input.quantity-input {
  width: 140px;
  max-width: 100%;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.schema-field input[aria-invalid="true"],
.schema-field textarea[aria-invalid="true"],
.schema-field select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

/* Custom date field (replaces native <input type="date">, see date-field.js
 * and app.js's date-picker-* actions): a plain text input showing
 * DD.MM.YYYY/YYYY-MM-DD, a calendar-popover trigger, and an explicit clear
 * button — all app-controlled, no native browser date UI involved.
 *
 * Visually this is ONE bordered/rounded pill matching every other schema
 * input exactly (border, radius, background, height) — the wrapper itself
 * carries that styling, and the text input inside it is borderless/
 * transparent so it reads as the field's own text rather than a separate
 * box. The calendar and clear controls stay genuinely separate <button>
 * elements (each independently focusable/labeled for accessibility), just
 * styled as plain icon buttons living inside the same pill instead of
 * their own bordered boxes. Purely a visual change: nothing about the
 * open/select/type/clear/commit behavior lives here (see app.js) — the
 * previous three-separate-boxes look can be restored by reverting only
 * this rule block. */
.date-field {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--input-background);
}

.date-field:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

/* The text input itself is borderless (see below) so it reads as part of
 * one pill rather than its own box — so its focus ring is drawn around the
 * whole pill instead of just the input's own (invisible-bordered) edges,
 * which would otherwise look like a stray line cutting across the middle
 * of the control. The calendar/clear buttons keep their own default
 * focus-visible outline (matching every other button in the app) since
 * each is its own small, separately-labeled control. */
.date-field:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.date-field input:focus-visible {
  outline: none;
}

.date-field input {
  flex: 1 1 auto;
  align-self: stretch;
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 10px 4px 10px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.date-field-calendar,
.date-field-clear {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin: 0 3px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.date-field-calendar {
  margin-right: 1px;
}

.date-field-clear {
  margin-right: 3px;
  margin-left: 1px;
}

.date-field-calendar:hover,
.date-field-clear:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.date-field-clear {
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}

.date-picker-popover {
  position: fixed;
  z-index: 130;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-small);
}

.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.date-picker-month-label {
  font-size: 13px;
  font-weight: 650;
  text-transform: capitalize;
}

.date-picker-nav {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 15px;
}

.date-picker-nav:hover {
  background: var(--surface-subtle);
}

.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 2px;
}

.date-picker-weekday {
  display: block;
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 650;
  text-align: center;
  text-transform: uppercase;
}

.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.date-picker-day {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.date-picker-day.is-blank {
  cursor: default;
}

.date-picker-day:not(.is-blank):hover {
  background: var(--surface-subtle);
}

.date-picker-day.is-today {
  border-color: var(--border-strong);
  font-weight: 700;
}

.date-picker-day.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.date-picker-footer {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.date-picker-footer .button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.schema-field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.4;
}

.schema-field-hint {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.schema-field {
  position: relative;
  /* Grid items default to min-width: auto, which lets a wide-min-content
   * native control (most notably <input type="date">'s internal
   * month/day/year segment UI — Safari renders this noticeably wider than
   * Chromium) refuse to shrink to its allocated 1fr track, overflowing into
   * the next column at tablet widths even though .schema-field-grid's
   * columns are already minmax(0, 1fr). min-width: 0 here lets the field
   * actually honor that track width instead of overflowing it. */
  min-width: 0;
}

.address-suggestions {
  position: absolute;
  z-index: 4;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.address-suggestions:empty,
.address-suggestions[hidden] {
  display: none;
}

.address-suggestion {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.address-suggestion:last-child {
  border-bottom: 0;
}

.address-suggestion:hover,
.address-suggestion:focus-visible {
  background: var(--accent-soft);
}

.schema-party-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.schema-party {
  min-width: 0;
  margin: 0;
  padding: 16px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
}

.schema-party legend {
  padding: 0 5px;
  font-size: 12px;
  font-weight: 710;
}

.schema-party-static {
  min-height: 90px;
  align-content: center;
  gap: 5px;
  background: var(--surface-subtle);
}

.schema-party-static strong {
  font-size: 13px;
}

.schema-party-static span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.repeatable-list {
  display: grid;
  gap: 14px;
}

.repeatable-item {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.repeatable-item-header {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.repeatable-item-header > div:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.repeatable-item-header > div:first-child > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.repeatable-item h4 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.repeatable-item h6 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.repeatable-item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.repeatable-item-actions button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}

.repeatable-item-actions button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.repeatable-item-actions button.is-danger {
  color: var(--danger);
}

.repeatable-item-actions button.repeatable-remove {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  gap: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.repeatable-item-actions button:disabled {
  border-color: var(--disabled-background);
  background: var(--disabled-background);
  color: var(--disabled);
  cursor: not-allowed;
}

.repeatable-field-grid {
  margin-bottom: 16px;
}

.repeatable-inspection-list {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.repeatable-empty {
  margin: 0 0 14px;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.area-key-summary-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.area-key-summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.area-key-summary-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-subtle);
  font-size: 13px;
}

.area-key-summary-item strong {
  flex: 1 1 auto;
  min-width: 120px;
}

.area-key-summary-item span {
  color: var(--text-secondary);
}

.repeatable-add {
  margin-top: 14px;
}

.nested-repeatable {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.nested-repeatable-heading {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nested-repeatable-heading h5 {
  margin: 0;
  font-size: 14px;
}

.nested-repeatable-heading > span {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.nested-repeatable-list {
  display: grid;
  gap: 10px;
}

.nested-repeatable-item {
  padding: 14px;
  background: var(--surface-subtle);
}

.nested-repeatable-item .repeatable-field-grid {
  margin-bottom: 0;
}

.inspection-list {
  display: grid;
  gap: 8px;
}

.inspection-item {
  min-width: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(140px, 0.62fr) minmax(330px, 1fr) minmax(160px, 0.58fr);
  align-items: end;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
}

.inspection-title {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.inspection-title span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.inspection-title strong {
  font-size: 12px;
  line-height: 1.3;
}

.remark-field.is-collapsed {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.remark-toggle {
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
}

.remark-toggle:hover,
.remark-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-soft);
}

.remark-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.remark-field.is-expanded {
  grid-column: 1 / -1;
}

.remark-field.is-expanded .remark-toggle {
  margin-bottom: 6px;
}

.remark-textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
}

.schema-option-group {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.schema-option-group button,
.schema-checkbox {
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.schema-option-group button[aria-pressed="true"],
.schema-checkbox[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.schema-checkbox {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
}

.schema-checkbox span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 7px;
}

.schema-completion {
  margin: 24px 28px 28px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-subtle);
}

.schema-completion strong {
  font-size: 13px;
}

.schema-completion p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.schema-completion .button {
  min-height: 46px;
  flex: 0 0 auto;
}

.editor-module-nav {
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.signature-section {
  margin: 0 28px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
}

.photo-section {
  margin: 18px 28px 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-subtle);
}

.photo-section.is-embedded {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  margin: 16px 0 0;
  padding: 16px;
  background: var(--surface);
}

.photo-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.photo-section-heading h3,
.photo-section-heading p {
  margin: 0;
}

.photo-section-heading p {
  margin-bottom: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.photo-section-heading h3 {
  font-size: 16px;
}

.photo-section-heading > span {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.photo-empty,
.photo-take-hint {
  color: var(--text-secondary);
}

.photo-empty {
  margin: 14px 0;
  font-size: 13px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.photo-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.photo-preview {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--input-background);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-unavailable {
  padding: 12px;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
}

.photo-preview-unavailable[hidden] {
  display: none;
}

.photo-preview-unavailable > span {
  color: var(--accent);
  font-size: 24px;
}

.photo-card-footer {
  min-height: 52px;
  padding: 6px 7px 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.photo-card-footer strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove {
  min-width: 44px;
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.photo-remove:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.photo-add {
  min-height: 44px;
}

.photo-take-hint {
  display: block;
  margin-top: 7px;
  font-size: 11px;
}

.signature-section-heading {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.signature-section-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.signature-section-heading p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.signature-section-heading > span {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.signature-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.signature-card.is-signed {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
}

.signature-card > header {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.signature-card h4 {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

.signature-card header span:not(.signature-state) {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 10px;
}

.signature-state {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.is-signed .signature-state {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.signature-preview,
.signature-empty {
  height: 108px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--signature-canvas-background);
}

.signature-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.signature-empty {
  display: grid;
  place-items: center;
  background: var(--surface-subtle);
  color: var(--border-strong);
  font-size: 20px;
}

.signature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.signature-actions .button {
  min-width: 0;
  min-height: 44px;
  padding: 0 11px;
  flex: 1 1 auto;
  font-size: 11px;
}

.signature-actions .signature-reuse {
  flex-basis: 100%;
  height: auto;
  padding-top: 9px;
  padding-bottom: 9px;
  line-height: 1.35;
}

body.signature-dialog-open {
  overflow: hidden;
}

.signature-dialog-overlay {
  position: fixed;
  z-index: 220;
  inset: 0;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: var(--overlay-background);
}

.signature-dialog {
  width: min(100%, 780px);
  max-height: calc(100dvh - 40px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-dialog);
}

.signature-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.signature-dialog-header h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 650;
  letter-spacing: -0.025em;
}

.signature-dialog-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.signature-dialog-hint {
  margin: 10px 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.signature-canvas-wrap {
  width: 100%;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-subtle);
}

[data-signature-canvas] {
  width: 100%;
  height: 230px;
  display: block;
  border-radius: 10px;
  background: var(--signature-canvas-background);
  cursor: crosshair;
  touch-action: none;
}

.signature-dialog-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.signature-dialog-error[hidden] {
  display: none;
}

.signature-dialog-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signature-dialog-actions > div {
  display: flex;
  gap: 8px;
}

.loading-state,
.error-state {
  min-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 900ms ease-in-out infinite alternate;
}

@keyframes pulse {
  to { opacity: 0.25; transform: scale(0.75); }
}

.loading-state p,
.error-state p {
  color: var(--text-secondary);
}

.error-state > span {
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

.error-state h1 {
  font-size: clamp(30px, 4vw, 46px);
}

.error-state p {
  max-width: 560px;
  margin: 16px 0 24px;
  line-height: 1.55;
}

.notice-low:empty,
.notice-corner:empty,
#notice-blocking:empty {
  display: none;
}

.notice-low {
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}

.notice-banner {
  width: min(100%, 1100px);
  min-height: 52px;
  margin: 14px auto 0;
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-elevated);
}

.notice-copy strong {
  font-size: 13px;
}

.notice-copy p {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.notice-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 680;
}

.notice-dismiss {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.notice-corner {
  position: fixed;
  z-index: 30;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: min(380px, calc(100vw - 40px));
  display: grid;
  gap: 10px;
}

.notice-card {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: 15px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.notice-card.severity-high {
  border-left-color: var(--danger);
}

.notice-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: var(--overlay-background);
  backdrop-filter: blur(5px);
}

.notice-dialog {
  width: min(100%, 500px);
  padding: 30px;
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-dialog);
}

.notice-symbol {
  width: 42px;
  height: 42px;
  margin-bottom: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

.notice-dialog .notice-copy strong {
  font-size: 21px;
}

.notice-dialog .notice-copy p {
  margin-top: 9px;
  font-size: 15px;
  line-height: 1.55;
}

.notice-dialog .notice-actions {
  margin-top: 22px;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .theme-trigger,
  .language-switch button {
    height: 44px;
  }

  .language-switch button {
    min-width: 44px;
  }

  .object-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-sidebar {
    position: static;
    max-height: none;
  }

  .editor-area-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inspection-item {
    grid-template-columns: minmax(120px, 0.5fr) minmax(320px, 1fr);
  }

  .inspection-note-field {
    grid-column: 1 / -1;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-area-nav,
  .editor-sidebar-heading,
  .editor-area-count-desktop {
    display: none;
  }

  .editor-sidebar {
    position: static;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .editor-area-chip-mobile {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }

  .editor-mobile-navigation {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    background: var(--overlay-background);
  }

  .editor-mobile-navigation-panel {
    width: min(100%, 620px);
    max-height: min(84vh, 760px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px 20px 14px 14px;
    background: var(--surface-elevated);
    box-shadow: var(--shadow-dialog);
  }

  .editor-mobile-navigation-panel > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
  }

  .editor-mobile-navigation-panel h2,
  .editor-mobile-navigation-panel p {
    margin: 0;
  }

  .editor-mobile-navigation-panel p {
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 12px;
  }

  .editor-mobile-navigation-panel > header button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
  }

  .editor-mobile-navigation-panel nav {
    max-height: calc(min(84vh, 760px) - 90px);
    overflow-y: auto;
    padding: 10px;
  }

  .editor-mobile-area-link {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
  }

  .editor-mobile-area-link + .editor-mobile-area-link {
    margin-top: 3px;
  }

  .editor-mobile-area-link[aria-current="step"] {
    background: var(--accent-soft);
    outline: 1px solid var(--accent);
    outline-offset: -1px;
  }

  .editor-mobile-area-link .editor-area-copy {
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .app-header {
    min-height: 68px;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }

  .brand-name {
    max-width: 40vw;
  }

  .main-content {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .wizard-container {
    padding-top: 24px;
  }

  .progress-wrap {
    margin-bottom: 38px;
  }

  .wizard-step > h1,
  .case-created > h1 {
    font-size: clamp(32px, 10vw, 44px);
  }

  .object-grid,
  .process-grid {
    margin-top: 34px;
    grid-template-columns: 1fr;
  }

  .object-grid {
    gap: 10px;
  }

  .object-card {
    min-height: 88px;
    padding: 16px 52px 16px 16px;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }

  .choice-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
  }

  .choice-icon svg {
    width: 27px;
    height: 27px;
  }

  .object-card .choice-label {
    margin: 0;
    padding: 0;
  }

  .process-card {
    min-height: 76px;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-picker,
  .summary-card {
    margin-top: 34px;
  }

  .summary-list {
    columns: 1;
  }

  .review-card-grid {
    margin-top: 30px;
    gap: 16px;
  }

  .review-card {
    padding: 18px 18px;
  }

  .review-module-header {
    flex-wrap: wrap;
  }

  .wizard-nav {
    position: sticky;
    z-index: 8;
    bottom: 0;
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
    background: var(--sticky-background);
    backdrop-filter: blur(14px);
  }

  .case-created {
    padding: 54px 0;
  }

  .case-meta,
  .created-modules ol {
    grid-template-columns: 1fr;
  }

  .notice-banner {
    align-items: flex-start;
  }

  .editor-shell {
    padding-top: 22px;
  }

  .editor-context {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
  }

  .editor-case-number {
    min-width: 0;
  }

  .editor-conflict {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-document-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .finalization-summary-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .finalization-summary-row dd {
    text-align: left;
  }

  .editor-document-controls {
    justify-content: stretch;
  }

  .editor-document-controls .button {
    flex: 1 1 180px;
  }

  .editor-finalized-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-area-nav {
    display: none;
  }

  .editor-sidebar {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .editor-sidebar-heading {
    display: none;
  }

  .editor-area-count-desktop {
    display: none;
  }

  .editor-area-chip-mobile {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }

  .editor-mobile-navigation {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    background: var(--overlay-background);
  }

  .editor-mobile-navigation-panel {
    width: min(100%, 620px);
    max-height: min(84vh, 760px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px 20px 14px 14px;
    background: var(--surface-elevated);
    box-shadow: var(--shadow-dialog);
  }

  .editor-mobile-navigation-panel > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
  }

  .editor-mobile-navigation-panel h2,
  .editor-mobile-navigation-panel p {
    margin: 0;
  }

  .editor-mobile-navigation-panel p {
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 12px;
  }

  .editor-mobile-navigation-panel > header button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
  }

  .editor-mobile-navigation-panel nav {
    max-height: calc(min(84vh, 760px) - 90px);
    overflow-y: auto;
    padding: 10px;
  }

  .editor-mobile-area-link {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
  }

  .editor-mobile-area-link + .editor-mobile-area-link {
    margin-top: 3px;
  }

  .editor-mobile-area-link[aria-current="step"] {
    background: var(--accent-soft);
    outline: 1px solid var(--accent);
    outline-offset: -1px;
  }

  .editor-mobile-area-link .editor-area-copy {
    min-width: 0;
  }

  .editor-module-header {
    padding: 22px;
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .editor-status-badge {
    align-self: flex-start;
  }

  .editor-status-controls {
    padding: 16px 22px;
  }

  .editor-status-controls button {
    flex: 1 1 140px;
  }

  .editor-placeholder {
    min-height: 240px;
    margin: 22px;
    padding: 24px;
  }

  .schema-form {
    padding: 0 22px;
  }

  .photo-section {
    margin-right: 22px;
    margin-left: 22px;
  }

  .photo-section.is-embedded {
    margin-right: 0;
    margin-left: 0;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }

  .schema-section {
    padding: 22px 0;
  }

  .schema-field-grid,
  .schema-context dl,
  .schema-party-grid,
  .inspection-item {
    grid-template-columns: 1fr;
  }

  .schema-field.is-wide,
  .inspection-note-field {
    grid-column: auto;
  }

  .inspection-item {
    align-items: stretch;
  }

  .inspection-status-field,
  .inspection-note-field {
    min-width: 0;
  }

  .repeatable-item {
    padding: 14px;
  }

  .repeatable-item-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .repeatable-item-actions {
    flex-wrap: wrap;
  }

  .repeatable-item-actions button.repeatable-remove {
    max-width: 100%;
  }

  .schema-completion {
    margin: 20px 22px 24px;
    align-items: stretch;
    flex-direction: column;
  }

  .schema-completion .button {
    width: 100%;
  }

  .signature-section {
    margin: 0 22px;
    padding: 22px 0;
  }

  .signature-grid {
    grid-template-columns: 1fr;
  }

  .signature-preview,
  .signature-empty {
    height: 124px;
  }

  .editor-module-nav {
    padding: 16px 22px;
  }
}

@media (max-width: 430px) {
  .finalization-dialog-overlay {
    padding: 12px;
  }

  .finalization-dialog {
    padding: 18px;
  }

  .finalization-dialog-actions {
    flex-direction: column-reverse;
  }

  .finalization-dialog-actions .button {
    width: 100%;
  }

  .brand-name {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .theme-trigger {
    min-width: 58px;
    grid-template-columns: 18px 12px;
  }

  .theme-trigger-label {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .progress-meta span:last-child {
    display: none;
  }

  .wizard-nav .button {
    flex: 1 1 0;
    padding: 0 14px;
  }

  .wizard-nav .button-primary {
    min-width: 0;
  }

  .summary-primary,
  .created-modules {
    padding: 18px;
  }

  .editor-placeholder {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-module-nav .button {
    min-width: 0;
    padding: 0 12px;
    flex: 1 1 0;
  }

  .signature-section-heading,
  .signature-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .signature-section-heading > span {
    align-self: flex-start;
  }

  .signature-dialog-overlay {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    align-items: end;
  }

  .signature-dialog {
    max-height: calc(100dvh - 20px);
    padding: 18px;
    border-radius: 18px;
  }

  [data-signature-canvas] {
    height: 210px;
  }

  .signature-dialog-actions > .button,
  .signature-dialog-actions > div,
  .signature-dialog-actions > div .button {
    width: 100%;
  }
}

/* Authenticated SaaS application shell and settings foundation. */
.saas-navigation-shell {
  min-width: 0;
}

.app-shell.has-saas-navigation .main-content { min-height: calc(100vh - 61px); }

.saas-navigation-desktop {
  width: fit-content;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 20px;
}

.saas-nav-link {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 11px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
}

.saas-nav-link:hover,
.saas-nav-link:focus-visible { background: var(--surface-subtle); color: var(--text-primary); }
.saas-nav-link.is-active { background: var(--accent-soft); color: var(--accent); }
.administration-menu { position: relative; }
.administration-menu > summary { cursor: pointer; list-style: none; }
.administration-menu > summary::-webkit-details-marker { display: none; }
.administration-menu > summary::after { content: "▾"; margin-left: 7px; color: var(--text-secondary); }
.administration-menu.is-active > summary,
.administration-menu[open] > summary { background: var(--accent-soft); color: var(--accent); }
.administration-popover { left: 0; display: grid; gap: 2px; }
.administration-menu-group {
  padding: 9px 12px 4px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.saas-mobile-admin-group { margin-top: 12px; padding-top: 12px; display: grid; gap: 4px; border-top: 1px solid var(--border); }
.saas-mobile-admin-group > span { padding: 4px 14px; color: var(--text-secondary); font-size: 11px; font-weight: 760; letter-spacing: 0.08em; text-transform: uppercase; }
.saas-mobile-trigger,
.saas-mobile-navigation,
.saas-mobile-backdrop { display: none; }

.saas-page {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding-top: clamp(28px, 5vw, 56px);
}

.saas-page-header { max-width: 780px; margin-bottom: 28px; }
.saas-page-header h1 { margin: 4px 0 10px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; }
.saas-page-header p:last-child { margin: 0; color: var(--text-secondary); line-height: 1.65; }
.saas-page-header-actions,
.saas-section-heading,
.dashboard-primary-action,
.dashboard-admin-entry,
.subscription-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.saas-page-header-actions { max-width: none; align-items: end; }
.saas-section,
.dashboard-primary-action,
.dashboard-admin-entry,
.settings-form-section,
.subscription-summary,
.saas-info-note {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.dashboard-primary-action { margin-bottom: 24px; background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.dashboard-primary-action h2,
.dashboard-admin-entry h2,
.saas-section-heading h2 { margin: 0 0 5px; }
.dashboard-primary-action p,
.dashboard-admin-entry p,
.saas-section-heading p { margin: 0; color: var(--text-secondary); }
.dashboard-admin-entry { margin-top: 24px; }
.dashboard-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.saas-section-heading { margin-bottom: 18px; }
.quiet-link { color: var(--accent); font-size: 13px; font-weight: 680; text-decoration: none; }
.case-list { display: grid; }
.case-list-item {
  min-width: 0;
  min-height: 68px;
  padding: 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
}
.case-list-item:first-child { border-top: 0; }
.case-list-item > span:first-child { min-width: 0; display: grid; gap: 4px; }
.case-list-item small,
.case-list-meta time { color: var(--text-secondary); font-size: 12px; }
.case-list-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.saas-empty-state { padding: 22px 0; color: var(--text-secondary); }
.saas-empty-state p { margin: 6px 0 0; }

.settings-page .settings-content { width: min(100%, 980px); }
.settings-page .settings-content:has(#subscription-title) { width: min(100%, 1180px); }
.settings-form { display: grid; gap: 20px; }
.settings-form-section { box-shadow: none; }
.settings-form-section h3 { margin: 0 0 18px; }
.settings-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-form [aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.settings-field-error { margin: 0; color: var(--danger); font-size: 12px; font-weight: 600; line-height: 1.45; }
.settings-span-2 { grid-column: 1 / -1; }
.settings-checkbox { min-height: 44px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.settings-checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }
[data-billing-address-fields] { margin-top: 16px; }
.settings-form-actions { display: flex; justify-content: flex-end; }
.company-profile-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.company-profile-heading > div { min-width: 0; }
.company-profile-heading .button { flex: 0 0 auto; }
.company-profile-view { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.company-profile-group,
.company-profile-incomplete { padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.company-profile-group h3 { margin: 0 0 14px; }
.company-profile-group dl { margin: 0; display: grid; gap: 11px; }
.company-profile-group dl > div { display: grid; grid-template-columns: minmax(115px, .75fr) minmax(0, 1.25fr); gap: 12px; }
.company-profile-group dt { color: var(--text-secondary); font-size: 12px; font-weight: 680; }
.company-profile-group dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.company-profile-group p,
.company-profile-incomplete p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.company-profile-incomplete { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-info-list { display: grid; gap: 12px; }
.settings-info-list article {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.settings-info-list h3 { margin: 0 0 4px; }
.settings-info-list p { margin: 0; color: var(--text-secondary); }
.settings-status {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 720;
  white-space: nowrap;
}
.settings-status.is-active { background: var(--accent-soft); color: var(--accent); }
.settings-label { color: var(--text-secondary); font-size: 12px; font-weight: 680; }
.subscription-summary { padding-block: 22px; border-color: color-mix(in srgb, var(--accent) 22%, var(--border)); background: color-mix(in srgb, var(--accent) 3%, var(--surface)); }
.subscription-summary h3 { margin: 5px 0; font-size: 27px; letter-spacing: -0.02em; }
.subscription-summary p { margin: 0; color: var(--text-secondary); }
.current-plan-price { display: block; margin: 0 0 7px; font-size: 16px; }
.subscription-summary .subscription-trial-remaining { margin-top: 9px; color: var(--text-primary); font-weight: 680; }
.subscription-summary .subscription-trial-end { margin-top: 8px; font-size: 12px; }
.subscription-usage-section { margin-top: 18px; }
.subscription-usage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.subscription-usage-grid article { min-width: 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.subscription-usage-grid span { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 680; }
.subscription-usage-grid strong { display: block; margin-top: 7px; font-size: 18px; }
.entitlement-list { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; list-style: none; }
.entitlement-list li { display: flex; align-items: center; gap: 9px; }
.entitlement-list li > span:first-child { color: var(--accent); font-weight: 750; }
.saas-info-note { margin-top: 20px; box-shadow: none; background: var(--surface-subtle); }
.saas-info-note p { margin: 6px 0 0; color: var(--text-secondary); }
.active-addon-list { margin: 10px 0 0; padding: 0; display: grid; gap: 8px; list-style: none; }
.active-addon-list li { display: grid; gap: 3px; }
.active-addon-list span { color: var(--text-secondary); font-size: 12px; }
.commercial-section-heading { margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.commercial-section-heading h3 { margin: 0; }
.commercial-section-heading p { margin: 5px 0 0; color: var(--text-secondary); line-height: 1.5; }
.billing-interval-toggle { flex: 0 0 auto; padding: 4px; display: inline-flex; gap: 3px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-subtle); }
.billing-interval-toggle button { min-height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.billing-interval-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-soft); }
.billing-interval-toggle button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.commercial-plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.commercial-plan-card { min-width: 0; padding: 17px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.commercial-plan-card.is-recommended { border-color: var(--accent); }
.commercial-plan-title { min-height: 30px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.commercial-plan-title h4 { margin: 2px 0 0; font-size: 17px; }
.commercial-plan-price { min-height: 36px; margin-top: 9px; display: block; font-size: 15px; line-height: 1.35; }
.commercial-plan-card .commercial-plan-audience { min-height: 52px; margin: 5px 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }
.commercial-trial-copy { display: block; color: var(--text-secondary); font-size: 11px; font-weight: 680; }
.commercial-plan-metrics { margin: 13px 0 0; padding: 13px 0 0; display: grid; gap: 7px; border-top: 1px solid var(--border); }
.commercial-plan-metrics > div,
.commercial-plan-features li { display: flex; justify-content: space-between; gap: 9px; font-size: 11px; }
.commercial-plan-metrics dt,
.commercial-plan-metrics dd { margin: 0; }
.commercial-plan-metrics dt,
.commercial-plan-features span { color: var(--text-secondary); }
.commercial-plan-metrics dd,
.commercial-plan-features strong { text-align: right; }
.commercial-plan-features { margin: 11px 0 0; padding: 11px 0 0; display: grid; gap: 7px; border-top: 1px solid var(--border); list-style: none; }
.active-addon-panel { margin-bottom: 18px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface-subtle); }
.active-addon-panel h4,
.commercial-addon-section > h4 { margin: 0 0 8px; }
.active-addon-panel p { margin: 0; color: var(--text-secondary); }
.commercial-addon-grid { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; list-style: none; }
.commercial-addon-grid > li { min-width: 0; padding: 13px 15px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.commercial-addon-title { min-width: 0; }
.commercial-addon-price { font-size: 12px; font-weight: 700; white-space: nowrap; }
.commercial-addon-grid p { min-width: 0; margin: 0; overflow: hidden; color: var(--text-secondary); font-size: 12px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.commercial-addon-status { justify-self: end; }
.commercial-no-purchase { margin: 13px 0 0; color: var(--text-secondary); font-size: 12px; }
.billing-cycle-summary { margin-bottom: 16px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.billing-cycle-summary span { color: var(--text-secondary); font-size: 12px; font-weight: 680; }
.billing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.billing-grid address { color: var(--text-secondary); font-style: normal; line-height: 1.65; }
.branding-panel {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(240px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.branding-preview {
  min-height: 160px;
  padding: 18px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.branding-preview img { display: block; max-width: 100%; max-height: 150px; object-fit: contain; }
.branding-empty { color: var(--text-secondary); text-align: center; }
.branding-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.branding-controls p { flex-basis: 100%; margin: 0 0 4px; color: var(--text-secondary); }
.branding-upload { position: relative; overflow: hidden; cursor: pointer; }
.branding-upload input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.branding-upload:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.account-section-navigation { width: fit-content; max-width: 100%; margin-bottom: 22px; padding: 5px; display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.account-section-link { min-height: 42px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 9px; color: var(--text-secondary); font-size: 13px; font-weight: 680; text-decoration: none; white-space: nowrap; }
.account-section-link:hover,
.account-section-link:focus-visible { background: var(--surface-subtle); color: var(--text-primary); }
.account-section-link.is-active { background: var(--accent-soft); color: var(--accent); }
.account-section-content { width: min(100%, 860px); }
.account-card { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-soft); }
.account-card .settings-form { max-width: 620px; }
.field-hint { margin: -8px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.compact-security-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.compact-security-form .auth-field { flex: 1 1 240px; }
.account-security-section { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.account-security-section > h3 { margin: 0 0 12px; }
.account-section-heading { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.account-section-heading h3 { margin: 0; }
.account-section-heading p { margin: 5px 0 0; color: var(--text-secondary); }
.two-factor-status-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.two-factor-status-header h2 { margin: 0; }
.two-factor-status-header p { margin: 6px 0 0; color: var(--text-secondary); }
.two-factor-status-header .settings-status { flex: 0 0 auto; margin-top: 2px; }
.two-factor-introduction { margin-top: 20px; }
.two-factor-introduction > h3 { margin: 0 0 8px; font-size: 17px; }
.two-factor-introduction > p { margin: 0 0 12px; color: var(--text-secondary); line-height: 1.55; }
.two-factor-introduction > .button { margin-top: 14px; }
.security-info-note { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text-primary) !important; font-size: 13px; }
.security-section-copy { margin: 0 0 14px; color: var(--text-secondary); line-height: 1.55; }
.security-help { margin: 12px 0; }
.security-help summary { width: fit-content; cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 680; }
.security-help summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); outline-offset: 3px; border-radius: 4px; }
.security-help p { margin: 10px 0 0; color: var(--text-secondary); line-height: 1.55; }
.security-help ul { margin: 10px 0 0; padding-left: 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.contextual-reauth { margin: 16px 0; padding: 16px; border: 1px solid var(--accent); border-radius: var(--radius-md); background: var(--accent-soft); }
.contextual-reauth h3 { margin: 0; font-size: 16px; }
.contextual-reauth p { margin: 5px 0 14px; color: var(--text-secondary); }
.contextual-reauth .form-error,
.contextual-reauth .form-success { margin-top: 12px; }
.account-session-panel { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.security-setup-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.security-setup-panel:focus-visible,
.security-recovery:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); outline-offset: 4px; }
.security-recovery { margin: 14px 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted); }
.security-action-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.totp-setup-intro { margin: 12px 0 16px; color: var(--text-secondary); }
.totp-setup-steps { margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 7px 18px; list-style-position: inside; color: var(--text-secondary); font-size: 12px; }
.totp-setup-methods { display: grid; grid-template-columns: minmax(190px, 0.65fr) minmax(260px, 1.35fr); gap: 18px; align-items: start; }
.totp-qr-panel, .totp-manual-panel { min-width: 0; }
.totp-qr-panel h3, .totp-manual-panel h3 { margin: 0 0 10px; font-size: 15px; }
.totp-qr-code { width: min(100%, 210px); height: auto; display: block; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.totp-manual-panel { display: grid; justify-items: start; gap: 10px; }
.totp-manual-panel code { max-width: 100%; padding: 10px 12px; display: block; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13px; letter-spacing: 0.06em; }
.totp-authenticator-link { color: var(--text-secondary); font-size: 12px; font-weight: 650; text-underline-offset: 3px; }
.totp-authenticator-help { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.totp-authenticator-help p { margin: 10px 0 6px; color: var(--text-secondary); }
.totp-authenticator-help ul { margin: 0; padding-left: 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.totp-confirm-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.security-confirm-action { margin-top: 12px; }
.security-sensitive-section { border-top-color: color-mix(in srgb, var(--danger) 28%, var(--border)); }
.security-sensitive-section h3 { color: var(--danger); }
.security-recovery ul { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 16px; padding-left: 22px; }
.security-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.security-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.security-list li > span { display: grid; gap: 3px; }
.security-list li > span:last-child { justify-items: end; }
.security-list small, .security-list time { color: var(--text-secondary); font-size: 12px; }
.account-session-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.account-session-heading h2 { min-width: 0; margin: 0; }
.account-session-heading .settings-status { flex: 0 0 auto; margin: 1px 0 0; }
.account-session-copy { margin: 14px 0 0; color: var(--text-secondary); line-height: 1.55; }
.account-session-note { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; line-height: 1.5; }

/* Compact administration pages use the available laptop viewport without
   reducing the touch spacing used by tablet and mobile layouts. */
@media (min-width: 901px) {
  .app-shell.is-settings-page .main-content { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .settings-page { padding-top: 30px; }
  .settings-page > .saas-page-header { margin-bottom: 18px; }
  .settings-page .admin-section-heading { margin-bottom: 14px; }
  .settings-page .settings-info-list { gap: 8px; }
  .settings-page .settings-info-list article { padding: 14px 16px; gap: 16px; }
  .settings-page .subscription-summary,
  .settings-page .subscription-summary + .settings-form-section,
  .settings-page .billing-grid .settings-form-section,
  .settings-page .saas-info-note { padding: 16px 18px; }
  .settings-page .subscription-summary + .settings-form-section { margin-top: 14px; }
  .settings-page .subscription-usage-section { margin-top: 14px; }
  .settings-page .entitlement-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
  .settings-page .saas-info-note { margin-top: 14px; }
  .settings-page .saas-empty-state { padding-block: 10px; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .app-shell.has-saas-navigation .brand-name { display: none; }
  .app-shell.has-saas-navigation .app-header { gap: 7px; padding-inline: 14px; }
  .app-shell.has-saas-navigation [data-saas-navigation] { margin-left: 5px; }
  .app-shell.has-saas-navigation .saas-navigation-desktop { gap: 10px; }
  .app-shell.has-saas-navigation .saas-nav-link { padding-inline: 9px; }
  .app-shell.has-saas-navigation .header-actions { gap: 6px; }
  .app-shell.has-saas-navigation .header-preferences { padding-right: 6px; }
  .app-shell.has-saas-navigation .account-menu-trigger { max-width: 142px; }
  .commercial-plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-header { min-height: 60px; flex-wrap: nowrap; }
  .app-shell.has-saas-navigation .main-content { min-height: calc(100vh - 61px); }
  .app-shell.has-saas-navigation .header-actions { display: none; }
  .app-shell.has-saas-navigation [data-saas-navigation] { margin-left: auto; flex: 0 0 auto; }
  .saas-navigation-desktop { display: none; }
  .saas-navigation-shell { padding: 0; }
  .saas-mobile-trigger {
    min-height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 680;
  }
  .saas-mobile-backdrop { position: fixed; z-index: 89; inset: 0; display: block; background: var(--overlay-background); }
  .saas-mobile-navigation {
    position: fixed;
    z-index: 90;
    inset: 0 0 0 auto;
    width: min(88vw, 360px);
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    display: block;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-dialog);
  }
  .saas-mobile-heading { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .saas-mobile-heading button { width: 44px; height: 44px; border: 0; border-radius: 11px; background: var(--surface-subtle); cursor: pointer; font-size: 24px; }
  .saas-mobile-navigation nav { display: grid; gap: 5px; }
  .saas-mobile-navigation .saas-nav-link { min-height: 48px; }
  .saas-mobile-group { padding: 16px 0; border-top: 1px solid var(--border); }
  .saas-mobile-group:first-of-type { margin-top: 10px; border-top: 0; }
  .saas-mobile-group h2 { margin: 0 0 10px; color: var(--text-secondary); font-size: 11px; font-weight: 760; letter-spacing: 0.08em; text-transform: uppercase; }
  .saas-mobile-group-label { margin: 10px 0 7px; color: var(--text-secondary); font-size: 12px; font-weight: 680; }
  .saas-mobile-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  .saas-mobile-option { min-height: 44px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-primary); cursor: pointer; font: inherit; font-size: 12px; font-weight: 650; }
  .saas-mobile-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .saas-mobile-account { display: grid; gap: 5px; }
  .saas-mobile-logout { width: 100%; border: 0; background: transparent; color: var(--danger); cursor: pointer; font: inherit; text-align: left; }
  .saas-mobile-admin-group { margin-top: 8px; padding-top: 8px; }
  .billing-grid { grid-template-columns: 1fr; }
  .subscription-usage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .commercial-plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .compact-security-form, .security-list li { align-items: stretch; flex-direction: column; }
  .compact-security-form .button, .security-list .button { width: 100%; }
  .security-list li > span:last-child { justify-items: start; }
  .security-recovery ul { grid-template-columns: 1fr; }
  .security-action-grid { grid-template-columns: 1fr; }
  .totp-setup-methods { grid-template-columns: 1fr; }
  .totp-qr-code { width: min(100%, 230px); }
  .totp-manual-panel .button { width: 100%; }
  .two-factor-status-header { gap: 12px; }
  .account-two-factor { padding-inline: 18px; }
}

@media (max-width: 600px) {
  .saas-mobile-options { grid-template-columns: 1fr; }
  .saas-page { padding-top: 28px; }
  .saas-page-header-actions,
  .saas-section-heading,
  .dashboard-primary-action,
  .dashboard-admin-entry,
  .subscription-summary,
  .settings-info-list article { align-items: stretch; flex-direction: column; }
  .saas-page-header-actions .button,
  .dashboard-primary-action .button,
  .dashboard-admin-entry .button { width: 100%; }
  .dashboard-admin-actions { width: 100%; display: grid; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .company-profile-view { grid-template-columns: 1fr; }
  .company-profile-heading,
  .company-profile-incomplete { align-items: stretch; flex-direction: column; }
  .company-profile-heading .button,
  .company-profile-incomplete .button { width: 100%; }
  .company-profile-group dl > div { grid-template-columns: 1fr; gap: 3px; }
  .subscription-usage-grid { grid-template-columns: 1fr; }
  .entitlement-list { grid-template-columns: 1fr; }
  .commercial-section-heading { display: grid; }
  .billing-interval-toggle { width: 100%; }
  .billing-interval-toggle button { flex: 1 1 50%; }
  .commercial-plan-grid,
  .commercial-addon-grid { grid-template-columns: 1fr; }
  .commercial-plan-card .commercial-plan-audience { min-height: 0; }
  .commercial-addon-grid > li { grid-template-columns: 1fr; }
  .commercial-addon-status { justify-self: start; }
  .commercial-addon-grid p { white-space: normal; }
  .settings-span-2 { grid-column: auto; }
  .account-section-navigation { width: 100%; }
  .account-section-link { flex: 1 1 calc(50% - 4px); justify-content: center; text-align: center; }
  .case-list-item { align-items: flex-start; flex-direction: column; }
  .case-list-meta { width: 100%; justify-content: space-between; }
  .settings-form-actions { flex-direction: column-reverse; }
  .settings-form-actions .button { width: 100%; }
  .branding-panel { grid-template-columns: 1fr; padding: 16px; }
  .branding-controls .button { width: 100%; }
}

@media (max-width: 700px) {
  .app-shell.has-saas-navigation .main-content { min-height: calc(100vh - 61px); }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .app-header { padding-inline: 16px; gap: 8px; }
  .brand { gap: 8px; }
  .brand-name { max-width: 120px; }
  .saas-navigation-desktop { gap: 2px; }
  .saas-nav-link { padding-inline: 9px; }
  .header-actions { gap: 6px; }
  .header-preferences { padding-right: 6px; }
  .account-menu-trigger { max-width: 150px; }
}

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