body[data-theme] { --surface:#fff; --canvas:#e8ecf1; --text:#25344a; --muted:#788398; --line:#cbd3de; --soft:color-mix(in srgb,var(--theme-color) 9%,var(--surface)); background-color:var(--canvas); color:var(--text); font-size:13px; line-height:1.9; }
body[data-theme][data-theme=default] { --theme-color:#365e68; --canvas:#e8e6df; }
body[data-theme][data-theme=blue] { --theme-color:#305c91; --canvas:#e6ebf3; }
body[data-theme][data-theme=green] { --theme-color:#2d6655; --canvas:#e3ece7; }
body[data-theme][data-theme=purple] { --theme-color:#66518f; --canvas:#e9e5f0; }
body[data-theme][data-theme=dark] { --theme-color:#9fb8ef; --surface:#202938; --canvas:#151d29; --text:#e7edf6; --muted:#b0bdcf; --line:#354155; color-scheme:dark; }
body[data-theme=pink], body.login-page[data-theme][data-theme=pink] { background-color:#ffe4f1; --theme-color:#ed8ac7; --surface:#fffafb; --canvas:#eee0e6; --text:#493940; --muted:#806b75; --line:#d8bdc9; }
body[data-theme=pink] header, body[data-theme=pink] .workspace-nav, body[data-theme=pink] .login { background-image:linear-gradient(125deg,#ffffff99,transparent 45%,#ebccd533 70%,#fff9); }
body[data-theme=pink] .sidebar-title::after, body[data-theme=pink] .login-brand::after { content:'✿ · ✿'; display:block; color:#ed8ac7; font-size:14px; letter-spacing:10px; font-weight:normal; }
body[data-theme=pink] .panel { border-color:var(--line); }
body[data-theme=pink] .stat-card { background:color-mix(in srgb,var(--tone) 5%,var(--surface)); }
body.login-page[data-theme] { background-color:var(--canvas); color:var(--text); }
.login-page[data-theme] .panel, .login-page[data-theme] input { background:var(--surface); color:var(--text); border-color:var(--line); }
.login-page[data-theme] button { background:var(--theme-color); color:var(--surface); }
body.admin-theme {
 --primary:var(--theme-color); --secondary:var(--theme-color); --accent:var(--text);
 --body-fg:var(--text); --body-bg:var(--canvas); --body-quiet-color:var(--muted); --body-loud-color:var(--text);
 --header-color:var(--text); --header-branding-color:var(--theme-color); --header-bg:var(--surface); --header-link-color:var(--theme-color);
 --breadcrumbs-fg:var(--muted); --breadcrumbs-link-fg:var(--theme-color); --breadcrumbs-bg:var(--surface);
 --link-fg:var(--theme-color); --link-hover-color:var(--text); --link-selected-fg:var(--theme-color);
 --hairline-color:var(--line); --border-color:var(--line); --darkened-bg:var(--soft); --selected-bg:var(--soft); --selected-row:var(--soft);
 --button-fg:var(--surface); --button-bg:var(--theme-color); --button-hover-bg:var(--muted); --default-button-bg:var(--theme-color); --default-button-hover-bg:var(--muted);
 --close-button-bg:var(--muted); --close-button-hover-bg:var(--theme-color); font-family:Tahoma,Arial,sans-serif;
}
.admin-theme #header { border-bottom:1px solid var(--line); box-shadow:0 2px 8px #00000008; }
.admin-theme #site-name { display:flex; align-items:center; gap:12px; font-size:18px; }
.admin-theme .admin-logo { width:150px; height:48px; object-fit:contain; background:white; border-radius:6px; }
.admin-theme .theme-toggle { display:none; }
.admin-theme .module, .admin-theme .inline-group, .admin-theme .submit-row { background:var(--surface); border-color:var(--line); }
.admin-theme input, .admin-theme select, .admin-theme textarea { color:var(--text); background:var(--surface); border-color:var(--line); font-family:inherit; }
.admin-theme .module h2, .admin-theme .module caption, .admin-theme .inline-group h2 { background:var(--soft); color:var(--text); }
.admin-theme .module caption a.section { color:var(--theme-color); }
.admin-theme table thead th, .admin-theme #changelist-filter, .admin-theme .selector-available h2, .admin-theme .selector-chosen h2 { background:var(--soft); color:var(--text); }
.admin-theme .button, .admin-theme input[type=submit], .admin-theme .submit-row input { background:var(--theme-color); color:var(--surface); }
.admin-theme a:focus-visible, .admin-theme button:focus-visible { outline:2px solid var(--theme-color); outline-offset:2px; }

/* Subtle metallic surfaces; keep the existing fixed gold Final Save style. */
body[data-theme] header, body[data-theme] .workspace-nav, body[data-theme] .panel { background-image:linear-gradient(125deg,rgba(255,255,255,.12),transparent 42%,rgba(50,65,85,.035) 70%,rgba(255,255,255,.08)); }
.workspace .workspace-nav > a, .workspace .workspace-nav > .mail-menu > summary, .workspace-nav .nav-caption { font-weight:700; color:var(--text); }
.workspace .workspace-nav .mail-menu-content a { font-weight:400; color:var(--muted); }
.user-code { font-family:monospace; font-size:11px; overflow-wrap:anywhere; }

.workspace .dashboard-heading { display:grid; grid-template-columns:minmax(190px,1fr) auto; align-items:center; gap:8px 16px; }
.workspace .dashboard-heading .quick-panel { display:flex; align-items:center; gap:8px; width:auto; max-width:none; padding:5px 8px; border-radius:10px; box-shadow:0 1px 4px #00000008; }
.dashboard-heading .quick-panel .section-heading { margin:0; flex:none; }
.dashboard-heading .quick-panel h2 { font-size:11px; white-space:nowrap; }
.dashboard-heading .quick-panel .dashboard-actions { gap:4px; margin:0; }
.workspace .dashboard-heading .quick-panel .button, .workspace .dashboard-heading .quick-panel .mail-menu summary { padding:3px 6px; min-height:25px; font-size:10px; border-radius:6px; }
.dashboard-heading .quick-panel .icon { width:14px; height:14px; }
.workspace .dashboard-heading > .button { grid-column:1 / -1; justify-self:start; padding:4px 9px; min-height:28px; font-size:11px; }
@media(max-width:900px) { .workspace .dashboard-heading { grid-template-columns:1fr; } .workspace .dashboard-heading .quick-panel { justify-self:start; max-width:100%; box-sizing:border-box; flex-wrap:wrap; } }

.dashboard-heading .quick-panel .section-heading small { display:none; }
body[data-theme=pink]::before { content:""; position:fixed; inset:0; pointer-events:none; z-index:0; opacity:.60; background-repeat:repeat; background-size:170px 150px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='150' viewBox='0 0 170 150'%3E%3Cg fill='%23ed8ac7'%3E%3Cg transform='translate(27 31) rotate(-12) scale(2.2)'%3E%3Cellipse cy='-3' rx='2' ry='3'/%3E%3Cellipse cx='3' rx='3' ry='2'/%3E%3Cellipse cy='3' rx='2' ry='3'/%3E%3Cellipse cx='-3' rx='3' ry='2'/%3E%3C/g%3E%3Cg fill='%23ffffff' transform='translate(121 106) rotate(30) scale(2.6)'%3E%3Cellipse cy='-3' rx='2' ry='3'/%3E%3Cellipse cx='3' rx='3' ry='2'/%3E%3Cellipse cy='3' rx='2' ry='3'/%3E%3Cellipse cx='-3' rx='3' ry='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
body[data-theme=pink] > main, body[data-theme=pink] > #container { position:relative; }
@media(max-width:700px) { .workspace .dashboard-heading .quick-panel { flex:0 1 auto; width:100%; max-width:100%; box-sizing:border-box; } }

/* Compact shared tables and administration workflow filters. */
body[data-theme] table td, body[data-theme] table th { padding:4px 7px; line-height:1.4; }
body[data-theme] table td .row-action, body[data-theme] table td .button, body[data-theme] table td button { width:auto; min-width:0; min-height:24px; height:auto; padding:2px 6px; font-size:10px; line-height:1.5; margin:2px; }
body[data-theme] table .mail-actions { gap:3px; }
.flow-navigation { margin:10px 24px; }
.flow-navigation summary { cursor:pointer; font-weight:bold; }
.flow-navigation > div, .flow-filters { display:flex; gap:12px; flex-wrap:wrap; align-items:center; padding:8px; }
.flow-filters label { display:flex; align-items:center; gap:5px; }
.flow-marker { color:var(--theme-color); white-space:nowrap; }
.admin-theme #changelist:has(.flow-filters) .changelist-form-container { width:100%; }

body[data-theme] table .action-icon { width:13px; height:13px; flex:none; margin-inline-end:4px; vertical-align:middle; }
body[data-theme=pink] table button, body[data-theme=pink] .button:not(.final-save), body[data-theme=pink] table .row-action:not(.final-save) { color:#382333; }

.workspace .dashboard-heading .quick-panel .dashboard-actions > .button,
.workspace .dashboard-heading .quick-panel .mail-menu > summary { display:inline-flex; align-items:center; justify-content:center; gap:4px; box-sizing:border-box; width:116px; height:29px; padding:3px 5px; font-size:10px; background:var(--theme-color); color:var(--surface); border:1px solid var(--theme-color); }
.workspace[data-theme=pink] .dashboard-heading .quick-panel .dashboard-actions .button { color:#382333; }

/* Compact dashboard, using the current theme and existing navigation. */
.workspace .stat-card { padding:12px 16px; text-decoration:none; box-shadow:0 2px 7px #27334512; }
.workspace .stat-card .count { font-size:26px; line-height:1.2; padding-top:2px; }
.workspace .dashboard-grid { gap:12px; }
.dashboard-tabs { display:flex; gap:6px; flex-wrap:wrap; }
.dashboard-tabs a { padding:5px 9px; border:1px solid var(--line); border-radius:6px; }
.dashboard-tabs a[aria-current] { background:var(--soft); color:var(--text); font-weight:700; }
.gregorian { display:block; color:var(--muted); font-size:10px; direction:ltr; }
.workspace .correspondence-panel td { padding:4px 6px; }
.workspace .workspace-nav > a, .workspace .workspace-nav > details > summary { font-weight:750; }

/* Shared control geometry; preserve theme palettes and the fixed gold exception. */
body[data-theme] :is(button,.button,.row-action,input[type=submit]):not(.final-save):not(.backup-button) {
 background-image:linear-gradient(180deg,#ffffff24,transparent 48%,#0000000c);
 box-shadow:inset 0 1px 0 #ffffff30,0 1px 2px #17233522; border-radius:6px;
}
body[data-theme] :is(input,select,textarea,button) { font-family:inherit; font-size:12px; box-sizing:border-box; }
body[data-theme] :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]),select) { min-height:32px; padding:4px 7px; max-width:100%; }
body[data-theme] table :is(td,th) { padding:5px 7px; line-height:1.55; vertical-align:middle; }
body[data-theme] table td :is(.row-action,.button,button) { min-height:27px; padding:3px 7px; font-size:11px; }
body[data-theme] .panel { border-radius:10px; }
body[data-theme] .message-meta { padding:9px 12px; border:1px solid var(--line); border-radius:8px; background:var(--soft); margin:8px 0 14px; }
.letter-flags { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin:6px 0; }
.letter-flags p { margin:0; display:flex; gap:5px; align-items:center; }
.user-select-search { display:block; width:100%; margin-bottom:4px; }
.admin-theme #header { position:sticky; top:0; z-index:100; }
.admin-theme .icon { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.7; vertical-align:middle; }
.user-menu-content { max-height:78vh; overflow:auto; }
.profile-portrait, .user-menu-content img.profile-portrait { display:block; width:144px; height:192px; aspect-ratio:3/4; object-fit:contain; border:1px solid var(--line); border-radius:8px; margin:8px auto; background:var(--soft); }
.profile-fallback { text-align:center; padding:12px; color:var(--muted); }
.profile-modal { width:min(340px,85vw); max-height:85vh; overflow:auto; padding:16px; border:1px solid var(--line); border-radius:10px; color:var(--text); background:var(--surface); box-shadow:0 8px 28px #0003; }
.profile-modal::backdrop { background:#18243566; }
.profile-modal p { margin:5px 0; overflow-wrap:anywhere; }
@media print { .profile-modal, .user-menu-content, .user-select-search { display:none; } }

.editor span:has(>input[type=checkbox]) label { width:auto; white-space:nowrap; flex:none; }
