:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-synthesis:none;color-scheme:light}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}button,input,textarea,select{font:inherit}button{cursor:pointer}button:disabled{opacity:.45;cursor:not-allowed}a{color:inherit}
body[data-theme="wa"]{--primary:#087f6b;--primary-dark:#075e54;--focus:#25d366;--surface:#fff;--surface2:#f4f7f7;--background:#dce9e5;--chat-bg:#e6ded4;--mine:#d9fdd3;--theirs:#fff;--text:#1c2b2b;--muted:#667781;--border:#dbe4e5;--hover:#e9f6f0;--shadow:rgba(0,0,0,.11)}
body[data-theme="dark"]{color-scheme:dark;--primary:#00a884;--primary-dark:#202c33;--focus:#00a884;--surface:#111b21;--surface2:#202c33;--background:#0b141a;--chat-bg:#0b141a;--mine:#005c4b;--theirs:#202c33;--text:#edf2f5;--muted:#9caeb6;--border:#2a3942;--hover:#26373c;--shadow:rgba(0,0,0,.4)}
body[data-theme="blue"]{--primary:#3774eb;--primary-dark:#254e9d;--focus:#60a5fa;--surface:#fff;--surface2:#f0f6ff;--background:#dce8fb;--chat-bg:#e9effa;--mine:#d9e7ff;--theirs:#fff;--text:#14233c;--muted:#68788d;--border:#dce4ee;--hover:#e6efff;--shadow:rgba(16,36,80,.13)}
body[data-theme="pink"]{--primary:#c34788;--primary-dark:#9e2e6c;--focus:#e96aa7;--surface:#fff;--surface2:#fff1f7;--background:#f5dbe8;--chat-bg:#fae9f0;--mine:#ffdbeb;--theirs:#fff;--text:#401f36;--muted:#86667a;--border:#f1dbe7;--hover:#fff0f7;--shadow:rgba(63,17,42,.13)}
body{background:var(--background);color:var(--text)}.hidden{display:none!important}.muted{color:var(--muted)}.small{font-size:12px}.primary,.danger,.secondary{border:0;border-radius:12px;padding:13px 16px;font-weight:700}.primary{background:var(--primary);color:white}.primary:hover{filter:brightness(1.07)}.primary-link{display:block;text-decoration:none;text-align:center}.danger{background:#b5324e;color:white}.secondary{background:var(--surface2);color:var(--text);border:1px solid var(--border)}input,textarea,select{border:1px solid var(--border);background:var(--surface);color:var(--text);border-radius:10px;outline:none;padding:12px;width:100%;min-width:0}input:focus,textarea:focus,select:focus{border-color:var(--focus);box-shadow:0 0 0 3px color-mix(in srgb,var(--focus) 17%,transparent)}label{display:flex;flex-direction:column;gap:8px;font-weight:600;font-size:13px;margin-bottom:15px}.page-center,.login-view,.setup-page{height:100dvh;display:flex;align-items:center;justify-content:center;padding:18px;overflow:auto}.load-brand{text-align:center}.load-brand img{width:100px}.load-brand h1{margin:4px}.load-brand p{color:var(--muted)}.auth-card{width:min(100%,410px);max-height:95dvh;overflow:auto;background:var(--surface);box-shadow:0 16px 45px var(--shadow);padding:38px 30px;border-radius:23px;text-align:center}.auth-card label{text-align:left}.auth-card .primary{width:100%;margin-top:7px}.auth-card h1{margin:12px 0 7px;font-size:27px}.auth-card .muted{line-height:1.5}.brand-icon{width:72px;height:72px}.footnote{margin-top:24px}.form-error{color:#c82e49}.success{color:var(--primary)}
.app-shell{width:min(100%,1500px);height:100dvh;display:grid;grid-template-columns:352px minmax(0,1fr);margin:auto;background:var(--surface);box-shadow:0 4px 28px var(--shadow)}.sidebar{height:100%;display:flex;flex-direction:column;min-width:0;border-right:1px solid var(--border);position:relative}.sidebar-header{background:var(--surface2);padding:16px 17px;display:flex;align-items:center;gap:12px;min-height:79px;border-bottom:1px solid var(--border)}.small-logo{width:41px;height:41px;border-radius:12px}.brand-block{flex:1;display:flex;flex-direction:column;gap:3px}.brand-block strong{font-size:20px;letter-spacing:-.5px}.brand-block span{max-width:200px;overflow:hidden;text-overflow:ellipsis}.icon-button{width:39px;height:39px;border:0;border-radius:50%;background:transparent;color:var(--muted);font-size:24px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.icon-button:hover,.settings-menu button:hover{background:var(--hover);color:var(--text)}.settings-menu{position:absolute;right:14px;top:69px;width:244px;background:var(--surface);border:1px solid var(--border);box-shadow:0 13px 30px var(--shadow);border-radius:14px;padding:12px;z-index:30}.settings-menu button{background:transparent;border:0;text-align:left;padding:10px;border-radius:8px;color:var(--text);width:100%}.settings-menu label{margin:8px 0 3px 8px;font-weight:600}.settings-menu select{margin-bottom:6px}.side-section{display:flex;align-items:center;justify-content:space-between;padding:17px 19px 10px}.side-section h2{font-size:21px;margin:0}.tag{background:var(--hover);color:var(--primary);padding:7px 9px;border-radius:20px;font-weight:700;font-size:11px}.chat-list{flex:1;min-height:0;overflow-y:auto}.chat-item{display:flex;align-items:center;gap:12px;padding:15px 17px;width:100%;border:0;border-bottom:1px solid var(--border);background:var(--surface);color:var(--text);text-align:left}.chat-item:hover,.chat-item.selected{background:var(--hover)}.avatar{background:var(--surface2);border:1px solid var(--border);width:43px;height:43px;border-radius:50%;display:inline-flex;justify-content:center;align-items:center;flex-shrink:0;font-size:22px}.chat-item-copy{display:flex;flex-direction:column;gap:5px;min-width:0}.chat-item-copy strong{font-size:15px}.chat-item-copy small{color:var(--muted);font-size:12px}.sidebar-footer{padding:16px 19px;display:flex;flex-direction:column;gap:8px;border-top:1px solid var(--border);overflow-wrap:anywhere}.right-panel{min-width:0;min-height:0;position:relative;display:flex;flex-direction:column}.empty-state{flex:1;background:var(--chat-bg);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:28px;text-align:center}.empty-state h2{font-size:26px;margin-bottom:5px}.empty-state p{color:var(--muted)}.hero-logo{width:110px;height:110px}.empty-badge{color:var(--primary);background:var(--surface);font-size:12px;padding:12px;border-radius:20px;margin-top:15px}
.conversation{height:100%;display:flex;flex-direction:column;background:var(--chat-bg);min-height:0}.chat-header{height:72px;flex-shrink:0;display:flex;align-items:center;gap:12px;padding:10px 16px;background:var(--surface2);border-bottom:1px solid var(--border)}.chat-person{display:flex;flex-direction:column;min-width:0;flex:1;gap:4px}.chat-person strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-person .small{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.header-button{background:var(--hover);color:var(--primary);border:0;border-radius:10px;padding:10px 12px;font-size:12px;font-weight:700}.clear-icon{font-size:21px}.messages{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:9px;padding:22px clamp(14px,6%,80px);overscroll-behavior:contain}.chat-notice{align-self:center;max-width:320px;text-align:center;background:var(--surface);color:var(--muted);font-size:12px;line-height:1.5;border-radius:12px;padding:13px;box-shadow:0 1px 4px var(--shadow);margin:auto}.bubble{max-width:min(70%,500px);border-radius:12px;padding:9px 11px;box-shadow:0 1px 2px var(--shadow);overflow-wrap:anywhere;flex-shrink:0}.bubble.mine{align-self:flex-end;background:var(--mine);border-top-right-radius:3px}.bubble.theirs{align-self:flex-start;background:var(--theirs);border-top-left-radius:3px}.bubble-text{font-size:14px;white-space:pre-wrap;line-height:1.48}.bubble-meta{font-size:10px;color:var(--muted);text-align:right;margin-top:6px}.shared-image{width:auto;max-width:100%;max-height:290px;display:block;border-radius:8px}.composer{min-height:73px;display:flex;gap:7px;align-items:center;padding:10px 15px calc(10px + env(safe-area-inset-bottom));background:var(--surface2);border-top:1px solid var(--border)}.composer textarea{resize:none;line-height:1.5;max-height:110px;min-height:44px;border-radius:22px;background:var(--surface)}.send-button{width:43px;height:43px;background:var(--primary);color:white;border:0;border-radius:50%;font-size:19px;flex-shrink:0}.emoji-tray{background:var(--surface);padding:10px;display:grid;grid-template-columns:repeat(8,1fr);gap:2px;max-height:190px;overflow:auto;border-top:1px solid var(--border)}.emoji-tray button{border:0;background:transparent;border-radius:7px;font-size:23px;padding:7px}.emoji-tray button:hover{background:var(--hover)}
.admin-view{padding:30px;overflow:auto;background:var(--surface2);height:100%}.admin-heading h1{font-size:28px;margin:0 0 7px}.admin-heading p{color:var(--muted);line-height:1.45;max-width:700px}.admin-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;margin-top:22px}.admin-card{border:1px solid var(--border);background:var(--surface);border-radius:16px;padding:24px;box-shadow:0 3px 15px var(--shadow)}.admin-card h3{margin-top:0}.admin-card p{line-height:1.5}.admin-card .primary{width:100%;margin-top:4px}.admin-row{padding:12px 0;border-bottom:1px solid var(--border);font-size:14px}.admin-row:last-child{border-bottom:0}.flex-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.subtle{border:1px solid var(--border);background:var(--surface2);color:var(--text);border-radius:9px;padding:8px 10px;font-size:12px}.modal-shade{position:fixed;z-index:100;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(0,0,0,.65)}.modal-card{width:min(100%,425px);background:var(--surface);border-radius:18px;padding:29px;box-shadow:0 15px 45px var(--shadow);max-height:95dvh;overflow:auto}.modal-card h2{font-size:23px;margin-top:0}.modal-card p{color:var(--muted);font-size:14px;line-height:1.55}.modal-card .primary,.modal-card .danger,.modal-card .secondary{width:100%;margin-top:10px}.toast{position:fixed;bottom:85px;left:50%;transform:translateX(-50%);background:#202c33;color:#fff;padding:12px 19px;max-width:min(90vw,430px);border-radius:11px;box-shadow:0 5px 24px #0005;z-index:200;font-size:13px;text-align:center}.mobile-only{display:none}
@media(max-width:850px){.app-shell{grid-template-columns:300px minmax(0,1fr)}.admin-grid{grid-template-columns:1fr}.admin-view{padding:20px}.messages{padding:15px 20px}.header-button{padding:8px;font-size:11px}}
@media(max-width:650px){.app-shell{display:block;position:relative}.sidebar{width:100%;height:100%;border-right:0}.right-panel{display:none;width:100%;height:100%;position:absolute;inset:0}.app-shell.show-chat .sidebar{display:none}.app-shell.show-chat .right-panel{display:flex}.app-shell.admin-active .sidebar{display:none}.app-shell.admin-active .right-panel{display:flex}.chat-header{height:64px;padding:8px}.chat-avatar{width:37px;height:37px;font-size:17px}.mobile-only{display:inline-flex}.header-button{max-width:80px;white-space:normal}.messages{padding:15px 12px}.bubble{max-width:88%}.composer{padding:7px 6px calc(8px + env(safe-area-inset-bottom));gap:2px}.composer .icon-button{width:34px;height:38px;font-size:25px}.composer textarea{padding:11px 13px}.send-button{height:39px;width:39px}.admin-view{padding:18px}.admin-card{padding:17px}.emoji-tray{grid-template-columns:repeat(7,1fr)}.side-section{padding-top:24px}.sidebar-header{padding:13px}.toast{bottom:80px}}

.password-status{background:rgba(200,46,73,.09);border:1px solid #c82e49;border-radius:10px;padding:11px 12px;font-size:13px!important;line-height:1.5;overflow-wrap:anywhere;color:#c82e49!important}.modal-card .primary:disabled{opacity:.65;cursor:wait}

/* V4: password visibility and admin controls */
.password-field{position:relative;display:flex;align-items:center;width:100%;min-width:0}
.password-field>input{padding-right:76px;min-width:0}
.password-eye{position:absolute;right:6px;top:50%;transform:translateY(-50%);height:34px;min-width:62px;border:1px solid var(--border);border-radius:8px;background:var(--surface2);color:var(--text);font-size:12px;font-weight:700;cursor:pointer}
.managed-user{padding:15px 0;border-bottom:1px solid var(--border)}
.managed-user:last-child{border-bottom:0}
.managed-user-heading{display:flex;gap:9px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-bottom:6px}
.account-badge{border-radius:20px;padding:5px 10px;font-size:11px;font-weight:700}
.account-active{background:#e2f8ed;color:#086a39}.account-inactive{background:#ffe7e7;color:#aa2130}
.user-actions{display:flex;flex-wrap:wrap;gap:7px;margin-top:12px}
.user-actions button{min-height:36px;cursor:pointer}
.danger-outline{color:#bd3344;border-color:#d9909c}
@media(max-width:650px){.managed-user-heading strong{overflow-wrap:anywhere}.user-actions button{flex:1 1 auto}}

/* v5 - explicit password recovery and administration feedback */
.text-link {border:0;background:transparent;color:var(--accent,#087e70);cursor:pointer;font-size:14px;text-decoration:underline;text-underline-offset:3px;margin-top:10px;padding:8px 0;width:100%;text-align:center}
.admin-card-heading {display:flex;justify-content:space-between;align-items:center;gap:10px}
#adminSearch {width:100%;max-width:100%;margin:6px 0 14px}
.form-feedback {font-size:13px;color:#086349;background:#e8f7f0;border:1px solid #b9dfce;padding:10px;border-radius:10px;margin:8px 0}
.form-feedback.is-error {color:#a52831;background:#fff0f1;border-color:#f2b9bf}
.recovery-request {display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;border:1px solid #e5b247;background:#fff5dc;color:#674207;padding:8px 10px;border-radius:9px;font-size:12px;margin:9px 0}
.recovery-request button {font-size:12px}
#adminActionModal .modal-card {max-width:460px}
#adminActionModal .danger {width:100%}
#adminActionModal #adminModalStatus {padding:10px;border-radius:9px;background:#fff0f0}
@media (max-width:600px) { .admin-card-heading {align-items:flex-start} .managed-user-heading {flex-wrap:wrap} .user-actions {row-gap:6px} }
