/* 16 public + Owner presentation family for 14. Product structure and logic stay in 14. */
.admin-shell,
body.sop-v3-active {
  --owner-ui-surface: #ffffff;
  --owner-ui-subtle: #ecece8;
  --owner-ui-hover: #e9e9e4;
  --owner-ui-ink: #11110f;
  --owner-ui-ink-2: #5e5e59;
  --owner-ui-ink-3: #85857d;
  --owner-ui-line: #d8d8d2;
  --owner-ui-accent: #e84a2a;
  --owner-ui-accent-soft: #fff0e9;
  --owner-ui-danger: #a12727;
  --owner-ui-danger-soft: #fff1f1;
}

html[data-theme="dark"] :is(.admin-shell, body.sop-v3-active) {
  --owner-ui-surface: #0a0a0a;
  --owner-ui-subtle: #111111;
  --owner-ui-hover: #161616;
  --owner-ui-ink: #ffffff;
  --owner-ui-ink-2: #b8b8b8;
  --owner-ui-ink-3: #7a7a7a;
  --owner-ui-line: #242424;
  --owner-ui-accent: #f45724;
  --owner-ui-accent-soft: #201008;
  --owner-ui-danger: #ff7568;
  --owner-ui-danger-soft: #25100f;
}

/* Shared 116 x 44 LIGHT / DARK segmented control. */
.owner-ui-theme-toggle {
  position: relative;
  width: 116px;
  height: 44px;
  min-height: 44px;
  flex: 0 0 116px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px;
  border: 1px solid var(--owner-ui-line);
  border-radius: 3px;
  background: var(--owner-ui-surface);
  color: var(--owner-ui-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--owner-ui-ink) 4%, transparent), 3px 3px 0 var(--owner-ui-line);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.owner-ui-theme-toggle:hover { border-color: var(--owner-ui-accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--owner-ui-accent) 18%, transparent), 3px 3px 0 color-mix(in srgb, var(--owner-ui-accent) 38%, var(--owner-ui-line)); }
.owner-ui-theme-toggle:active { transform: translate(1px, 1px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--owner-ui-accent) 28%, transparent), 1px 1px 0 var(--owner-ui-line); }
.owner-ui-theme-toggle:focus-visible { outline: 2px solid var(--owner-ui-accent); outline-offset: 3px; }
.owner-ui-theme-toggle [data-theme-scale] { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr 12px 1fr; align-items: center; gap: 2px; }
.owner-ui-theme-toggle [data-theme-mode] { min-width: 0; height: 32px; display: grid; place-items: center; color: var(--owner-ui-ink-3); font: 750 9px/1 ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.owner-ui-theme-toggle [data-theme-separator] { position: relative; width: 4px; height: 4px; justify-self: center; background: var(--owner-ui-accent); box-shadow: 0 -7px 0 color-mix(in srgb, var(--owner-ui-ink) 22%, transparent), 0 7px 0 color-mix(in srgb, var(--owner-ui-ink) 22%, transparent); }
.owner-ui-theme-toggle [data-theme-glyph] { display: none; }
.owner-ui-theme-toggle[data-theme-state="light"] [data-theme-mode="light"],
.owner-ui-theme-toggle[data-theme-state="dark"] [data-theme-mode="dark"] { background: var(--owner-ui-ink); box-shadow: inset 0 -3px var(--owner-ui-accent); color: var(--owner-ui-surface); }

/* Primary action: hard-edge Owner CTA family. */
:is(.admin-login-form button, .admin-filters button, .admin-button:not(.admin-button-secondary), body.sop-v3-active .sop-v3-button:not(.secondary)) {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid var(--owner-ui-accent);
  border-radius: 0;
  background: var(--owner-ui-accent);
  color: #ffffff;
  box-shadow: 5px 5px 0 color-mix(in srgb, var(--owner-ui-accent) 22%, transparent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
  transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
:is(.admin-login-form button, .admin-filters button, .admin-button:not(.admin-button-secondary), body.sop-v3-active .sop-v3-button:not(.secondary)):hover:not(:disabled) { border-color: var(--owner-ui-accent); background: color-mix(in srgb, var(--owner-ui-accent) 86%, #000); }
:is(.admin-login-form button, .admin-filters button, .admin-button:not(.admin-button-secondary), body.sop-v3-active .sop-v3-button:not(.secondary)):active:not(:disabled) { opacity: .72; }
:is(.admin-login-form button, .admin-filters button, .admin-button:not(.admin-button-secondary), body.sop-v3-active .sop-v3-button:not(.secondary)):focus-visible { outline: 3px solid var(--owner-ui-accent); outline-offset: 3px; }
:is(.admin-login-form button, .admin-filters button, .admin-button:not(.admin-button-secondary), body.sop-v3-active .sop-v3-button:not(.secondary)):disabled {
  border-color: var(--owner-ui-line);
  background: var(--owner-ui-subtle);
  color: var(--owner-ui-ink-3);
  box-shadow: none;
  cursor: not-allowed;
  opacity: .72;
}
body.sop-v3-active .sop-v3-button[data-state="sending"],
body.sop-v3-active .sop-v3-button[data-state="sending"]:disabled { border-color: var(--owner-ui-accent); background: color-mix(in srgb, var(--owner-ui-accent) 82%, #000); color: #fff; cursor: progress; }

/* Quiet actions remain neutral; orange is reserved for hover/focus. */
:is(.admin-button-secondary, .admin-link-button, body.sop-v3-active .sop-v3-button.secondary) {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--owner-ui-line);
  border-radius: 0;
  background: var(--owner-ui-surface);
  color: var(--owner-ui-ink-2);
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 720;
}
:is(.admin-button-secondary, .admin-link-button, body.sop-v3-active .sop-v3-button.secondary):hover:not(:disabled) { border-color: var(--owner-ui-accent); background: var(--owner-ui-subtle); color: var(--owner-ui-ink); }
:is(.admin-button-secondary, .admin-link-button, body.sop-v3-active .sop-v3-button.secondary):focus-visible { outline: 3px solid var(--owner-ui-accent); outline-offset: 3px; }
:is(.admin-button-secondary, .admin-link-button, body.sop-v3-active .sop-v3-button.secondary):disabled { border-color: var(--owner-ui-line); background: var(--owner-ui-subtle); color: var(--owner-ui-ink-3); cursor: not-allowed; opacity: .72; }

/* Destructive actions share the same hard-edge geometry without competing with the primary CTA. */
:is(.admin-button-danger-secondary, .admin-danger-button) {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--owner-ui-danger);
  border-radius: 0;
  background: var(--owner-ui-surface);
  color: var(--owner-ui-danger);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--owner-ui-danger) 18%, transparent);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 760;
}
.admin-button-danger-secondary:hover:not(:disabled) { background: var(--owner-ui-danger-soft); }
.admin-danger-button { min-height: 48px; padding-inline: 18px; background: var(--owner-ui-danger); color: #ffffff; font-size: 13px; }
.admin-danger-button:hover:not(:disabled) { background: color-mix(in srgb, var(--owner-ui-danger) 84%, #000); }
:is(.admin-button-danger-secondary, .admin-danger-button):focus-visible { outline: 3px solid var(--owner-ui-danger); outline-offset: 3px; }
:is(.admin-button-danger-secondary, .admin-danger-button):disabled { border-color: var(--owner-ui-line); background: var(--owner-ui-subtle); color: var(--owner-ui-ink-3); box-shadow: none; cursor: not-allowed; opacity: .72; }

.admin-danger-zone { display: grid; gap: 12px; border-color: color-mix(in srgb, var(--owner-ui-danger) 45%, var(--owner-ui-line)); }
.admin-danger-zone :is(h2, p) { margin: 0; }
.admin-danger-zone > :is(.admin-danger-button, .admin-delete-confirmation) { justify-self: start; }
.admin-delete-confirmation { margin-top: 0; }

/* Panels and cards use the flat 1px Owner grid language. */
.admin-card { border: 1px solid var(--owner-ui-line); border-radius: 0; background: var(--owner-ui-surface); box-shadow: none; }
body.sop-v3-active .sop-v3-card { border: 1px solid var(--owner-ui-line); border-radius: 0; padding: clamp(20px, 4vw, 34px); background: var(--owner-ui-surface); box-shadow: 12px 12px 0 color-mix(in srgb, var(--owner-ui-accent) 10%, transparent); }
:is(.admin-case-summary, .admin-delivery-form, .admin-delivery-record, .admin-file,
body.sop-v3-active .sop-v3-upload-section, body.sop-v3-active .sop-v3-plan,
body.sop-v3-active .sop-v3-job, body.sop-v3-active .sop-v3-case-number) { border-radius: 0; background: var(--owner-ui-subtle); }
body.sop-v3-active :is(.sop-v3-modal-panel, .sop-v3-image-preview-panel) { border-radius: 0; box-shadow: 16px 16px 0 color-mix(in srgb, var(--owner-ui-accent) 13%, transparent); }

/* Form controls follow Owner's 44px square, subtle-surface controls. */
:is(.admin-shell, body.sop-v3-active) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 44px;
  border: 1px solid var(--owner-ui-line);
  border-radius: 0;
  background: var(--owner-ui-subtle);
  color: var(--owner-ui-ink);
  font: inherit;
}
:is(.admin-shell, body.sop-v3-active) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus-visible { border-color: var(--owner-ui-accent); outline: 3px solid var(--owner-ui-accent); outline-offset: 2px; box-shadow: none; }
:is(.admin-shell, body.sop-v3-active) :is(input, select, textarea):disabled { border-color: var(--owner-ui-line); background: var(--owner-ui-subtle); color: var(--owner-ui-ink-3); opacity: .72; }
body.sop-v3-active input[type="file"]::file-selector-button { border: 1px solid var(--owner-ui-line); border-radius: 0; background: var(--owner-ui-surface); color: var(--owner-ui-ink); }
body.sop-v3-active input[type="file"]::file-selector-button:hover { border-color: var(--owner-ui-accent); background: var(--owner-ui-hover); }

/* Progress, navigation, accordion and table active states. */
body.sop-v3-active .sop-v3-progress { gap: 1px; padding: 4px; border: 1px solid var(--owner-ui-line); background: var(--owner-ui-subtle); }
body.sop-v3-active .sop-v3-progress > span { min-height: 42px; display: grid; align-items: center; padding-inline: 12px; background: var(--owner-ui-surface); }
body.sop-v3-active .sop-v3-progress .active { color: var(--owner-ui-ink); box-shadow: inset 0 -3px var(--owner-ui-accent), 3px 3px 0 color-mix(in srgb, var(--owner-ui-accent) 15%, transparent); }
body.sop-v3-active .sop-v3-progress .active::after { right: auto; bottom: 9px; left: 6px; width: 5px; height: 5px; box-shadow: 2px 2px 0 color-mix(in srgb, var(--owner-ui-accent) 25%, transparent); }
:is(.admin-nav a, .admin-detail-top a, .admin-table a, body.sop-v3-active .sop-v3-case-item h4 button):focus-visible { outline: 3px solid var(--owner-ui-accent); outline-offset: 3px; }
:is(.admin-nav a, .admin-detail-top a, .admin-table a)[aria-current="page"] { background: var(--owner-ui-surface); box-shadow: inset 0 -3px var(--owner-ui-accent); color: var(--owner-ui-ink); }
.admin-table tbody tr:hover { box-shadow: inset 4px 0 var(--owner-ui-accent); }
body.sop-v3-active .sop-v3-case-item h4 button[aria-expanded="true"] { box-shadow: inset 3px 0 var(--owner-ui-accent); color: var(--owner-ui-ink); }

/* Step 2 required-data panel: stable rhythm without changing form structure. */
body.sop-v3-active .sop-v3-upload-section {
  min-width: 0;
  padding: clamp(24px, 3.2vw, 32px);
  border: 1px solid var(--owner-ui-line);
  background: color-mix(in srgb, var(--owner-ui-subtle) 78%, var(--owner-ui-surface));
}
body.sop-v3-active .sop-v3-upload-section > .sop-v3-section-kicker {
  margin: 0 0 24px;
  padding: 0 0 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--owner-ui-line) 72%, transparent);
}
body.sop-v3-active .sop-v3-upload-section > :is(.sop-v3-file-control, .sop-v3-field, .sop-v3-progressive-control) { min-width: 0; }
body.sop-v3-active .sop-v3-upload-section > .sop-v3-field { margin: 26px 0 0; }
body.sop-v3-active .sop-v3-upload-section .sop-v3-field {
  gap: 9px;
  line-height: 1.55;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-field :is(input, select, textarea) {
  min-width: 0;
  padding-inline: 14px;
  line-height: 1.5;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-field :is(input, textarea)::placeholder {
  color: var(--owner-ui-ink-3);
  opacity: .9;
}
body.sop-v3-active .sop-v3-upload-section :is(.sop-v3-field small, .sop-v3-file-summary, .sop-v3-file-empty) {
  max-width: 100%;
  color: var(--owner-ui-ink-2);
  font-size: .875rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-picker { margin: 0; }
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-picker-label {
  min-height: 44px;
  margin: 3px 0 0;
  border-radius: 0;
  padding: 9px 14px;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-summary {
  min-height: 0;
  margin: 16px 0 0;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-summary-label { margin-bottom: 8px; line-height: 1.5; }
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-list { gap: 0; }
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-row {
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 12px 0;
  border-top-color: color-mix(in srgb, var(--owner-ui-line) 72%, transparent);
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-row:last-child { padding-bottom: 0; }
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-name {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  color: var(--owner-ui-ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
}
body.sop-v3-active .sop-v3-upload-section .sop-v3-file-remove {
  width: 44px;
  min-width: 44px;
  justify-self: end;
  padding-inline: 4px;
}
body.sop-v3-active .sop-v3-upload-section > .sop-v3-progressive-control {
  margin-top: 28px;
  padding-top: 22px;
  border-top-color: color-mix(in srgb, var(--owner-ui-line) 72%, transparent);
}
body.sop-v3-active .sop-v3-upload-section > .sop-v3-progressive-control > .sop-v3-check {
  min-height: 52px;
  align-items: start;
  gap: 12px;
  margin: 0;
  padding: 7px 0 9px;
  line-height: 1.6;
}
body.sop-v3-active .sop-v3-upload-section > .sop-v3-progressive-control > .sop-v3-check input[type="checkbox"] { margin-top: 2px; }
body.sop-v3-active .sop-v3-upload-section > .sop-v3-progressive-control > #optional-job-details {
  min-width: 0;
  margin-top: 18px;
  padding-top: 4px;
}

@media (max-width: 640px) {
  .owner-ui-theme-toggle { width: 44px; height: 44px; min-height: 44px; flex-basis: 44px; padding: 0; box-shadow: 2px 2px 0 var(--owner-ui-line); }
  .owner-ui-theme-toggle [data-theme-scale] { display: none; }
  .owner-ui-theme-toggle [data-theme-glyph] { position: relative; width: 22px; height: 22px; display: block; border: 1px solid var(--owner-ui-ink); background: linear-gradient(90deg, var(--owner-ui-ink) 0 50%, var(--owner-ui-surface) 50% 100%); }
  .owner-ui-theme-toggle [data-theme-glyph]::before,
  .owner-ui-theme-toggle [data-theme-glyph]::after { position: absolute; width: 4px; height: 4px; background: var(--owner-ui-accent); content: ""; }
  .owner-ui-theme-toggle [data-theme-glyph]::before { top: -4px; right: -4px; }
  .owner-ui-theme-toggle [data-theme-glyph]::after { bottom: -4px; left: -4px; }
  .owner-ui-theme-toggle [data-theme-glyph] > i { position: absolute; top: 5px; bottom: 5px; left: 50%; width: 1px; background: var(--owner-ui-accent); transform: translateX(-50%); }
  .owner-ui-theme-toggle[data-theme-state="dark"] [data-theme-glyph] { background: linear-gradient(90deg, var(--owner-ui-surface) 0 50%, var(--owner-ui-ink) 50% 100%); }
  body.sop-v3-active .sop-v3-upload-section { padding: 22px 18px; }
  body.sop-v3-active .sop-v3-upload-section > .sop-v3-section-kicker { margin-bottom: 20px; padding-bottom: 12px; }
  body.sop-v3-active .sop-v3-upload-section > .sop-v3-field { margin-top: 22px; }
  body.sop-v3-active .sop-v3-upload-section .sop-v3-file-row { gap: 12px; }
  body.sop-v3-active .sop-v3-upload-section > .sop-v3-progressive-control { margin-top: 24px; padding-top: 18px; }
  body.sop-v3-active .sop-v3-card { padding: 20px 16px; box-shadow: 7px 7px 0 color-mix(in srgb, var(--owner-ui-accent) 10%, transparent); }
  body.sop-v3-active .sop-v3-progress > span { min-width: 0; padding-inline: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.owner-ui-theme-toggle, .admin-button, .admin-link-button, body.sop-v3-active .sop-v3-button) { transition: none; }
}
