.ref-workspace, .ref-dialog {
    --ref-surface: #fff;
    --ref-subtle: #f8fafc;
    --ref-border: #cbd5e1;
    --ref-text: #1e293b;
    --ref-muted: #526176;
    --ref-accent: #0f766e;
    --ref-accent-bg: #e6f4f1;
    --ref-error: #b91c1c;
    --ref-error-bg: #fef2f2;
    --ref-warning: #92400e;
    --ref-warning-bg: #fffbeb;
    color: var(--ref-text);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}
.dark .ref-workspace, .dark .ref-dialog {
    --ref-surface: #1e293b;
    --ref-subtle: #182334;
    --ref-border: #475569;
    --ref-text: #f1f5f9;
    --ref-muted: #b0bed0;
    --ref-accent: #5eead4;
    --ref-accent-bg: #173f3e;
    --ref-error: #fca5a5;
    --ref-error-bg: #422a32;
    --ref-warning: #fcd34d;
    --ref-warning-bg: #3b3425;
    color-scheme: dark;
}
.ref-workspace { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--ref-border); }
.ref-recipe-notice { display: none; }
body[data-reference-recipe="1"] [data-reference-stage="2"] { display: none; }
body[data-reference-recipe="1"] .ref-recipe-notice { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--ref-border); }
.ref-recipe-notice p { color: var(--ref-muted); font-size: 12px; margin-top: 2px; }
.ref-workspace .hidden, .ref-dialog .hidden { display: none; }
#referencePreviewTitle { scroll-margin-top: 140px; }
.ref-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.ref-heading h3 { font-size: 20px; font-weight: 700; }
.ref-title-group { flex: 1; min-width: 0; }
.ref-title-group h4 { margin-top: 12px; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.ref-muted { color: var(--ref-muted); font-size: 12px; overflow-wrap: anywhere; }
.ref-active { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 16px; background: var(--ref-accent-bg); color: var(--ref-accent); border-left: 3px solid var(--ref-accent); }
.ref-active p { overflow-wrap: anywhere; font-weight: 600; }
.ref-section-title { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.ref-step { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; border: 1px solid var(--ref-border); border-radius: 50%; font-size: 12px; font-variant-numeric: tabular-nums; }
.ref-upload, .ref-preview, .ref-history { padding: 24px 0; }
.ref-preview, .ref-history { border-top: 1px solid var(--ref-border); }
.ref-upload-fields { display: grid; grid-template-columns: minmax(0, 1fr) 180px auto; align-items: start; gap: 20px; margin-top: 18px; }
.ref-upload-fields > button { margin-top: 29px; }
.ref-field { display: flex; flex-direction: column; gap: 8px; position: relative; min-width: 0; font-size: 13px; font-weight: 500; }
.ref-field input, .ref-field select { width: 100%; min-width: 0; height: 42px; border: 1px solid var(--ref-border); border-radius: 6px; background-color: var(--ref-surface); color: var(--ref-text); padding: 8px 12px; font: inherit; }
.ref-field select { padding-right: 32px; }
.ref-field input::placeholder { color: var(--ref-muted); opacity: 1; }
.ref-file-control { position: relative; display: flex; align-items: center; height: 42px; min-width: 0; background: var(--ref-surface); border: 1px solid var(--ref-border); border-radius: 6px; }
.ref-file-control:focus-within { outline: 2px solid var(--ref-accent); outline-offset: 3px; }
.ref-file-control input { position: absolute; inset: 0; height: 100%; opacity: 0; cursor: pointer; }
.ref-file-command { display: flex; align-items: center; align-self: stretch; flex-shrink: 0; padding: 0 14px; background: var(--ref-subtle); border-right: 1px solid var(--ref-border); border-radius: 6px 0 0 6px; font-weight: 600; }
#referenceFileName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 12px; color: var(--ref-muted); }
.ref-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--ref-border); border-radius: 6px; background: var(--ref-surface); color: var(--ref-text); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.ref-button .material-icons-outlined { font-size: 18px; flex-shrink: 0; }
.ref-button:hover:not(:disabled) { background: var(--ref-subtle); border-color: var(--ref-muted); }
.ref-button:disabled { opacity: .45; cursor: not-allowed; }
.ref-button.ref-primary { color: #fff; background: #0f766e; border-color: #0f766e; }
.ref-button.ref-primary:hover:not(:disabled) { background: #115e59; border-color: #115e59; }
.ref-icon { width: 40px; padding: 8px; flex-shrink: 0; }
.ref-workspace :focus-visible, .ref-dialog :focus-visible { outline: 2px solid var(--ref-accent); outline-offset: 3px; }
.ref-templates { margin-top: 16px; font-size: 12px; color: var(--ref-muted); }
.ref-templates summary, .ref-audit summary { cursor: pointer; width: fit-content; padding: 4px 0; }
.ref-templates div { display: flex; flex-wrap: wrap; gap: 12px 20px; padding-top: 12px; }
.ref-templates a { color: var(--ref-accent); text-decoration: underline; text-underline-offset: 3px; }
.ref-format-help { margin-top: 16px; font-size: 13px; }
.ref-format-help summary { cursor: pointer; width: fit-content; padding: 4px 0; }
.ref-format-help dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px 20px; margin: 16px 0; }
.ref-format-help dt { font-weight: 600; }
.ref-format-help dd, .ref-format-help p { color: var(--ref-muted); overflow-wrap: anywhere; }
.ref-format-help p { margin-top: 12px; }
.ref-control-filters { margin-top: 12px; }
.ref-rejected { margin-bottom: 24px; }
.ref-rejected li { padding: 12px 0; border-bottom: 1px solid var(--ref-border); overflow-wrap: anywhere; }
.ref-rejected p { margin-top: 6px; }
.ref-received { display: block; margin-top: 6px; color: var(--ref-text); overflow-wrap: anywhere; white-space: pre-wrap; }
.ref-remedy { display: block; margin-top: 6px; color: var(--ref-muted); }
.ref-impact:not(:empty) { padding: 12px; margin-top: 16px; border-left: 3px solid var(--ref-warning); background: var(--ref-warning-bg); color: var(--ref-text); font-size: 13px; }
@media (max-width: 600px) {
    .ref-format-help dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .ref-format-help dt:not(:first-child) { margin-top: 12px; }
}
.ref-feedback:not(:empty), .ref-validation { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin: 0 0 20px; background: var(--ref-accent-bg); color: var(--ref-accent); border-left: 3px solid currentColor; font-size: 13px; }
.ref-feedback[data-tone="error"], .ref-validation[data-tone="error"] { color: var(--ref-error); background: var(--ref-error-bg); }
.ref-validation[data-tone="warning"] { color: var(--ref-warning); background: var(--ref-warning-bg); }
.ref-validation[data-tone="neutral"] { color: var(--ref-muted); background: var(--ref-subtle); }
.ref-validation .material-icons-outlined { font-size: 20px; flex-shrink: 0; }
.ref-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-counts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 20px 0; padding: 16px 0; border-block: 1px solid var(--ref-border); }
.ref-counts > div { display: flex; flex-direction: column; gap: 4px; padding: 0 16px; border-left: 1px solid var(--ref-border); }
.ref-counts > div:first-child { border-left: 0; padding-left: 0; }
.ref-counts dt { color: var(--ref-muted); font-size: 12px; }
.ref-count-definition { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; }
.ref-reconciliation:not(:empty) { margin: -8px 0 20px; }
.ref-counts dd { order: -1; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ref-counts [data-tone="error"] dd { color: var(--ref-error); }
.ref-counts [data-tone="warning"] dd { color: var(--ref-warning); }
.ref-counts [data-tone="success"] dd { color: var(--ref-accent); }
.ref-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; }
.ref-toolbar > label:first-child { flex: 0 1 240px; }
.ref-search { flex: 1; max-width: 360px; min-width: 180px; }
.ref-comparison { margin: 12px 0; }
.ref-table-scroll { max-height: 400px; overflow: auto; border: 1px solid var(--ref-border); border-radius: 6px; background: var(--ref-surface); }
.ref-table { width: 100%; table-layout: fixed; text-align: left; font-size: 13px; }
.ref-table th { position: sticky; top: 0; z-index: 1; background: var(--ref-subtle); color: var(--ref-muted); font-size: 12px; font-weight: 600; }
.ref-table th:first-child { width: 22%; }
.ref-table th:nth-child(2) { width: 26%; }
.ref-table th, .ref-table td { padding: 12px 16px; vertical-align: top; overflow-wrap: anywhere; }
.ref-table td { border-top: 1px solid var(--ref-border); }
.ref-table tbody tr:hover { background: var(--ref-subtle); }
.ref-error { color: var(--ref-error); }
.ref-control-group { min-width: 0; border-top: 1px solid var(--ref-border); }
.ref-control-group:last-child { border-bottom: 1px solid var(--ref-border); }
.ref-control-group summary { display: flex; align-items: center; gap: 12px; padding: 14px 8px; cursor: pointer; list-style: none; }
.ref-control-group summary::-webkit-details-marker { display: none; }
.ref-control-group summary:hover { background: var(--ref-subtle); }
.ref-control-group summary > .material-icons-outlined { font-size: 20px; flex: 0 0 20px; color: var(--ref-muted); }
.ref-control-group[open] summary > .material-icons-outlined { transform: rotate(90deg); }
.ref-control-identity { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ref-control-identity strong, .ref-control-identity > span { display: block; }
.ref-control-identity > span { margin-top: 2px; color: var(--ref-muted); font-size: 13px; }
.ref-control-counts { display: flex; flex-wrap: wrap; justify-content: end; gap: 4px 12px; flex: 0 1 210px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ref-control-counts > span { white-space: nowrap; }
.ref-warning { color: var(--ref-warning); }
.ref-control-group .ref-table-scroll { margin-bottom: 16px; }
@media (max-width: 640px) {
    .ref-control-group summary { flex-wrap: wrap; }
    .ref-control-identity { flex-basis: calc(100% - 32px); }
    .ref-control-counts { flex-basis: 100%; justify-content: start; padding-left: 32px; }
}
.ref-quarantine-notice { margin: 16px 0; color: var(--ref-muted); font-size: 13px; }
.ref-quarantine-group { min-width: 0; padding: 16px 0; border-top: 1px solid var(--ref-border); }
.ref-quarantine-group summary { cursor: pointer; padding: 4px 0; overflow-wrap: anywhere; }
.ref-quarantine-group summary strong { font-size: 15px; }
.ref-quarantine-group summary > span { display: inline-block; margin-left: 16px; color: var(--ref-muted); font-size: 12px; }
.ref-quarantine-group summary .ref-difference-count { color: var(--ref-warning); }
.ref-quarantine-group .ref-table-scroll { margin-top: 12px; }
.ref-quarantine-table { min-width: 100%; table-layout: fixed; text-align: left; font-size: 13px; }
.ref-quarantine-table th, .ref-quarantine-table td { padding: 12px 16px; vertical-align: top; overflow-wrap: anywhere; border-bottom: 1px solid var(--ref-border); }
.ref-quarantine-table thead th { position: sticky; top: 0; background: var(--ref-subtle); }
.ref-quarantine-table thead strong, .ref-quarantine-table thead span { display: block; }
.ref-quarantine-table thead span { margin-top: 4px; font-size: 12px; color: var(--ref-muted); font-weight: 400; }
.ref-quarantine-table th:first-child { width: 200px; color: var(--ref-muted); font-weight: 500; }
.ref-quarantine-table tbody td { color: var(--ref-warning); background: var(--ref-warning-bg); font-weight: 600; }
.ref-quarantine-table tbody td.ref-muted { color: var(--ref-muted); background: var(--ref-surface); font-weight: 400; }
.ref-quarantine-table tr:last-child > * { border-bottom: 0; }
#referenceShowQuarantine[aria-pressed="true"] { border-color: var(--ref-warning); color: var(--ref-warning); background: var(--ref-warning-bg); }
.ref-pagination { display: flex; justify-content: end; align-items: center; gap: 8px; margin-top: 12px; color: var(--ref-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ref-pagination > span { margin-right: 8px; }
.ref-activation { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 16px 0; border-block: 1px solid var(--ref-border); }
.ref-audit { margin-top: 16px; font-size: 12px; color: var(--ref-muted); }
.ref-audit ul { margin-top: 8px; }
.ref-audit li { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 0; border-bottom: 1px solid var(--ref-border); }
.ref-audit time { min-width: 135px; font-variant-numeric: tabular-nums; }
.ref-history-list { margin-top: 16px; max-height: 360px; overflow-y: auto; }
.ref-history-row[data-selected="true"] { background: var(--ref-accent-bg); }
.ref-history-row td:first-child { border-left: 3px solid transparent; }
.ref-history-row[data-selected="true"] td:first-child { border-left-color: var(--ref-accent); }
.ref-version-link { color: var(--ref-accent); text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.ref-version-link:hover { text-decoration: underline; }
.ref-history-table { min-width: 900px; }
.ref-history-table th:first-child { width: 23%; }
.ref-history-table th:nth-child(2) { width: 18%; }
.ref-history-table th:nth-child(3) { width: 14%; }
.ref-history-table th:nth-child(4) { width: 16%; }
.ref-history-table th:nth-child(5) { width: 15%; }
.ref-history-table th:last-child { width: 14%; }
.ref-history-table .ref-badge { margin: 0 0 4px; }
.ref-changes-table { min-width: 620px; }
.ref-changes-table th:first-child { width: 15%; }
.ref-changes-table th:nth-child(2) { width: 25%; }
.ref-changes-table th:nth-child(3), .ref-changes-table th:nth-child(4) { width: 30%; }
.ref-changes-table td:last-child { font-weight: 600; }
.ref-label-help { display: inline-flex; align-items: center; gap: 4px; }
.ref-help { flex-shrink: 0; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--ref-muted); border-radius: 4px; }
.ref-help:hover { color: var(--ref-accent); background: var(--ref-accent-bg); }
.ref-help .material-icons-outlined { font-size: 16px; }
.ref-dialog.ref-tooltip { position: fixed; z-index: 1100; width: min(290px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); margin: 0; padding: 10px 12px; font-size: 12px; box-shadow: 0 4px 16px #0003; overflow-wrap: anywhere; }
.ref-dialog.ref-menu { position: fixed; z-index: 1000; width: min(290px, calc(100vw - 16px)); margin: 0; padding: 6px; box-shadow: 0 6px 20px #0003; }
.ref-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; text-align: left; font-size: 13px; border-radius: 4px; }
.ref-menu button:hover:not(:disabled), .ref-menu button:focus-visible { background: var(--ref-accent-bg); }
.ref-menu button:disabled { opacity: .45; cursor: not-allowed; }
.ref-menu button[data-reference-action="delete"] { color: var(--ref-error); }
.ref-menu button .material-icons-outlined { font-size: 18px; }
.ref-dialog.ref-journal { width: min(1100px, calc(100% - 32px)); }
.ref-journal h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.ref-journal .ref-table-scroll { margin-top: 16px; max-height: 60dvh; }
.ref-journal-table { min-width: 850px; }
.ref-journal-table th:first-child { width: 15%; }
.ref-journal-table th:nth-child(2) { width: 20%; }
.ref-author-email { display: block; margin-top: 4px; }
.ref-event-details { margin-top: 8px; font-size: 12px; }
.ref-event-details dt { color: var(--ref-muted); margin-top: 8px; }
.ref-event-details dd { overflow-wrap: anywhere; }
#referencePolicy:not(:empty) { margin: 12px 0 20px; }
#referenceStatusText { margin-top: 16px; }
.ref-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 4px; color: var(--ref-muted); background: var(--ref-subtle); font-size: 11px; font-weight: 600; vertical-align: middle; }
.ref-badge[data-state="active"] { color: var(--ref-accent); background: var(--ref-accent-bg); }
.ref-badge[data-state="blocked"] { color: var(--ref-error); background: var(--ref-error-bg); }
.ref-dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 24px; border: 1px solid var(--ref-border); border-radius: 8px; background: var(--ref-surface); }
.ref-dialog::backdrop { background: #0f172aaa; }
.ref-dialog h3 { font-size: 20px; font-weight: 700; margin-top: 16px; }
.ref-confirm-summary { margin: 20px 0; padding: 4px 0; border-block: 1px solid var(--ref-border); }
.ref-confirm-summary div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 16px; padding: 8px 0; }
.ref-confirm-summary dt { color: var(--ref-muted); font-size: 12px; }
.ref-confirm-summary dd { font-weight: 600; overflow-wrap: anywhere; }
.ref-dialog #referenceConfirmText { color: var(--ref-muted); font-size: 13px; }
.ref-ack:not(.hidden) { display: flex; gap: 12px; align-items: start; padding: 12px; margin-top: 16px; border: 1px solid var(--ref-border); border-radius: 6px; background: var(--ref-warning-bg); font-size: 13px; }
.ref-ack input { flex-shrink: 0; margin-top: 3px; border-radius: 3px; color: #0f766e; }
.ref-dialog .ref-error:not(:empty) { margin-top: 16px; font-size: 13px; }
.ref-dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 24px; }
@media (max-width: 760px) {
    .ref-upload-fields { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .ref-upload-fields > button { margin-top: 0; justify-self: start; }
    .ref-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 0; }
    .ref-counts > div:nth-child(4) { border-left: 0; padding-left: 0; }
    .ref-history .ref-heading { align-items: stretch; flex-direction: column; }
    .ref-history .ref-search { max-width: none; }
    .ref-table th, .ref-table td { padding: 10px 8px; }
}
@media (max-width: 440px) {
    .ref-heading { gap: 12px; }
    .ref-title-group { flex-basis: 100%; }
    .ref-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ref-counts > div:nth-child(n) { padding: 0 12px; border-left: 1px solid var(--ref-border); }
    .ref-counts > div:nth-child(odd) { border-left: 0; padding-left: 0; }
    .ref-toolbar > label { flex-basis: 100%; max-width: none; }
    .ref-table:not(.ref-history-table):not(.ref-journal-table) { min-width: 560px; }
    .ref-history-row { align-items: start; gap: 8px; padding-inline: 8px; }
    .ref-history-row .ref-button { padding: 8px; }
    .ref-dialog { padding: 20px; }
    .ref-confirm-summary div { grid-template-columns: 80px minmax(0, 1fr); gap: 12px; }
}
