/* Low-priority defaults: existing (unlayered) portal styles always take precedence.
   Load with the shared header. Screen only: certificate/document printing is unchanged. */
@layer ui-foundation {
  @media screen {
    :where(main button:not([class]):not(.birth-entry *):not(.template-page-toolbar *):not(.certificate-preparer-toolbar *), main input[type="submit"]:not([class]), main input[type="button"]:not([class])) {
      min-height:42px; padding:10px 15px; border:1px solid #0b5cab;
      border-radius:7px; background:#0b5cab; color:#fff;
      font:inherit; font-size:14px; font-weight:600; line-height:1.4;
      cursor:pointer;
    }
    :where(main button:not([class]):not(.birth-entry *):not(.template-page-toolbar *):not(.certificate-preparer-toolbar *), main input[type="submit"]:not([class]), main input[type="button"]:not([class])):hover:not(:disabled) { background:#084986; }
    :where(main button, main input, main select, main textarea):disabled { opacity:.6; cursor:not-allowed; }
    :where(main input:not([type]), main input[type="text"], main input[type="email"], main input[type="password"], main input[type="search"], main input[type="number"], main input[type="date"], main select, main textarea) {
      box-sizing:border-box; max-width:100%; min-height:42px; padding:9px 11px;
      border:1px solid #b9c9da; border-radius:7px; background:#fff; color:#243247;
      font:inherit; font-size:14px; line-height:1.5;
    }
    :where(main textarea) { min-height:100px; resize:vertical; }
    :where(main summary) {
      width:fit-content; max-width:100%; min-height:42px; box-sizing:border-box;
      padding:10px 14px; border:1px solid #c5d6e8; border-radius:7px;
      color:#074c91; background:#edf5ff; font-weight:600; cursor:pointer;
    }
    :where(main summary):hover { background:#dfeeff; }
    :where(main details[open]>summary) { margin-bottom:12px; }
    :where(main details>form) { display:grid; gap:12px; margin-top:12px; }
    :where(main details pre) { max-width:100%; overflow:auto; padding:12px; border:1px solid #dde5ef; border-radius:7px; background:#f6f8fc; white-space:pre-wrap; overflow-wrap:anywhere; }
    :where(a, button, input, select, textarea, summary):focus-visible { outline:3px solid #2674bc; outline-offset:3px; }
  }
}

/* Explicit action links keep ordinary navigation and inline prose as links. */
@media screen {
  .ui-section-description { display:none !important; }
  main button.ui-section-help-title,
  main button.ui-section-help-title:hover,
  main button.ui-section-help-title:active {
    display:inline; width:auto; min-height:0; margin:0; padding:0;
    border:0; border-radius:3px; background:transparent; color:inherit;
    font:inherit; text-align:inherit; cursor:default; box-shadow:none; transform:none;
  }
  main button.ui-section-help-title:hover { background:transparent; color:inherit; }
  main button.ui-section-help-title:focus-visible { outline:3px solid #2674bc; outline-offset:3px; }
  .ui-section-tooltip {
    position:fixed; inset:auto; margin:0; box-sizing:border-box;
    width:max-content; max-width:min(340px,calc(100vw - 24px));
    max-height:calc(100dvh - 24px); overflow:auto;
    padding:10px 12px; border:1px solid #c5d6e8; border-radius:8px;
    background:#fff; color:#243247; font:400 14px/1.5 var(--ui-font, sans-serif);
    overflow-wrap:anywhere; box-shadow:0 6px 20px #173c6226;
  }
  .ui-action { display:inline-flex; align-items:center; justify-content:center; min-height:40px; box-sizing:border-box; gap:7px; padding:9px 14px; border:1px solid #b9cfe7; border-radius:7px; background:#edf5ff; color:#074c91; font-size:14px; font-weight:600; line-height:1.4; text-decoration:none; }
  .ui-action:hover { background:#dcecff; border-color:#0b5cab; }
  .ui-action:focus-visible { outline:3px solid #2674bc; outline-offset:2px; }
  .ui-pagination { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-top:18px; }
  .staff-main .request-rejection-details>summary,
  .official-main .template-removal-disclosure>summary { padding:10px 14px; border:1px solid #e5bbb6; border-radius:7px; background:#fff4f2; color:#9b2921; }
  .staff-main .request-rejection-details>summary:hover,
  .official-main .template-removal-disclosure>summary:hover { background:#ffe7e3; }
  .staff-main .request-rejection-details>summary:focus-visible { outline:3px solid #9b2921; outline-offset:3px; }
  :is(details[data-floating-details],.audit-review-cell details) { position:relative; }
  :is(details[data-floating-details],.audit-review-cell details)[open]>summary { margin-bottom:0; }
  :is(details[data-floating-details],.audit-review-cell details)>:not(summary) {
    position:fixed; z-index:550; box-sizing:border-box; width:min(380px,calc(100vw - 24px));
    max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px); overflow:auto; overscroll-behavior:contain;
    border:1px solid #c9d8e9; border-radius:9px; background:#fff;
    box-shadow:0 14px 34px #173c6230;
  }
}
@media print {
  .ui-section-tooltip { display:none !important; }
  .ui-section-help-title { border:0; padding:0; background:none; color:inherit; font:inherit; }
}
