/* Delfin's shared visual language. No business rules or generated utility CSS. */
:root {
    --portal-bg: #f4f7fb;
    --portal-surface: #fff;
    --portal-soft: #f8fafc;
    --portal-border: #e2e8f0;
    --portal-text: #172b45;
    --portal-muted: #63758b;
    --portal-primary: #0069c9;
    --portal-primary-hover: #0054a3;
    --portal-tint: #edf5ff;
    --portal-positive: #047857;
    --portal-positive-bg: #ecfdf5;
    --portal-warning: #92400e;
    --portal-warning-bg: #fffbeb;
    --portal-danger: #b42336;
    --portal-danger-bg: #fff1f2;
    --portal-shadow: 0 3px 14px rgb(24 49 79 / 4%);
    --portal-radius: 14px;
    --portal-glass: rgb(255 255 255 / 80%);
    --portal-glass-raised: rgb(255 255 255 / 93%);
    --portal-glow-blue: rgb(0 105 201 / 6%);
    --portal-glow-teal: rgb(13 148 136 / 4%);
}
html.dark {
    color-scheme: dark;
    --portal-bg: #0b1422;
    --portal-surface: #111e30;
    --portal-soft: #152338;
    --portal-border: #26364c;
    --portal-text: #e6edf6;
    --portal-muted: #9aacc3;
    --portal-primary: #75b9ff;
    --portal-primary-hover: #a3d1ff;
    --portal-tint: #18314c;
    --portal-positive: #69dfb3;
    --portal-positive-bg: #143b33;
    --portal-warning: #f3c46e;
    --portal-warning-bg: #392f1d;
    --portal-danger: #ffa6b2;
    --portal-danger-bg: #402232;
    --portal-shadow: 0 3px 14px rgb(0 0 0 / 9%);
    --portal-glass: rgb(17 30 48 / 80%);
    --portal-glass-raised: rgb(17 30 48 / 94%);
    --portal-glow-blue: rgb(56 139 231 / 10%);
    --portal-glow-teal: rgb(45 178 164 / 5%);
}
html { background-color: var(--portal-bg); color-scheme: light; }
/* Keep the root canvas painted while Unfold waits for Alpine. Hiding html itself
   with display:none would expose the browser's default white canvas. */
html[x-cloak] { display: block !important; }
html[x-cloak] body { visibility: hidden; }
html:not([data-portal-theme-ready]) *,
html:not([data-portal-theme-ready]) *::before,
html:not([data-portal-theme-ready]) *::after { transition: none !important; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif; }
body:has(#nav-sidebar), .delfin-public { background: var(--portal-bg); color: var(--portal-text); }
body:has(#nav-sidebar) #main { background: var(--portal-bg); }
body:has(#nav-sidebar) #main > div:first-child { border-color: var(--portal-border); background: var(--portal-surface); }
#content h1 { font-weight: 650; letter-spacing: -.03em; color: var(--portal-text); }
#nav-sidebar, #nav-sidebar-inner { background: var(--portal-surface); border-color: var(--portal-border); }
#nav-sidebar-inner > div:first-child { border-color: var(--portal-border); }
#nav-sidebar-apps h2 { color: var(--portal-muted); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .1em; }
#nav-sidebar-apps hr { border-color: var(--portal-border); margin-top: 16px; margin-bottom: 12px; }
#nav-sidebar-apps ol { gap: 4px; }
#nav-sidebar-apps ol > li > a { position: relative; border-radius: 9px; min-height: 42px; color: var(--portal-muted); font-size: 13px; transition: background-color 160ms, color 160ms; }
#nav-sidebar-apps ol > li > a:hover { background: var(--portal-soft); color: var(--portal-primary); }
#nav-sidebar-apps ol > li > a.active { background: var(--portal-tint); color: var(--portal-primary); font-weight: 600; }
#nav-sidebar-apps ol > li > a.active::before { content: ''; width: 3px; height: 18px; background: var(--portal-primary); position: absolute; left: 0; border-radius: 0 3px 3px 0; }
.portal-account { border-color: var(--portal-border); }
.portal-brand { display: flex; width: 100%; align-items: center; justify-content: center; padding: 8px 0; }
.portal-logo { background: transparent; padding: 0; filter: none; width: 100%; height: auto; }
.portal-logo-pair { display: block; flex-shrink: 0; aspect-ratio: 1581 / 995; }
.portal-logo-pair .portal-logo-light { display: block; }
.portal-logo-pair .portal-logo-dark { display: none; }
html.dark .portal-logo-pair .portal-logo-light { display: none; }
html.dark .portal-logo-pair .portal-logo-dark { display: block; }
.portal-admin-logo { width: 130px; max-width: 100%; height: auto; max-height: 84px; object-fit: contain; }
.portal-login-logo { width: 153px; margin: 0 auto 16px; }
.portal-form-logo { width: 102px; }
.portal-wizard-logo { width: 76px; }
#nav-sidebar-inner > div:first-child:has(.portal-brand) { min-height: 112px; }

/* Dashboard */
.portal-dashboard { padding: 28px 8px 40px; }
.portal-page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin-bottom: 28px; }
.portal-eyebrow { margin: 0 0 8px; color: var(--portal-primary); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .14em; }
.portal-page-heading h1 { margin: 0; font-size: clamp(26px, 3vw, 34px); line-height: 1.2; }
.portal-page-heading p:not(.portal-eyebrow) { color: var(--portal-muted); margin: 9px 0 0; font-size: 13px; line-height: 1.6; }
.portal-heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.portal-button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid var(--portal-border); border-radius: 9px; background: var(--portal-surface); color: var(--portal-text); font-size: 12px; font-weight: 600; text-decoration: none; transition: background-color 160ms, border-color 160ms, box-shadow 160ms, transform 160ms; }
.portal-button .material-symbols-outlined { font-size: 18px; }
.portal-button:hover { background: var(--portal-soft); border-color: var(--portal-muted); }
.portal-button-primary { background: #0069c9; color: white; border-color: #0069c9; box-shadow: 0 3px 7px rgb(0 105 201 / 14%); }
.portal-button-primary:hover { background: #0054a3; border-color: #0054a3; color: white; }
.portal-button:active { transform: translateY(1px); }
.portal-dashboard a:focus-visible, .site-credit-link:focus-visible, .portal-theme-toggle:focus-visible { outline: 2px solid var(--portal-primary); outline-offset: 4px; }
.portal-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 32px; }
.portal-metric, .portal-panel, .system-health { background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
.portal-metric { padding: 22px; transition: border-color 180ms, box-shadow 180ms, transform 180ms; }
.portal-metric-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.portal-metric-label { color: var(--portal-muted); font-size: 12px; font-weight: 500; }
.portal-metric-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--portal-tint); color: var(--portal-primary); font-size: 19px; }
.portal-metric-value { display: block; font-size: 32px; line-height: 1.2; letter-spacing: -.045em; font-weight: 650; color: var(--portal-text); margin: 16px 0 6px; font-variant-numeric: tabular-nums; }
.portal-metric-footer { color: var(--portal-muted); font-size: 11px; }
.dashboard-panels { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 32px; align-items: start; }
.portal-panel { overflow: hidden; min-width: 0; }
.portal-panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 22px 24px; border-bottom: 1px solid var(--portal-border); }
.portal-panel-heading h2 { color: var(--portal-text); font-size: 14px; font-weight: 600; margin: 0; }
.portal-panel-heading p { color: var(--portal-muted); font-size: 11px; margin: 5px 0 0; }
.portal-panel-heading > .material-symbols-outlined { color: var(--portal-muted); font-size: 20px; }
.portal-app-heading { padding: 18px 24px 8px; color: var(--portal-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.portal-access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.portal-access-row { display: flex; align-items: center; gap: 12px; padding: 13px 24px; transition: background-color 160ms; }
.portal-access-row:hover, .portal-recent-row:hover { background: var(--portal-soft); }
.portal-access-icon { display: grid; place-items: center; background: var(--portal-soft); color: var(--portal-primary); width: 34px; height: 34px; border: 1px solid var(--portal-border); border-radius: 9px; font-size: 18px; flex-shrink: 0; }
.portal-access-name { color: var(--portal-text); font-size: 13px; font-weight: 500; flex: 1; }
.portal-row-actions { display: flex; align-items: center; gap: 14px; }
.portal-text-link { display: inline-flex; align-items: center; gap: 5px; color: var(--portal-primary); font-size: 11px; font-weight: 600; text-decoration: none; }
.portal-text-link .material-symbols-outlined { font-size: 15px; }
.portal-text-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.portal-app:last-child { padding-bottom: 12px; }
.portal-recent-row { display: flex; gap: 12px; align-items: flex-start; padding: 18px 24px; border-bottom: 1px solid var(--portal-border); transition: background-color 160ms; }
.portal-avatar { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 11px; background: var(--portal-tint); color: var(--portal-primary); font-size: 13px; font-weight: 600; }
.portal-recent-info { min-width: 0; flex: 1; }
.portal-recent-name { display: block; color: var(--portal-text); font-size: 12px; font-weight: 600; text-decoration: none; }
a.portal-recent-name:hover { color: var(--portal-primary); }
.portal-recent-email { color: var(--portal-muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.portal-recent-meta { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 11px; }
.portal-recent-meta time { color: var(--portal-muted); font-size: 10px; }
.portal-panel-footer { display: flex; justify-content: center; padding: 15px 24px; background: var(--portal-soft); }
.portal-empty { padding: 30px 24px; color: var(--portal-muted); font-size: 12px; line-height: 1.7; }
.portal-status { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 3px 8px; font-size: 10px; font-weight: 550; white-space: nowrap; line-height: 1.5; background: var(--portal-tint); color: var(--portal-primary); }
.portal-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.portal-status--pending { color: var(--portal-warning); background: var(--portal-warning-bg); }
.portal-status--completed { color: var(--portal-positive); background: var(--portal-positive-bg); }
.portal-status--rejected { color: var(--portal-danger); background: var(--portal-danger-bg); }

/* System health remains the last, full-width dashboard row. */
.system-health { grid-column: 1 / -1; padding: 24px; color: var(--portal-text); font-size: 12px; }
.system-health-header, .system-health-heading, .system-health-row, .system-health-row dt, .system-health-status { display: flex; align-items: center; gap: 8px; }
.system-health-header, .system-health-row { justify-content: space-between; }
.system-health-header { flex-wrap: wrap; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--portal-border); }
.system-health-heading { gap: 12px; }
.system-health-heading h2 { margin: 0; color: var(--portal-text); font-size: 14px; font-weight: 600; }
.system-health-heading p { margin: 4px 0 0; color: var(--portal-muted); font-size: 11px; }
.system-health .system-health-shield { padding: 10px; border-radius: 11px; background: var(--portal-positive-bg); color: var(--portal-positive); font-size: 18px; }
.system-health-status { color: var(--portal-positive); white-space: nowrap; font-size: 11px; }
.system-health-warning { color: var(--portal-warning); }
.system-health-status .material-symbols-outlined { font-size: 14px; }
.system-health-details { display: grid; gap: 18px; margin: 22px 0 0; }
.system-health-row dt .material-symbols-outlined { color: var(--portal-muted); font-size: 17px; }
.system-health-row dd { margin: 0; }
.system-health-note { margin-top: 20px; color: var(--portal-muted); font-size: 11px; line-height: 1.7; max-width: 760px; }

/* Shared agency credit, deliberately quieter than navigation. */
.site-credit { box-sizing: border-box; width: 100%; padding: 16px 24px; background: var(--portal-surface); border-top: 1px solid var(--portal-border); color: var(--portal-text); text-align: left; font-weight: 400; }
.site-credit .site-credit-label { margin: 0 0 11px; color: var(--portal-muted); font-size: 10px; font-weight: 500; line-height: 1.5; letter-spacing: .06em; text-transform: uppercase; }
.site-credit .site-credit-link { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; border-radius: 6px; }
.site-credit-brand { display: flex; flex: 1; flex-direction: column; gap: 7px; min-width: 0; }
.kompleto-logo { display: block; position: relative; width: 100%; max-width: 240px; aspect-ratio: 2172 / 724; }
.kompleto-logo img { display: block; width: 100%; height: auto; }
/* A white overlay only over the word, preserving the original blue icon and .dev. */
.kompleto-logo .kompleto-logo-dark-word { position: absolute; inset: 0; filter: brightness(0) invert(1); clip-path: inset(0 26.4% 0 26.4%); opacity: 0; transition: opacity 220ms ease; pointer-events: none; }
html.dark .kompleto-logo .kompleto-logo-dark-word { opacity: 1; }
.site-credit-description { color: var(--portal-muted); font-size: 10px; font-weight: 500; line-height: 1.6; letter-spacing: .04em; text-transform: uppercase; }
.site-credit-external { flex-shrink: 0; margin-left: auto; color: var(--portal-muted); }
.site-credit-link:hover .site-credit-external { color: var(--portal-primary); }
.site-credit .site-credit-footer { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--portal-border); color: var(--portal-muted); font-size: 10px; font-weight: 500; line-height: 1.6; letter-spacing: .04em; text-transform: uppercase; }

/* Admin tables and forms keep Unfold's markup and existing interactions. */
#changelist #result_list { font-size: 12px; }
#changelist #result_list thead th { background: var(--portal-soft); color: var(--portal-muted); font-size: 11px; font-weight: 600; }
#changelist #result_list tbody th, #changelist #result_list tbody td { border-color: var(--portal-border); padding-top: 15px; padding-bottom: 15px; vertical-align: middle; }
#changelist #result_list tbody tr { background: var(--portal-surface); transition: background-color 150ms; }
#changelist #result_list tbody tr:hover { background: var(--portal-soft); }
#changelist #result_list .field-name a { color: var(--portal-text); font-weight: 600; }
#changelist #result_list .field-name a:hover { color: var(--portal-primary); }
#changelist #result_list .column-name { min-width: 180px; }
#changelist #result_list .field-phone, #changelist #result_list .field-formatted_dob { white-space: nowrap; }
#changelist #result_list .field-generate_pdf_button a { background: var(--portal-soft); color: var(--portal-muted); border: 1px solid var(--portal-border); border-radius: 7px; font-size: 11px; font-weight: 500; padding: 6px 10px; white-space: nowrap; }
#changelist #result_list .field-generate_pdf_button a:hover { color: var(--portal-primary); border-color: var(--portal-primary); }
#changelist #result_list .field-generate_pdf_button svg { width: 14px; height: 14px; }
#changelist #toolbar { border-color: var(--portal-border); }
#changelist-filter { background: var(--portal-surface); border-color: var(--portal-border); border-radius: 12px; }
#changelist-filter h2 { font-size: 12px; font-weight: 600; }
#content .module, #content .inline-group { border-color: var(--portal-border); border-radius: var(--portal-radius); }
#content fieldset.module { background: var(--portal-surface); box-shadow: var(--portal-shadow); }
#content .form-row { border-color: var(--portal-border); }
#content .form-row label { font-size: 12px; font-weight: 500; }
#content .help, #content .helptext { font-size: 11px; line-height: 1.7; color: var(--portal-muted); }
#content input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=hidden]), #content select, #content textarea { border-color: var(--portal-border); background-color: var(--portal-surface); color: var(--portal-text); border-radius: 8px; transition: border-color 150ms, box-shadow 150ms; }
#content input:not([type=checkbox]):not([type=radio]):focus, #content select:focus, #content textarea:focus { border-color: var(--portal-primary); box-shadow: 0 0 0 3px var(--portal-tint); }
#content .submit-row { border-color: var(--portal-border); border-radius: 12px; background: var(--portal-surface); }
.portal-annual-history, .portal-archive > section, .portal-archive > .overflow-x-auto { background: var(--portal-surface); border-color: var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
.portal-archive > p { color: var(--portal-muted); font-size: 12px; line-height: 1.8; }
.portal-archive table thead { background: var(--portal-soft); color: var(--portal-muted); font-size: 11px; }
.portal-archive table tbody tr:hover { background: var(--portal-soft); }
.portal-archive dl dt { color: var(--portal-muted); font-size: 11px; }
.portal-archive dl dd { margin-top: 5px; font-size: 13px; }

/* Public login / intake form use the same palette as the admin. */
.delfin-public { min-height: 100vh; }
.portal-theme-toggle { position: fixed; right: 22px; top: 18px; z-index: 70; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--portal-border); border-radius: 11px; background: var(--portal-surface); color: var(--portal-muted); cursor: pointer; box-shadow: var(--portal-shadow); }
.portal-theme-toggle svg { width: 18px; height: 18px; }
.portal-theme-sun, html.dark .portal-theme-moon { display: none; }
html.dark .portal-theme-sun { display: block; }
.portal-public-footer { padding: 24px 0; border-top: 1px solid var(--portal-border); background: var(--portal-surface); }
.portal-public-footer > div > p { color: var(--portal-muted); font-size: 10px; letter-spacing: .04em; }
.portal-public-footer .site-credit { max-width: 420px; margin: 18px auto 0; border: 1px solid var(--portal-border); border-radius: 12px; }
.portal-login { background: var(--portal-bg); }
.portal-login-card { background: var(--portal-surface); border-color: var(--portal-border); box-shadow: 0 16px 50px rgb(24 49 79 / 7%); padding: 36px; border-radius: 18px; }
.portal-login h1 { color: var(--portal-text); font-weight: 600; letter-spacing: -.03em; }
.portal-login p, .portal-login label { color: var(--portal-muted); }
.portal-login input:not([type=checkbox]) { background: var(--portal-soft); color: var(--portal-text); border-color: var(--portal-border); border-radius: 9px; min-height: 46px; }
.portal-login form > .rounded-md { display: grid; gap: 12px; box-shadow: none; }
.portal-login input::placeholder { color: var(--portal-muted); }
.portal-login form > button { border-radius: 9px; box-shadow: 0 4px 10px rgb(0 105 201 / 13%); transform: none; background: #0069c9; font-size: 13px; }
.portal-login form > button:hover { background: #0054a3; }
.portal-intake { max-width: 1160px; padding-top: 40px; }
.portal-form-header { flex-wrap: wrap; gap: 20px; margin-bottom: 28px; padding-right: 44px; }
.portal-form-header h1 { color: var(--portal-text); font-size: clamp(24px, 3vw, 30px); font-weight: 600; letter-spacing: -.035em; }
.portal-form-header p { color: var(--portal-muted); font-size: 12px; }
.portal-form-header a, .portal-form-header button { color: var(--portal-muted); font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.portal-intake-form { display: grid; gap: 24px; }
.portal-intake-form > * { margin-top: 0; margin-bottom: 0; }
.portal-form-section { border: 1px solid var(--portal-border); border-radius: var(--portal-radius); padding: 28px; background: var(--portal-surface); box-shadow: var(--portal-shadow); }
.portal-form-section h2 { color: var(--portal-text); font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.portal-form-section > .mb-8 { margin-bottom: 24px; }
.portal-form-section label { color: var(--portal-muted); font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.portal-form-section input:not([type=checkbox]):not([type=radio]):not([type=file]), .portal-form-section select, .portal-form-section textarea { color: var(--portal-text); background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: 8px; padding: 11px 13px; font-size: 13px; font-weight: 400; }
.portal-form-section input:focus, .portal-form-section select:focus, .portal-form-section textarea:focus { border-color: var(--portal-primary); box-shadow: 0 0 0 3px var(--portal-tint); outline: none; }
.portal-form-section .bg-slate-50, .portal-form-section .bg-slate-50\/50 { background: var(--portal-soft); border-color: var(--portal-border); border-radius: 12px; box-shadow: none; }
.portal-form-section .bg-slate-50:hover { background: var(--portal-soft); box-shadow: none; }
.portal-form-section .border-dashed { border-width: 1px; }
.portal-form-section span.text-slate-700 { color: var(--portal-text); font-weight: 500; }
.portal-form-section .text-slate-400, .portal-form-section .text-slate-500 { color: var(--portal-muted); }
.portal-form-section .w-12.h-12 { width: 36px; height: 36px; border-radius: 10px; }
.portal-form-section .w-12.h-12 svg { width: 19px; height: 19px; }
.portal-form-section button[type=button] { font-size: 12px; border-radius: 8px; font-weight: 500; }
.portal-form-controls { background: var(--portal-tint); color: var(--portal-text); }
.portal-form-controls label { color: var(--portal-muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; }
.portal-form-controls .bg-primary-900\/50 { background: var(--portal-surface); border-color: var(--portal-border); }
.portal-form-controls input { color: var(--portal-text); border-color: var(--portal-border); }
.portal-form-controls label > div { color: var(--portal-muted); font-weight: 600; border-radius: 7px; font-size: 12px; }
.portal-form-controls label .peer:checked + div { background: #0069c9; color: white; }
.portal-submit-bar { position: sticky; bottom: 16px; display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; padding: 20px 24px; background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: 0 4px 24px rgb(24 49 79 / 8%); z-index: 40; }
.portal-submit-bar h3 { color: var(--portal-text); font-size: 14px; font-weight: 600; }
.portal-submit-bar p { color: var(--portal-muted); font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; margin-top: 4px; }
.portal-submit-bar button { min-height: 42px; font-size: 12px; font-weight: 600; padding: 10px 16px; border-radius: 9px; box-shadow: none; transform: none; }
.portal-submit-bar button svg { width: 17px; height: 17px; }
.portal-wizard-navigation { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 1128px; z-index: 40; }
.portal-wizard-actions { position: static; }
.delfin-public .bg-red-50 { background: var(--portal-danger-bg); border-color: var(--portal-danger); }
.delfin-public .bg-red-50 p, .delfin-public .bg-red-50 h3 { color: var(--portal-danger); }
html.dark .flatpickr-calendar, html.dark .flatpickr-months .flatpickr-month, html.dark .flatpickr-current-month .flatpickr-monthDropdown-months { background: var(--portal-surface); color: var(--portal-text); border-color: var(--portal-border); }
html.dark .flatpickr-day, html.dark .flatpickr-weekday, html.dark .flatpickr-current-month { color: var(--portal-text); }
html.dark .flatpickr-day.flatpickr-disabled { color: var(--portal-muted); opacity: .5; }
html.dark .flatpickr-day:hover { background: var(--portal-tint); border-color: var(--portal-tint); }

/* A soft background makes translucent surfaces visible without reducing text opacity. */
body:has(#nav-sidebar) #main, .delfin-public {
    background-color: var(--portal-bg);
    background-image: radial-gradient(ellipse at 100% 0%, var(--portal-glow-blue), transparent 55%), radial-gradient(ellipse at 0% 55%, var(--portal-glow-teal), transparent 50%);
}
.portal-login { background: transparent; }
.portal-metric, .portal-panel, .system-health, .portal-login-card, .portal-submit-bar,
.portal-theme-toggle, .site-credit, .portal-account-menu {
    transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease, box-shadow 180ms ease;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .portal-metric, .portal-panel, .system-health, .portal-login-card {
        background: var(--portal-glass);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }
    body:has(#nav-sidebar) #main > div:first-child,
    #nav-sidebar, .portal-account-menu, .portal-submit-bar, .portal-theme-toggle {
        background: var(--portal-glass-raised);
        -webkit-backdrop-filter: blur(18px);
        backdrop-filter: blur(18px);
    }
    #nav-sidebar-inner, #nav-sidebar .site-credit { background: transparent; }
    .client-excel-modal { background: rgb(9 18 34 / 44%); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
}

/* Same-origin page fades are native: normal browser navigation remains unchanged. */
@view-transition { navigation: auto; }
@keyframes portal-page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes portal-content-in { from { opacity: .82; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
/* The incoming page fades over an opaque outgoing page, never a white gap. */
::view-transition { background-color: var(--portal-bg); }
::view-transition-old(root) { animation: none; opacity: 1; }
::view-transition-new(root) { animation: portal-page-in 240ms ease-out both; mix-blend-mode: normal; }
#nav-sidebar { view-transition-name: portal-sidebar; }
::view-transition-group(portal-sidebar) { animation: none; }
::view-transition-old(portal-sidebar) { animation: none; opacity: 0; }
::view-transition-new(portal-sidebar) { animation: none; }
html:not([data-portal-native-navigation="true"]) #content,
html:not([data-portal-native-navigation="true"]) .delfin-public main { animation: portal-content-in 220ms ease-out; }

/* Short, finite animations. Hover and focus never hide or delay content. */
@keyframes portal-arrive { from { opacity: .5; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.portal-page-heading, .portal-metric, .dashboard-panels > *, .portal-login-card { animation: portal-arrive 300ms ease-out both; }
.portal-metric:nth-child(2) { animation-delay: 35ms; }
.portal-metric:nth-child(3) { animation-delay: 70ms; }
.portal-metric:nth-child(4) { animation-delay: 105ms; }
.client-excel-modal.is-open .client-excel-dialog { animation: portal-arrive 180ms ease-out; }
@media (hover: hover) {
    .portal-metric:hover { border-color: var(--portal-primary); box-shadow: 0 6px 18px rgb(24 49 79 / 7%); }
}
@media (max-width: 1100px) {
    .portal-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .portal-dashboard { padding: 20px 0 28px; }
    .portal-metrics { gap: 12px; }
    .portal-metric { padding: 15px; }
    .portal-metric-value { font-size: 27px; }
    .portal-metric-top { flex-direction: column-reverse; align-items: flex-start; gap: 10px; }
    .portal-panel-heading, .portal-access-row, .portal-recent-row, .system-health { padding-left: 18px; padding-right: 18px; }
    .portal-app-heading { padding-left: 18px; }
    .portal-access-row { gap: 9px; }
    .portal-access-grid { grid-template-columns: minmax(0, 1fr); }
    .portal-row-actions { gap: 9px; }
    .portal-access-name { font-size: 12px; }
    .portal-login-card { padding: 28px 22px; }
    .portal-form-header { align-items: flex-start; }
    .portal-form-header > div { flex-wrap: wrap; gap: 12px; }
    .portal-form-section { padding: 20px; }
    .portal-submit-bar { position: static; padding: 20px; }
    .portal-submit-bar > div:last-child { flex-wrap: wrap; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
    .portal-metric, .portal-panel, .system-health, .portal-login-card,
    body:has(#nav-sidebar) #main > div:first-child, #nav-sidebar,
    .portal-account-menu, .portal-submit-bar, .portal-theme-toggle {
        background: var(--portal-surface);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .client-excel-modal { background: rgb(9 18 34 / 75%); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
