/* Precision graphite for the inner pages. Loaded separately from the homepage;
   screen-only colors leave the original light theme and printed documents intact. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --theme-canvas: #0b1017;
    --theme-surface: #121a24;
    --theme-soft: #17212e;
    --theme-raised: #1c2938;
    --theme-inset: #0d141e;
    --theme-ink: #f0f4fa;
    --theme-muted: #a3afbe;
    --theme-line: #293545;
    --theme-line-alpha: rgba(151, 175, 205, .18);
    --theme-link: #8ebaff;
    --theme-accent-surface: #14273e;
    --theme-success: #8bd7b0;
    --theme-success-surface: #122e26;
    --theme-warning: #f2cd8c;
    --theme-warning-surface: #332919;
    --theme-danger: #ffa7b4;
    --theme-danger-surface: #34202a;
    --theme-glass: rgba(13, 20, 30, .94);
    --theme-glass-soft: rgba(23, 33, 46, .94);
    --action: #086bd7;
    --action-hover: #1173dc;
    --cx-canvas: var(--theme-canvas);
    --cx-surface: var(--theme-surface);
    --bs-body-color-rgb: 240, 244, 250;
    --bs-body-bg-rgb: 18, 26, 36;
    --bs-secondary-color-rgb: 163, 175, 190;
    --bs-secondary-bg-rgb: 23, 33, 46;
    --bs-tertiary-bg: var(--theme-raised);
    --bs-tertiary-bg-rgb: 28, 41, 56;
    --bs-link-color-rgb: 142, 186, 255;
    --bs-link-hover-color: #b5d2ff;
    --bs-link-hover-color-rgb: 181, 210, 255;
    --bs-primary-text-emphasis: var(--theme-link);
    --bs-primary-bg-subtle: var(--theme-accent-surface);
    --bs-primary-border-subtle: #355879;
    --bs-border-color-translucent: var(--theme-line-alpha);
    --focus-ring: 0 0 0 3px rgba(142, 186, 255, .25);
    --theme-panel-shadow: inset 0 1px 0 rgba(215, 232, 255, .035), 0 12px 32px rgba(0, 0, 0, .13);
  }

  body.inner-page-theme {
    background: radial-gradient(ellipse 75% 34rem at 85% -14rem, rgba(27, 87, 150, .14), transparent 78%), var(--theme-canvas);
    color: var(--theme-ink);
  }
  .inner-page-theme :is(.fabrication-page, .employee-main) { background: transparent; }
  .inner-page-theme :is(.fabrication-page, .public-content, .editorial) {
    --fab-blue: var(--action);
    --public-action: var(--action);
    --editorial-blue: var(--action);
  }

  /* Quiet chrome: the active page and primary action carry the blue. */
  .inner-page-theme .apple-nav {
    background: radial-gradient(ellipse at 76% -120%, rgba(27, 87, 150, .18), transparent 70%), #0d131c;
    border-bottom-color: var(--theme-line);
    box-shadow: none;
  }
  .inner-page-theme .apple-nav .apple-nav-link { color: #c1cad6; }
  .inner-page-theme .apple-nav .apple-nav-link:hover { color: #fff; }
  .inner-page-theme .apple-nav .apple-nav-link[aria-current="page"] {
    color: var(--theme-ink);
    text-decoration-color: #529cff;
    text-decoration-thickness: 2px;
  }
  .inner-page-theme .apple-nav .apple-nav-cta {
    color: #fff;
    background: var(--action);
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .13);
  }
  .inner-page-theme .apple-nav .apple-nav-cta:hover { background: var(--action-hover); }
  .inner-page-theme .customer-account-button { border-radius: 6px; background: var(--theme-surface); }
  .inner-page-theme .apple-nav .navbar-toggler { border-color: #5c6f86; border-radius: 6px; }
  .inner-page-theme .apple-footer { background: #0a0f16; border-top-color: var(--theme-line); }
  .inner-page-theme .apple-footer .footer-meta-row { border-color: var(--theme-line); }

  /* Open editorial layouts stay open. Depth is reserved for useful surfaces. */
  .inner-page-theme :is(.fab-section--soft, .fab-cta, .public-cta, .industry-cta, .editorial-next, .public-note) {
    border: 1px solid var(--theme-line);
    border-radius: 8px;
    background: var(--theme-surface);
    box-shadow: inset 0 1px 0 rgba(215, 232, 255, .035);
  }
  .inner-page-theme :is(.fab-cta, .public-cta, .industry-cta) {
    background: linear-gradient(115deg, #142335, var(--theme-surface) 72%);
    border-top-color: #355579;
  }
  .inner-page-theme :is(.fab-note, .public-note) { border-left: 2px solid #529cff; }
  .inner-page-theme .fab-material-profile .fab-note { border: 0; }
  .inner-page-theme :is(.fab-material-profile, .fab-route-column) { border-top-color: #3b506a; }
  .inner-page-theme :is(.fab-number, .fab-jumpnav span, .fab-thickness-values li, .public-eyebrow, .editorial-category) {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-variant-numeric: tabular-nums;
  }
  .inner-page-theme :is(.fab-hero__media img, .fab-material-gallery img, .fab-shop-split img, .public-service-hero .public-figure img, .public-service-details .public-figure img, .public-location .public-figure img) {
    border: 1px solid var(--theme-line);
    border-radius: 6px;
  }
  .inner-page-theme :is(.fab-jumpnav a:hover, .public-related a:hover, .public-directory a:hover) { background: rgba(142, 186, 255, .035); }
  .inner-page-theme :is(.fab-faq-list details[open], .public-faqs details[open]) { border-bottom-color: #49698c; }
  .inner-page-theme :is(.fab-faq-list details[open] summary, .public-faqs details[open] summary) { color: var(--theme-link); }

  .inner-page-theme :is(.fab-button, .public-content .public-button, .industry-button, .editorial .btn) {
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
  }
  .inner-page-theme :is(.fab-button--light, .public-content .public-button--light, .industry-button--light) {
    color: var(--theme-ink);
    background: var(--theme-raised);
    border-color: #465d78;
  }
  .inner-page-theme :is(.fab-button--light:hover, .public-content .public-button--light:hover, .industry-button--light:hover) {
    background: #263b52;
    border-color: #6486ad;
  }

  /* Table headers, row labels and data each have their own quiet level. */
  .inner-page-theme :is(.fab-table-wrap, .public-table-scroll) { border-radius: 6px; background: var(--theme-surface); }
  .inner-page-theme .fab-table thead th { background: #1b2a3d; color: var(--theme-ink); }
  .inner-page-theme .fab-table tbody th { background: #151f2c; }
  .inner-page-theme .fab-table td { background: #101822; }
  .inner-page-theme .fab-table tbody tr:hover > * { background: #1a293a; }
  .inner-page-theme .table { --bs-table-hover-bg: #1c2a3b; --bs-table-striped-bg: #151f2c; }
  .inner-page-theme .saved-quote-grand-total { border-top-color: #49698c; }

  /* Forms read as recessed controls; panels sit above the graphite canvas. */
  .inner-page-theme :is(.card-elev, .account-panel, .account-current-work, .customer-auth-card, .invoice-panel, .internal-surface, .employee-empty) {
    border-color: var(--theme-line);
    box-shadow: var(--theme-panel-shadow);
  }
  .inner-page-theme .section-tech { background: transparent; }
  .inner-page-theme :is(.form-control, .form-select, .input-group-text) {
    background-color: var(--theme-inset);
    border-color: #526983;
    color: var(--theme-ink);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
  }
  .inner-page-theme :is(.form-control:focus, .form-select:focus) {
    background-color: #101b29;
    border-color: var(--theme-link);
    box-shadow: var(--focus-ring);
  }
  .inner-page-theme :is(.form-control:disabled, .form-select:disabled) { background-color: var(--theme-soft); }
  .inner-page-theme .form-control:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px var(--theme-inset) inset; }
  .inner-page-theme .form-check-input:not(:checked) { border-color: #61748d; background-color: var(--theme-inset); }
  .inner-page-theme :is(.form-control, .form-select):is(.is-invalid, [aria-invalid="true"]) {
    border-color: var(--theme-danger);
  }
  .inner-page-theme :is(.form-control, .form-select):is(.is-invalid, [aria-invalid="true"]):focus {
    border-color: var(--theme-danger);
    box-shadow: 0 0 0 3px rgba(255, 167, 180, .2);
  }
  .inner-page-theme :is(.form-control, .form-select).is-valid { border-color: var(--theme-success); }
  .inner-page-theme :is(.form-control, .form-select).is-valid:focus {
    border-color: var(--theme-success);
    box-shadow: 0 0 0 3px rgba(139, 215, 176, .2);
  }
  .inner-page-theme .btn-primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
  .inner-page-theme :is(.btn-outline-primary, .btn-outline-secondary) {
    --bs-btn-color: #afc8e8;
    --bs-btn-border-color: #526c8a;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #213953;
    --bs-btn-hover-border-color: #7395bc;
    --bs-btn-active-bg: #213953;
  }
  .inner-page-theme :is(.dropdown-menu, .modal-content) { box-shadow: 0 16px 48px rgba(0, 0, 0, .4); }
  .inner-page-theme .modal-backdrop { --bs-backdrop-opacity: .7; }

  .inner-page-theme .employee-sidebar { background: #0d141e; border-right: 1px solid var(--theme-line); }
  .inner-page-theme .employee-nav-item { color: #adbcd0; }
  .inner-page-theme .employee-nav-item.active { color: #eaf3ff; border-color: #529cff; background: var(--theme-accent-surface); }
  .inner-page-theme .employee-nav-item:hover { background: #192638; color: #fff; }
  .inner-page-theme .cad-viewer-shell { background: radial-gradient(ellipse at top, #1d3046, var(--theme-inset) 75%); }
  .inner-page-theme .cad-step-viewer { background: radial-gradient(ellipse at top, #233c56, #111b28 75%); }

  /* These older staff fragments still have inline light backgrounds. */
  .inner-page-theme :is(#trav-loading-overlay, #nest-loading-overlay) { background: var(--theme-glass) !important; }
  .inner-page-theme.work-order-page :is(#wo-main-form .border.rounded.p-2, .border.rounded.p-2:has(> #add-job-form)) {
    background: var(--theme-soft) !important;
  }
  .inner-page-theme .employee-workspace .badge.rounded-pill[style*="color:#111"] {
    background: var(--theme-soft) !important;
    color: var(--theme-muted) !important;
    border-color: var(--theme-line) !important;
  }
  .inner-page-theme .employee-workspace .badge.rounded-pill[style*="color:#7a5b00"] {
    background: var(--theme-warning-surface) !important;
    color: var(--theme-warning) !important;
    border-color: #655332 !important;
  }
  .inner-page-theme .employee-workspace .badge.rounded-pill[style*="color:#0d6efd"] {
    background: var(--theme-accent-surface) !important;
    color: var(--theme-link) !important;
    border-color: #355879 !important;
  }
}
