/* Shared design tokens + layout for every authenticated NCRM page: the
   login screen, the dynamic sidebar (rendered by js/shell.js from
   GET /api/me/menus), and the topbar. Page-specific content styles stay
   inline in each page's own <style> block. */
:root{
  --navy:#0f2a4a; --navy2:#153a63; --accent:#2f5fd1; --bg:#f4f6f9; --card:#ffffff;
  --border:#e1e6ed; --text:#1c2733; --muted:#647082; --ok:#2e9e5b; --off:#b6bcc4;
  --tint:#e9f0fc;
}
*{ box-sizing:border-box; }
body{ margin:0; font-family:-apple-system,Segoe UI,Roboto,Arial,sans-serif; background:var(--bg); color:var(--text); }

/* ---------- LOGIN (split screen: carousel + card, rendered by js/shell.js
   renderLoginScreen() -- every page just has an empty #loginScreen div) ---------- */
#loginScreen{ display:none; min-height:100vh; }

/* ---------- BOOT LOADING (shown by shell.js while checking auth, before
   either #loginScreen or #appScreen is revealed -- avoids a flash of the
   login form on every navigation while a valid session is confirmed) ---------- */
.ncrm-boot-loading{ position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); z-index:100; }
.ncrm-boot-spinner{ width:32px; height:32px; border-radius:50%; border:3px solid var(--border); border-top-color:var(--accent); animation:ncrm-spin .7s linear infinite; }
@keyframes ncrm-spin{ to{ transform:rotate(360deg); } }
.login-split{ min-height:100vh; display:grid; grid-template-columns:1fr; background:linear-gradient(135deg, #241f33, #3a3050); }
@media(min-width:900px){ .login-split{ grid-template-columns:1fr 440px; } }
.login-left{ display:none; flex-direction:column; align-items:center; justify-content:center; padding:40px; color:#fff; }
@media(min-width:900px){ .login-left{ display:flex; } }
.login-carousel{ width:100%; max-width:400px; text-align:center; }
.login-slide{ display:none; }
.login-slide.active{ display:block; animation:login-fade .4s ease; }
@keyframes login-fade{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:translateY(0); } }
.login-illustration{ margin:0 auto 26px; width:210px; }
.login-illustration svg{ width:100%; height:auto; display:block; }
.login-slide-title{ font-size:21px; font-weight:700; margin-bottom:10px; }
.login-slide-desc{ font-size:13.5px; color:#c9c3dc; line-height:1.6; max-width:320px; margin:0 auto; }
.login-dots{ display:flex; justify-content:center; gap:7px; margin-top:24px; }
.login-dot{ width:8px; height:8px; border-radius:50%; background:rgba(255,255,255,.25); cursor:pointer; border:none; padding:0; }
.login-dot.active{ background:#fff; }

.login-right{ display:flex; align-items:center; justify-content:center; padding:40px 24px; background:#fff; }
.login-card{ width:100%; max-width:340px; }
.login-logo-badge{ width:120px; margin:0 auto 14px; }
.login-logo-badge img{ width:100%; height:auto; display:block; }
.login-card h1{ font-size:16px; font-weight:800; text-align:center; letter-spacing:.06em; color:var(--navy); margin:0 0 22px; }
.login-remember{ display:flex; align-items:center; gap:6px; color:var(--muted); font-size:12.5px; cursor:pointer; }
.login-remember input{ width:auto; }
.login-forgot{ color:var(--accent); text-decoration:none; font-size:12px; }
.login-forgot:hover{ text-decoration:underline; }

.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12px; color:var(--muted); margin-bottom:6px; }
.field input, .field select, .field textarea{ width:100%; padding:10px 12px; border-radius:8px; border:1px solid var(--border); background:#eef4fb; font-size:13.5px; font-family:inherit; }
.field textarea{ resize:vertical; min-height:80px; }
.btn{ padding:11px; background:var(--accent); color:#fff; border:none; border-radius:8px; font-size:14px; font-weight:600; cursor:pointer; }
.btn.secondary{ background:#fff; color:var(--navy); border:1px solid var(--border); }
.btn-row{ display:flex; gap:8px; justify-content:flex-end; }
.login-err{ color:#b3261e; font-size:12.5px; margin-top:10px; text-align:center; display:none; }

/* ---------- Password show/hide toggle (login + User Management forms) ---------- */
.password-wrap{ position:relative; }
.password-wrap input{ padding-right:42px !important; }
.password-toggle{ position:absolute; top:50%; right:8px; transform:translateY(-50%); width:30px; height:30px; padding:0; display:grid; place-items:center; border:0; border-radius:6px; background:transparent; color:var(--muted); cursor:pointer; }
.password-toggle:hover, .password-toggle:focus-visible{ color:var(--navy); background:#dfe9f7; outline:none; }
.password-toggle svg{ width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* ---------- APP SHELL ---------- */
#appScreen{ display:none; min-height:100vh; grid-template-columns:230px 1fr; }
#appScreen.open{ display:grid; }

.ncrm-sidebar{ background:var(--navy); color:#e7edf5; padding:16px 0; overflow-y:auto; position:sticky; top:0; height:100vh; }
.ncrm-sidebar .brand{ display:block; padding:14px 18px 16px; }
.ncrm-sidebar .brand-card{ background:#fff; border-radius:10px; padding:8px; display:flex; align-items:center; justify-content:center; }
.ncrm-sidebar .brand img{ width:100%; max-width:78px; height:auto; display:block; }
.ncrm-group{ padding:10px 18px 4px; font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:#8fa3bd; }
.ncrm-menu-item{ display:flex; align-items:center; gap:10px; padding:9px 18px; font-size:13px; cursor:pointer; color:#dbe4ef; }
.ncrm-menu-item:hover{ background:rgba(255,255,255,.06); }
.ncrm-menu-item.active{ background:var(--accent); color:#fff; font-weight:600; }
.ncrm-badge{ width:22px; height:22px; min-width:22px; border-radius:6px; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:700; color:#fff; }
.ncrm-children{ display:none; padding-left:40px; }
.ncrm-children.open{ display:block; }
.ncrm-child-item{ padding:7px 18px 7px 0; font-size:12.5px; cursor:pointer; color:#b9c6d8; }
.ncrm-child-item:hover{ color:#fff; }
.ncrm-child-item.active{ color:#fff; font-weight:600; }
.ncrm-empty-sidebar{ padding:18px; font-size:12px; color:#8fa3bd; line-height:1.5; }

.ncrm-main{ display:flex; flex-direction:column; min-width:0; }
header.topbar{ background:var(--navy2); color:#fff; padding:10px 24px; display:flex; align-items:center; justify-content:space-between; gap:20px; }
header.topbar .who{ font-size:12px; color:#cfe0f2; display:flex; align-items:center; gap:14px; white-space:nowrap; }
header.topbar .logout-link{ color:#cfe0f2; cursor:pointer; text-decoration:underline; font-size:12px; }

/* ---------- GLOBAL SEARCH (topbar) ---------- */
.gs-wrap{ position:relative; display:flex; align-items:center; background:#fff; border-radius:8px; flex:1; max-width:480px; }
.gs-scope{ position:relative; }
.gs-scope-btn{ background:var(--tint); color:var(--navy); border:none; border-radius:8px 0 0 8px; padding:9px 12px; font-size:12px; font-weight:600; cursor:pointer; white-space:nowrap; }
.gs-scope-btn:hover{ background:#dfe9f7; }
.gs-scope-menu{ position:absolute; top:100%; left:0; min-width:200px; background:#fff; border-radius:0 0 8px 8px; box-shadow:0 8px 24px rgba(15,42,74,.18); display:none; z-index:61; }
.gs-scope-menu.open{ display:block; }
.gs-scope-item{ padding:10px 14px; font-size:12.5px; color:var(--text); cursor:pointer; border-top:1px solid var(--border); }
.gs-scope-item:first-child{ border-top:none; }
.gs-scope-item:hover{ background:var(--tint); color:var(--accent); }
.gs-input{ flex:1; border:none; border-radius:0 8px 8px 0; padding:9px 12px; font-size:12.5px; color:var(--text); min-width:0; }
.gs-input:focus{ outline:none; }
.gs-results{ position:absolute; top:100%; left:0; right:0; background:#fff; border-radius:0 0 8px 8px; box-shadow:0 8px 24px rgba(15,42,74,.18); max-height:320px; overflow-y:auto; display:none; z-index:60; }
.gs-results.open{ display:block; }
.gs-result-item{ padding:10px 14px; border-top:1px solid var(--border); cursor:pointer; }
.gs-result-item:hover{ background:#f8fafc; }
.gs-result-nm{ font-size:12.5px; font-weight:700; color:var(--text); }
.gs-result-meta{ font-size:11px; color:var(--muted); margin-top:2px; }
.gs-result-empty{ padding:14px; font-size:12px; color:var(--muted); text-align:center; }

.tb-icons{ display:flex; align-items:center; gap:16px; color:#cfe0f2; }
.tb-icons .tb-icon{ font-size:15px; cursor:default; position:relative; }
.tb-icons .tb-badge{ position:absolute; top:-6px; right:-8px; background:#e0554a; color:#fff; font-size:9px; font-weight:700; border-radius:8px; padding:1px 4px; }
.tb-session-timer{ font-size:11.5px; color:#cfe0f2; font-variant-numeric:tabular-nums; }
main{ max-width:1100px; width:100%; margin:0 auto; padding:24px 20px 60px; position:relative; }

/* Covers <main> between showApp() and the page's own ncrmOnReady() data
   fetch resolving -- without this there's a real blank gap, since the
   page's static markup (status tabs, empty containers, etc.) is visible
   but unpopulated until its own JS finishes fetching. */
.ncrm-content-loading{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; background:var(--bg); z-index:10; }
.ncrm-content-loading-text{ font-size:12.5px; color:var(--muted); }
.page-title{ font-size:19px; font-weight:700; color:var(--navy); margin:0 0 4px; }
.page-sub{ font-size:12.5px; color:var(--muted); margin:0 0 18px; }

.coming-soon{ background:#fff; border:1px dashed var(--border); border-radius:12px; padding:48px 24px; text-align:center; color:var(--muted); font-size:13.5px; }
.coming-soon .cs-title{ font-size:16px; font-weight:700; color:var(--navy); margin-bottom:6px; }

/* ---------- SHARED MODAL CHROME ----------
   Used by every page with a popup form (Filter Leads, Create Lead, Roles &
   Privileges' New Role/Duty/Privilege, User Management's New User/Reset
   Password). Each page still owns its own modal BODY layout/fields. */
.modal-overlay{ display:none; position:fixed; inset:0; background:rgba(15,42,74,.35); align-items:flex-start; justify-content:center; padding:40px 20px; z-index:50; }
.modal-overlay.open{ display:flex; }
.create-lead-modal{ background:#fff; border-radius:12px; width:100%; max-width:640px; max-height:85vh; display:flex; flex-direction:column; overflow:hidden; }
.filter-modal-head{ background:var(--tint); padding:14px 20px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); }
.filter-modal-head h2{ font-size:15px; margin:0; color:var(--navy); }
.filter-modal-head .close{ cursor:pointer; color:var(--muted); font-size:16px; background:none; border:none; }
.create-lead-body{ flex:1; overflow-y:auto; padding:18px 20px; }
.create-lead-body .field input:disabled, .create-lead-body .field select:disabled{ background:#eef1f5; color:var(--off); cursor:not-allowed; }
.create-lead-err{ color:#b3261e; font-size:12.5px; margin-top:4px; display:none; }
.filter-modal-foot{ padding:14px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; }

/* ---------- RAISE A TICKET (floating, all pages) ---------- */
.rt-fab{ position:fixed; right:24px; bottom:24px; z-index:40; background:var(--navy); color:#fff; border:none; border-radius:24px; padding:10px 16px 10px 14px; font-size:12.5px; font-weight:700; display:flex; align-items:center; gap:7px; cursor:pointer; box-shadow:0 4px 14px rgba(15,42,74,.28); }
.rt-fab:hover{ background:var(--navy2); }
.rt-fab .rt-fab-icon{ font-size:15px; }
.rt-success{ text-align:center; padding:30px 10px; color:var(--ok); font-size:13.5px; }
