:root{--surface:#fff;--surface-alt:#f8faf9;--hover:#fafcfb;--text-on-brand:#fff}
:root[data-theme=blue]{--brand:#174f87;--brand-dark:#103d6b;--ink:#18334c;--muted:#52677b;--ground:#f0f5fa;--line:#d4e0eb;--soft:#e4eef8}
:root[data-theme=dark]{color-scheme:dark;--brand:#80cdb6;--brand-dark:#a1dfcc;--ink:#e4ecef;--muted:#b0c0c8;--ground:#10191e;--line:#3b4d56;--white:#1b282f;--surface:#1b282f;--surface-alt:#22323a;--hover:#293d46;--soft:#243f3b;--amber:#f2ce8d;--amber-bg:#42351e;--red:#ffaaa2;--text-on-brand:#10251e}
body{background:var(--ground);color:var(--ink)}.sidebar,.topbar,.panel,button,input,select,textarea{background-color:var(--surface);color:var(--ink)}button.primary,.mark{background:var(--brand);color:var(--text-on-brand)}button.primary:hover{background:var(--brand-dark)}button:hover{background-color:var(--soft)}.nav button{background:transparent;color:var(--muted)}.nav button.active{background:var(--soft);color:var(--brand)}th,dialog .dialog-foot{background:var(--surface-alt)}tbody tr:hover{background:var(--hover)}th,td{border-color:var(--line)}input,select,textarea{border-color:var(--line)}.stat{background:var(--surface)}dialog{background:var(--surface);color:var(--ink)}.notice{color:var(--amber)}.bar-track{background:var(--surface-alt)}.chip.gray{background:var(--surface-alt);color:var(--muted)}.chip.red{background:var(--amber-bg);color:var(--red)}.text-button{color:var(--brand);background:transparent}.theme-options{display:flex;flex-wrap:wrap;gap:12px}.theme-options button{display:flex;align-items:center;gap:8px}.theme-options [aria-pressed=true]{border:2px solid var(--brand)}.theme-swatch{display:block;width:20px;height:20px;border:1px solid var(--line);border-radius:50%}.swatch-green{background:#165c51}.swatch-blue{background:#174f87}.swatch-dark{background:#10191e}.settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;align-items:start}.settings-grid .panel-body{display:grid;gap:12px}.settings-grid .field{min-width:0}.lock-panel{max-width:480px;margin:48px auto}.lock-panel .panel-body{display:grid;gap:16px}.side-bottom #settings-button{display:flex;align-items:center;gap:12px;text-align:left}.side-bottom #settings-button .od-icon{--od-icon-size:20px}:root[data-theme=dark] select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e4ecef' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")}
@media(max-width:1024px){.settings-grid{grid-template-columns:minmax(0,1fr)}}@media(max-width:768px){.settings-grid{gap:16px}.side-bottom{display:flex;flex-wrap:wrap;margin-top:0;padding:0;border:0}.side-bottom .local-status,.side-bottom>p{display:none}.side-bottom #settings-button{margin-left:auto}.lock-panel{margin:16px auto}}
@media print{body{background:#fff;color:#000}.panel,td,th{background:#fff;color:#000}}

/* Optional glass theme; existing palettes remain independent. */
:root[data-theme=glass]{color-scheme:light;--brand:#155e65;--brand-dark:#104a50;--ink:#17343c;--muted:#465f67;--ground:#e7f0f3;--line:rgba(100,138,149,.32);--white:#f7fbfc;--surface:rgba(255,255,255,.76);--surface-alt:rgba(236,245,248,.88);--hover:rgba(218,237,242,.86);--soft:rgba(212,234,238,.92);--text-on-brand:#fff;--glass-blur:16px;--glass-shadow:0 8px 28px rgba(31,73,88,.08)}
:root[data-theme=glass] body{background:radial-gradient(ellipse at 12% 10%,#c5e4e2 0,transparent 48%),radial-gradient(ellipse at 88% 72%,#d0dfef 0,transparent 52%),var(--ground);background-attachment:fixed}
:root[data-theme=glass] :is(.sidebar,.topbar,.panel,dialog,#person-actions){background:var(--surface);-webkit-backdrop-filter:blur(var(--glass-blur)) saturate(120%);backdrop-filter:blur(var(--glass-blur)) saturate(120%);box-shadow:var(--glass-shadow);border-color:rgba(255,255,255,.85)}
:root[data-theme=glass] .panel{border:1px solid rgba(255,255,255,.85);outline:1px solid rgba(100,138,149,.16)}
:root[data-theme=glass] :is(input,select,textarea){background-color:rgba(255,255,255,.9);border-color:rgba(100,138,149,.48)}
:root[data-theme=glass] button:not(.primary):not(.text-button):not(.human-mark):not([aria-selected=true]){background-color:rgba(255,255,255,.65)}
:root[data-theme=glass] button:hover:not(.human-mark):not([aria-selected=true]){background-color:var(--soft)}
:root[data-theme=glass] .nav button.active{background:var(--soft);color:var(--brand)}
:root[data-theme=glass] .stat{background:rgba(255,255,255,.62)}
.swatch-glass{background:linear-gradient(135deg,#c5e4e2,#e9f2f9);box-shadow:inset 0 0 0 3px rgba(255,255,255,.65)}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){:root[data-theme=glass]{--surface:#f7fbfc}}
@media(prefers-reduced-transparency:reduce){:root[data-theme=glass]{--surface:#f7fbfc;--glass-blur:0px}}
@media print{:root[data-theme=glass] body{background:#fff}:root[data-theme=glass] :is(.panel,dialog){background:#fff;backdrop-filter:none;box-shadow:none}}
.account-panel .panel-body{display:grid;gap:16px}.account-panel h1{font-size:30px}.account-panel textarea{font-family:ui-monospace,monospace;overflow-wrap:anywhere;word-break:break-all}.account-panel .inline-check{align-items:flex-start}.account-panel .inline-check input{flex:none;margin-top:4px}.account-panel .error:empty,.account-panel [role=status]:empty{display:none}

/* Online login reuses the app's existing surface and brand tokens. */
#cloud-auth-form{display:grid;gap:16px}#cloud-auth-form .field{margin:0}.auth-divider{display:flex;align-items:center;gap:16px;color:var(--muted)}.auth-divider::before,.auth-divider::after{content:"";height:1px;background:var(--line);flex:1}.auth-switch{text-align:center;margin:0}.auth-switch .text-button{padding:8px;min-height:44px}.account-panel .text-button:focus-visible{outline:2px solid var(--brand);outline-offset:4px}#cloud-google{min-height:44px}.account-panel #cloud-error:empty{display:none}

body.auth-screen .app{display:block}body.auth-screen .sidebar,body.auth-screen .topbar{display:none}body.auth-screen main{max-width:560px;padding:24px}body.auth-screen .lock-panel{margin:48px auto}body.auth-screen .account-panel h1{font-family:Georgia,serif;font-size:36px}@media(max-width:768px){body.auth-screen main{padding:16px}body.auth-screen .lock-panel{margin:16px auto}}

/* Filled selection uses the existing accent in every theme. */
:root{--button-hover-gray:#cccccc;--button-hover-ink:#111111}
:root .nav button[data-nav]{transition:background-color 180ms ease-out,color 180ms ease-out,transform 150ms ease-out}
:root .nav button[aria-current=page],:root[data-theme] .nav button[aria-current=page]{background:var(--brand)!important;color:var(--text-on-brand)!important;font-weight:700;box-shadow:none}
:root .nav button[data-nav]:active{transform:scale(.97)}
@media(hover:hover){
:root :is(.nav,.redesign-tabs) button:hover:not([aria-current=page]):not([aria-selected=true]),:root[data-theme] :is(.nav,.redesign-tabs) button:hover:not([aria-current=page]):not([aria-selected=true]){background:var(--button-hover-gray)!important;color:var(--button-hover-ink)!important;transform:scale(.99)}
:root :is(.nav,.redesign-tabs) button:active{transform:scale(.97)}
}
:root .redesign-tabs button{transition:background-color 180ms ease-out,color 180ms ease-out,transform 150ms ease-out}
@media(prefers-reduced-motion:reduce){:root :is(.nav,.redesign-tabs) button{transition:none;transform:none!important}}
@media(prefers-reduced-motion:reduce){:root .nav button[data-nav]{transition:none;transform:none}}
@media(forced-colors:active){:root .nav button[aria-current=page]{outline:2px solid Highlight;outline-offset:-2px}}

/* The appearance controls use existing glass surfaces and work before sign-in. */
:root[data-theme=glass] body{background:radial-gradient(ellipse at 12% 10%,var(--lg-gradient-1,#c5e4e2) 0,transparent 48%),radial-gradient(ellipse at 88% 72%,var(--lg-gradient-2,#d0dfef) 0,transparent 52%),var(--ground)}
#appearance-accent{width:100%;height:44px;padding:4px}
:root[data-theme=glass] #glass-gradient-controls input[type=color]{width:100%;height:44px;padding:4px}

/* Backup status follows the current theme and custom accent. */
button.backup-feedback{position:relative;min-width:180px;opacity:1;cursor:progress;display:inline-flex;align-items:center;justify-content:center;gap:8px;--backup-stroke:var(--brand)}
button.primary.backup-feedback{--backup-stroke:var(--text-on-brand)}
.backup-edge{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;pointer-events:none;border-radius:inherit}
.backup-edge rect{width:calc(100% - 4px);height:calc(100% - 4px);rx:6px;fill:none;stroke:var(--backup-stroke);stroke-width:2;stroke-dasharray:24 76;stroke-linecap:round;animation:backup-orbit 1.6s linear infinite}
.backup-check{width:20px;height:20px;flex:none;animation:backup-ready 200ms ease-out}
button.backup-feedback[data-backup-state=ready]{cursor:default}
@keyframes backup-orbit{to{stroke-dashoffset:-100}}
@keyframes backup-ready{from{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}
@media(prefers-reduced-motion:reduce){.backup-edge rect{animation:none;stroke-dasharray:none}.backup-check{animation:none}}
@media(forced-colors:active){button.backup-feedback{--backup-stroke:ButtonText}}


/* Compact phone login; desktop and other account screens retain their layout. */
@media(max-width:768px){
 body.auth-screen .account-panel:has(#cloud-auth-form[data-auth-mode="login"]) .auth-intro{display:none}
 body.auth-screen .account-panel:has(#cloud-auth-form[data-auth-mode="login"]) h1{font-size:28.8px}
 body.auth-screen .account-panel:has(#cloud-auth-form[data-auth-mode="login"]) .panel-body{gap:12px}
 body.auth-screen #cloud-auth-form[data-auth-mode="login"]{gap:12px}
 body.auth-screen #cloud-auth-form[data-auth-mode="login"] #cloud-login{width:50%;min-width:88px;justify-self:center}
}

@media(max-width:768px){
 body.auth-screen main:has(#cloud-auth-form[data-auth-mode="login"]){min-height:100vh;min-height:100dvh;padding-bottom:calc(16px + 10vh);padding-bottom:calc(16px + 10dvh);display:flex;flex-direction:column;justify-content:center}
 body.auth-screen .account-panel:has(#cloud-auth-form[data-auth-mode="login"]){width:80%;min-width:0;margin: auto;flex-shrink:0;overflow-wrap:anywhere}
 body.auth-screen .account-panel:has(#cloud-auth-form[data-auth-mode="login"]) :is(.panel-head,.panel-body){padding:16px}
 body.auth-screen #cloud-auth-form[data-auth-mode="login"] .field{min-width:0}
 body.auth-screen #cloud-auth-form[data-auth-mode="login"] input{width:100%;min-width:0}
}

.phone-only{display:none!important}
#mobile-menu-shade[hidden]{display:none!important}
@media(max-width:639px){
 .phone-only{display:inline-flex!important;align-items:center;justify-content:center}
 body:not(.auth-screen) .sidebar{position:fixed;top:0;left:0;bottom:0;width:min(288px,85vw);height:100vh;height:100dvh;z-index:32;display:flex;flex-direction:column;gap:24px;padding:20px 16px;background:var(--surface);visibility:hidden;transform:translateX(-100%);transition:transform 240ms ease-out,visibility 240ms;overflow-y:auto}
 body.phone-menu-open{overflow:hidden}
 body.phone-menu-open .sidebar{visibility:visible;transform:translateX(0)}
 .sidebar #mobile-menu-close{align-self:flex-end}
 .sidebar .wordmark{font-size:24px;gap:8px}
 .sidebar .side-label{display:block}
 .sidebar .nav{display:grid;overflow:visible;gap:8px}
 .sidebar .nav button{justify-content:flex-start;text-align:left;padding:12px;font-size:15px}
 .sidebar .nav .od-icon{display:block}
 .sidebar .side-bottom{display:grid;margin-top:auto;padding-top:16px;border-top:1px solid var(--line)}
 .sidebar .session-actions{display:grid;gap:8px}
 .sidebar .side-bottom #settings-button{margin-left:0}
 .sidebar .session-actions button{width:100%;text-align:left;justify-content:flex-start}
 #mobile-menu-shade{position:fixed;inset:0;width:100%;height:100%;z-index:31;background:rgba(0,0,0,.35);border:0;border-radius:0;padding:0}
 .topbar{gap:8px;justify-content:flex-start;padding:12px 16px}
 #mobile-menu{flex:none;width:44px;padding:8px}
 .topbar .breadcrumb{flex:1;min-width:0;overflow-wrap:anywhere}
 .topbar .top-actions{margin-left:auto}
 body.auth-screen #mobile-menu{display:none!important}
 .data-table tr[data-person-row]{padding:12px 16px}
 .data-table tr[data-person-row] td{font-size:14px;padding:4px 0}
 .data-table tr[data-person-row]:not(.phone-details-open) :is(td[data-label="Classification"],td[data-label="Waist (cm)"],td[data-label="Wrist (cm)"],td[data-label="Hip (cm)"],td[data-label="Weight to lose"]){display:none}
 .data-table td[data-label="Personnel"] .name{font-size:15px;overflow-wrap:anywhere}
 .data-table td[data-label="Action"]::before{display:none}
 .data-table td[data-label="Action"]{justify-content:flex-end}
 #person-actions{max-height:calc(100dvh - 16px);overflow-y:auto}
 #person-actions .phone-only{justify-content:flex-start}
}
@media(max-width:639px) and (prefers-reduced-motion:reduce){body:not(.auth-screen) .sidebar{transition:none}}

.phone-person-name{display:none}
@media(max-width:639px){
 .data-table tr[data-person-row]{display:grid;grid-template-columns:1fr 1fr 1fr 1fr 44px;align-items:center;gap:0;padding:8px 12px;touch-action:pan-y;-webkit-touch-callout:none}
 .data-table tr[data-person-row][hidden]{display:none!important}
 .data-table tr[data-person-row] td[data-label="Personnel"]{grid-column:1/-1;grid-row:1;padding:0 0 4px}
 .data-table tr[data-person-row] .desktop-person-name{display:none}
 .data-table tr[data-person-row] .phone-person-name{display:block;line-height:1.3}
 .data-table tr[data-person-row] td[data-label="Personnel"] small{font-size:12px;line-height:1.4}
 .data-table tr[data-person-row] :is(td[data-label="Height"],td[data-label="Weight"],td[data-label="Age"],td[data-label="BMI"]){grid-row:2;display:flex;justify-content:center;gap:4px;font-size:12px;white-space:nowrap;padding:0 4px;border-right:1px solid var(--line);min-width:0}
 .data-table tr[data-person-row] td[data-label="Height"]{grid-column:1}
 .data-table tr[data-person-row] td[data-label="Weight"]{grid-column:2}
 .data-table tr[data-person-row] td[data-label="Age"]{grid-column:3}
 .data-table tr[data-person-row] td[data-label="BMI"]{grid-column:4}
 .data-table tr[data-person-row] :is(td[data-label="Height"],td[data-label="Weight"])::before{display:none}
 .data-table tr[data-person-row] .inline-weight [data-unlock-weight]{font-size:12px;padding:0 4px;min-height:44px;background:transparent;box-shadow:none;border:0}
 .data-table tr[data-person-row] td[data-label="Action"]{grid-column:5;grid-row:2;padding:0}
 .data-table tr[data-person-row] td[data-label="Action"] button{padding:8px}
 .data-table tr.phone-details-open[data-person-row] :is(td[data-label="Classification"],td[data-label="Waist (cm)"],td[data-label="Wrist (cm)"],td[data-label="Hip (cm)"],td[data-label="Weight to lose"]){grid-column:1/-1}
 .data-table .bmi-history-row .inline-bmi-history{width:100%;max-width:100%}
}

@media(min-width:640px) and (max-width:1024px){
 #overview-personnel-table [data-person-row],#table-content [data-person-row]{touch-action:pan-y}
 .overview-primary [data-person-row] .name{-webkit-touch-callout:none;user-select:none;-webkit-user-select:none}
}

#person-actions button[hidden]{display:none!important}
@media(max-width:768px){
 .personnel-directory tr[data-person-row]{display:block}
 .personnel-directory tr[data-person-row] td{display:flex;justify-content:space-between;white-space:normal;gap:12px;border:0;padding:4px 0;grid-column:auto;grid-row:auto}
 .personnel-directory tr[data-person-row] td:first-child::before{display:block}
 .personnel-directory tr[data-person-row] td:first-child{padding-bottom:4px}
 .personnel-directory tr[data-person-row] td[data-label="Age"]{justify-content:space-between;border:0;font-size:14px;padding:4px 0}
 .personnel-directory tr[data-person-row] td[data-label="Action"]{justify-content:flex-end}
}

/* The directory has short ranks, not the Overview's combined personnel column. */
@media(min-width:769px){
 main[data-view="Personnel"] .data-table.personnel-directory{table-layout:fixed;width:100%}
 main[data-view="Personnel"] .data-table.personnel-directory :is(th,td){padding:8px 16px;text-align:left;vertical-align:middle;overflow-wrap:anywhere}
 main[data-view="Personnel"] .data-table.personnel-directory :is(th,td):first-child{width:12%;min-width:0;max-width:none;padding-left:16px;padding-right:16px}
 main[data-view="Personnel"] .data-table.personnel-directory :is(th,td):nth-child(5){width:8%;text-align:center}
 main[data-view="Personnel"] .data-table.personnel-directory :is(th,td):last-child{width:10%;text-align:center}
}
