:root{--page:#f3f6fa;--surface:#fff;--stripe:#eaf3f8;--ink:#25475f;--dim:#687f93;--line:#cedfe9;--accent:#087fa8;--tint:#d9edf7;--selected:#cde8f5}
body[data-theme=dark]{color-scheme:dark;--page:#121c28;--surface:#1c2b3b;--stripe:#233448;--ink:#e1eaf3;--dim:#a8bbcc;--line:#40566c;--accent:#69bddb;--tint:#294458;--selected:#31566d}
body[data-theme=sage]{--page:#f0f5f0;--surface:#fff;--stripe:#e8f1e8;--ink:#294c3c;--dim:#607d6d;--line:#c8ddce;--accent:#317f62;--tint:#dceee2;--selected:#cbe6d7}
body[data-theme=sand]{--page:#f6f2eb;--surface:#fffdf9;--stripe:#f2e9db;--ink:#574631;--dim:#86745d;--line:#dfd0b9;--accent:#98682b;--tint:#f1e2ca;--selected:#ebd6b5}
body{background:var(--page);color:var(--ink)}header,.panel,.task-card,dialog:not(#image-viewer),.section-card,.table-wrap,.contacts button,.bubble{background:var(--surface);color:var(--ink);border-color:var(--line)}
button,input,select,textarea{color:var(--ink);background:var(--surface);border-color:var(--line)}button.primary{background:var(--accent);color:var(--surface)}body[data-theme=dark] button.primary{color:#14212a}
h1,h2,h3,h4,.project-name,.section-card strong,.note strong{color:var(--ink)}.muted,small,.contact-preview,.owner-summary{color:var(--dim)}.tabs button.active,.subtabs button.active,.contacts button.selected,.bubble.mine{background:var(--tint);color:var(--ink)}
thead,.image-widget,.permit-panel,.new-document,.architecture-path,.external-panel{background:var(--stripe);color:var(--ink);border-color:var(--line)}
.project-row{background:var(--surface)!important;border-top-color:var(--page)}.project-row.alternate{background:var(--stripe)!important}.project-row:hover{background:var(--tint)!important}.project-row.open{background:var(--selected)!important;border-left-color:var(--accent)}
.details>td{background:var(--stripe)!important;border-color:var(--accent)}.section-card.section-selected,.inline-section{background:var(--selected)!important;border-color:var(--accent)!important}.section-card.section-selected{box-shadow:0 5px 0 var(--selected)}.section-card.section-selected:after{border-top-color:var(--accent)}.compact-document,.image-choice{background:var(--surface);border-color:var(--line)}
.project-actions{display:flex;gap:7px;justify-content:flex-end;flex-wrap:wrap;min-width:145px}.project-actions button{white-space:nowrap;padding:8px 10px}.project-name small{display:block;font-size:11px;margin-top:5px;font-weight:400}.compact-document{min-width:0;padding:0;border:0}.document-title{padding:10px 16px;font-weight:600}.avatar{overflow:hidden;flex-shrink:0;color:white}.avatar img{width:100%;height:100%;object-fit:cover}.bubble-person{display:flex;align-items:center;gap:8px;margin-bottom:8px}.bubble-person .avatar{width:25px;height:25px;font-size:11px}.chat-head{flex-wrap:wrap}.chat-head small{width:100%}#identity{display:flex;align-items:center;gap:8px}.profile-panel{margin-bottom:20px}.parcel-card{border-left:4px solid var(--accent)}
#image-viewer{position:fixed;inset:0;margin:0;width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;box-sizing:border-box;padding:14px 20px}#image-viewer .image-stage{height:calc(100% - 76px)}.image-viewer-head{flex-wrap:nowrap;min-height:42px}.image-viewer-head [data-gallery=close]{margin-left:auto;font-size:24px;min-width:42px}.zoom-tools{display:none}
body[data-theme=dark] .badge.waiting{background:#35475d;color:#d6e1ec}body[data-theme=dark] .notice{background:#303e47;color:var(--ink)}body[data-theme=dark] .notice.blue{background:#233f53}body[data-theme=dark] .due-late{color:#ffb6b6}body[data-theme=dark] .auth{background:var(--surface)}
thead th{background:var(--stripe);color:var(--dim)}.project-name small{color:var(--dim)}.compact-documents>.inline-actions{flex-basis:auto}

/* Header text follows the active theme surface. */
header .brand p,header .header-right{color:var(--ink)}
header #clock{color:var(--dim)}
/* Readable day palette and a continuous outline around the expanded project. */
body:not([data-theme=dark]){--dim:#465e70;--muted:#465e70}
body:not([data-theme=dark]) .badge.waiting{color:#485d75;background:#e8eef4}
body:not([data-theme=dark]) .badge.doing{color:#865000}
body:not([data-theme=dark]) .badge.done{color:#17643b}
body:not([data-theme=dark]) .badge.urgent{color:#ad203d}
.project-row.open>td{border-top:4px solid var(--accent)!important}
.project-row.open>td:first-child{border-left:4px solid var(--accent)!important}
.project-row.open>td:last-child{border-right:4px solid var(--accent)!important}
.details>td{border-left:4px solid var(--accent)!important;border-right:4px solid var(--accent)!important;border-bottom:6px solid var(--accent)!important}
.details+.project-row>td{border-top:22px solid var(--page)!important}
#theme-toggle{justify-self:end;white-space:nowrap;border:2px solid var(--accent);color:var(--ink);background:var(--surface);padding:8px 13px}
@media(max-width:650px){header .header-right{display:grid}header .header-right #clock,header .header-right #identity{display:none}header{gap:10px}}
.table-wrap>table{border-collapse:separate;border-spacing:0}

/* Cover the viewport even when the project list is short. */
html{min-height:100%;background:var(--page)}body{min-height:100vh;min-height:100dvh}
