:root {
  --p-blue:#004a99;
  --crm-header-bg:linear-gradient(to left,#0a5dab 0%,#004a99 52%,#003b7d 100%);
  --a-cyan:#00d2ff;
  --sidebar-w:250px;
  --header-h:70px;
  --footer-h:34px;
  --crm-bg:#f1f4f9;
  --crm-surface:#fff;
  --crm-border:#e5e7eb;
  --crm-text:#0f172a;
  --crm-muted:#64748b;
  --crm-primary:#07569f;
  --crm-primary-hover:#064985;
  --crm-success:#10b981;
  --crm-warning:#f59e0b;
  --crm-danger:#c62828;
  --crm-radius:12px;
  --crm-radius-lg:16px;
  --crm-shadow:0 8px 18px rgba(0,0,0,.08);
  --crm-shadow-card:0 8px 24px rgba(15,23,42,.06);
  --crm-shadow-modal:0 24px 60px rgba(15,23,42,.28);
  --crm-focus-ring:0 0 0 4px rgba(0,74,153,.14);
}
*{box-sizing:border-box}
html,body{margin:0;min-width:320px;min-height:100%;font-family:Inter,"Segoe UI",system-ui,-apple-system,BlinkMacSystemFont,sans-serif;color:var(--crm-text);background:var(--crm-bg);-webkit-font-smoothing:antialiased}
a{color:inherit}.app-shell{min-height:100vh}.main-area{min-width:0}
svg{display:block;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}

/* CloudCRM-derived application shell */
.top-navbar{height:var(--header-h);background:var(--crm-header-bg);color:#fff;display:flex;align-items:center;justify-content:space-between;padding:0 24px 0 18px;position:fixed;inset:0 0 auto 0;z-index:2000;box-shadow:0 2px 10px rgba(0,0,0,.10)}
.logo-area{display:flex;align-items:center;min-width:320px}.mobile-nav-toggle{width:42px;height:42px;margin-right:12px;padding:9px;border:0;border-radius:10px;background:transparent;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center}.mobile-nav-toggle:hover{background:rgba(255,255,255,.12)}.mobile-nav-toggle svg{width:22px;height:22px}
.foundation-brand{display:flex;align-items:center;gap:11px;color:#fff;text-decoration:none}.foundation-brand__mark{width:38px;height:38px;border:1px solid rgba(255,255,255,.45);border-radius:10px;display:grid;place-items:center;background:rgba(255,255,255,.12);font-size:22px;font-weight:850;box-shadow:inset 0 1px rgba(255,255,255,.15)}.foundation-brand__copy{display:flex;flex-direction:column;line-height:1.05}.foundation-brand__copy strong{font-size:18px;font-weight:760;letter-spacing:-.01em}.foundation-brand__copy small{margin-top:5px;color:rgba(255,255,255,.68);font-size:9px;font-weight:800;letter-spacing:.16em}
.header-right{display:flex;align-items:center;gap:18px;margin-left:auto}.header-profile-link{display:flex;align-items:center;gap:10px;padding-left:18px;border-left:1px solid rgba(255,255,255,.22);text-decoration:none;color:#fff}.header-profile-link:hover{opacity:.86}.header-profile-icon{width:22px;color:var(--a-cyan)}.header-profile-icon svg{width:22px;height:22px}.header-user-name{font-size:14px;font-weight:550}.header-clock{display:flex;flex-direction:column;min-width:92px;padding-left:18px;border-left:1px solid rgba(255,255,255,.25);text-align:right;line-height:1.15;color:#fff}.header-clock strong{font-size:14px}.header-clock span{margin-top:3px;font-size:10px;opacity:.78}.header-logout-form{margin:0}.header-icon-button{width:38px;height:38px;padding:8px;border:0;border-radius:10px;background:transparent;color:#fff;cursor:pointer}.header-icon-button:hover{background:rgba(255,255,255,.12)}.header-icon-button svg{width:21px;height:21px}

.sidebar-new{width:var(--sidebar-w);background:linear-gradient(180deg,#f8fbff 0,#fff 180px);border-right:1px solid #e0e8f1;box-shadow:3px 0 16px rgba(30,64,100,.025);position:fixed;top:var(--header-h);left:0;bottom:var(--footer-h);z-index:999;overflow-y:auto;padding:10px 0;display:flex;flex-direction:column;scrollbar-width:thin}.sidebar-nav{display:flex;flex-direction:column}.sidebar-section{padding:0 10px}.sidebar-label{padding:20px 12px 8px;color:#65758b;font-size:10px;font-weight:900;text-transform:uppercase;letter-spacing:.08em}.sidebar-link{position:relative;display:flex;align-items:center;min-height:42px;margin:3px 0;padding:10px 12px;border-radius:10px;gap:9px;color:#334155;text-decoration:none;font-size:13px;font-weight:550;line-height:1.3;transition:background .15s,color .15s,box-shadow .15s}.sidebar-link:hover{background:#edf4fb;color:#004a99}.sidebar-link.active{background:#e8f1fc;color:#004a99;box-shadow:inset 3px 0 #1764b0;font-weight:750}.sidebar-link:focus-visible{outline:2px solid #1764b0;outline-offset:2px}.sidebar-icon{display:grid;place-items:center;flex:0 0 22px;width:22px;color:#64748b}.sidebar-icon svg{width:18px;height:18px}.sidebar-link:hover .sidebar-icon,.sidebar-link.active .sidebar-icon{color:#004a99}.sidebar-link__label{flex:1;min-width:0}.sidebar-foot{margin-top:auto;display:flex;align-items:center;gap:9px;margin-inline:10px;padding:15px 12px;border-top:1px solid #e7edf4;color:#526174}.sidebar-foot__mark{width:28px;height:28px;border-radius:8px;background:#e8f1fc;color:#07569f;display:grid;place-items:center;font-weight:850}.sidebar-foot>span:last-child{display:flex;flex-direction:column}.sidebar-foot strong{font-size:12px}.sidebar-foot small{margin-top:2px;font-size:9px;color:#94a3b8}

.content{margin-left:var(--sidebar-w);padding:38px 34px calc(var(--footer-h) + 34px);padding-top:calc(var(--header-h) + 38px);min-height:calc(100vh - var(--footer-h));max-width:none}.content>*{max-width:1500px;margin-left:auto;margin-right:auto}.foundation-footer{position:fixed;z-index:850;left:var(--sidebar-w);right:0;bottom:0;height:var(--footer-h);display:flex;align-items:center;justify-content:flex-end;padding:0 22px;border-top:1px solid #e2e8f0;background:rgba(255,255,255,.95);backdrop-filter:blur(8px);color:#8a97a8;font-size:10px;font-weight:650;letter-spacing:.03em}

/* Page structure */
.page-head{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;margin-bottom:24px}.page-eyebrow{display:block;margin-bottom:6px;color:#1764b0;font-size:10px;font-weight:850;letter-spacing:.12em}.page-head h1{margin:0;color:#14203a;font-size:27px;font-weight:780;letter-spacing:-.025em}.page-head p{margin:7px 0 0;color:var(--crm-muted);font-size:14px;font-weight:500}.dashboard-head{margin-bottom:20px}
.card,.stat-card,.empty-state{background:#fff;border:1px solid var(--crm-border);border-radius:var(--crm-radius);box-shadow:var(--crm-shadow-card)}.card{padding:20px;margin-bottom:18px}.card-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:-20px -20px 18px;padding:16px 20px;border-bottom:1px solid var(--crm-border);background:linear-gradient(to bottom,#f8fbff,#fff);border-radius:12px 12px 0 0}.card-head h2{margin:0;color:#334155;font-size:14px;font-weight:800;text-transform:uppercase;letter-spacing:.04em}.dashboard-empty-card{padding:0;overflow:hidden}.empty-state{min-height:390px;border:0;box-shadow:none;border-radius:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:44px;text-align:center;color:var(--crm-muted);background:linear-gradient(180deg,#fff,#fbfdff)}.empty-state h2{margin:15px 0 6px;color:#14203a;font-size:20px}.empty-state p{max-width:560px;margin:0;line-height:1.55}.empty-icon{width:54px;height:54px;border-radius:14px;display:grid;place-items:center;background:#e8f4ff;color:#07569f}.empty-icon svg{width:25px;height:25px}
.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:18px}.stat-card{padding:19px 20px;position:relative;overflow:hidden}.stat-card:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:#1764b0}.stat-card span{display:block;margin-bottom:8px;color:var(--crm-muted);font-size:12px;font-weight:650}.stat-card strong{color:#14203a;font-size:23px;font-weight:800}.grid-2{display:grid;grid-template-columns:1.35fr .65fr;gap:18px;margin-bottom:18px}

/* Buttons: same visual language as CloudCRM */
.button{display:inline-flex;align-items:center;justify-content:center;gap:.55rem;min-height:42px;padding:.65rem 1rem;border:1px solid transparent;border-radius:12px;font:inherit;font-weight:800;line-height:1.1;text-decoration:none;cursor:pointer;user-select:none;box-shadow:0 4px 10px rgba(7,86,159,.14);transform:translateY(0) scale(1);transition:background-color .16s,border-color .16s,color .16s,box-shadow .16s,transform .08s}.button-primary{color:#fff!important;background:#07569f!important;border-color:#07569f!important}.button-primary:hover:not(:disabled){background:#064985!important;border-color:#064985!important;box-shadow:0 7px 16px rgba(7,86,159,.2);transform:translateY(-1px)}.button-secondary,.button-ghost,.button.secondary,.button.ghost{color:#07569f!important;background:#e8f4ff!important;border-color:#bddcff!important;box-shadow:0 3px 8px rgba(7,86,159,.09)}.button-secondary:hover:not(:disabled),.button-ghost:hover:not(:disabled){background:#d8ecff!important;border-color:#91c6f7!important;transform:translateY(-1px)}.button-danger,.button.danger{color:#fff!important;background:#c62828!important;border-color:#c62828!important}.button:active:not(:disabled){transform:translateY(2px) scale(.985)!important;box-shadow:inset 0 3px 7px rgba(15,23,42,.22),0 1px 2px rgba(15,23,42,.1)!important}.button:focus-visible{outline:3px solid rgba(14,116,190,.24);outline-offset:2px}.button[disabled]{opacity:.52;cursor:not-allowed;transform:none!important;box-shadow:none!important}.button.full{width:100%;padding:13px}.button.small{min-height:34px;padding:7px 10px;border-radius:9px;font-size:12px}

/* Tables and forms */
.table-card{overflow:auto;padding:0}.table-card .card-head{margin:0}.table-card>p{padding:0 20px 20px}table{border-collapse:collapse;width:100%;font-size:13px;background:#fff}th,td{padding:13px 16px;border-bottom:1px solid #edf1f5;text-align:left;white-space:nowrap}th{background:#f8fafc;color:#64748b;font-size:10px;font-weight:850;text-transform:uppercase;letter-spacing:.06em}tbody tr:hover{background:#f8fbff}.right{text-align:right}.badge{display:inline-flex;padding:4px 8px;border-radius:999px;font-size:11px;font-weight:800}.badge-ok{background:#eaf7ef;color:#18794e}.badge-muted{background:#f1f5f9;color:#64748b}.muted{color:var(--crm-muted)}code{padding:2px 5px;border-radius:5px;background:#f1f5f9;color:#334155}.notice,.error-box{padding:12px 14px;border:1px solid #cfe0f4;border-left:4px solid #1764b0;border-radius:10px;margin-bottom:16px;background:#f8fbff;color:#184a77}.error-box{border-color:#f4cccc;border-left-color:#c62828;background:#fff7f7;color:#a82532}
.role-form select,.modal-form input,.modal-form select,.modal-form textarea,.filter-form input,.filter-form select{display:block;width:100%;margin-top:7px;padding:11px 12px;border:1px solid #d6dce5;border-radius:8px;background:#fff;color:#172033;font:inherit;outline:none;transition:border-color .18s,box-shadow .18s}.modal-form input:focus,.modal-form select:focus,.modal-form textarea:focus,.filter-form input:focus,.filter-form select:focus{border-color:#0864d8;box-shadow:0 0 0 4px rgba(8,100,216,.12)}

/* Roles / system */
.role-list{border:1px solid #e7edf4;border-radius:10px;overflow:hidden}.role-row{display:flex;align-items:center;justify-content:space-between;padding:12px 13px;text-decoration:none;border-top:1px solid #edf1f5;background:#fff}.role-row:first-child{border-top:0}.role-row:hover{background:#f8fbff}.role-row.selected{background:#e8f1fc;color:#07569f}.role-row span:first-child{display:flex;flex-direction:column;gap:3px}.role-row small,.permission-checks small,.module-list small{display:block;color:#667085;font-size:11px}.rights-editor{margin-top:18px;padding-top:16px;border-top:1px solid #eaecf0}.rights-editor h3{margin:0 0 10px}.permission-checks{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:14px 0}.permission-checks label{display:flex;gap:9px;align-items:flex-start;border:1px solid #e5eaf0;border-radius:9px;padding:10px;background:#fff;cursor:pointer}.permission-checks label:hover{background:#f8fbff;border-color:#cfe0f4}.permission-checks input{margin-top:3px}.system-list{margin:0}.system-list div{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid #edf1f5}.system-list div:last-child{border-bottom:0}.system-list dt{color:var(--crm-muted)}.system-list dd{margin:0;font-weight:800}.module-list>div{display:flex;justify-content:space-between;padding:11px 0;border-top:1px solid #edf1f5}.module-list>div:first-child{border-top:0}.module-list>div>span{display:flex;flex-direction:column;gap:2px}
.system-tabs{display:flex;gap:26px;margin:0 0 24px;padding:0;border-bottom:2px solid #e2e8f0;overflow-x:auto}.system-tab{padding:11px 4px;color:#64748b;text-decoration:none;font-size:13px;font-weight:700;border-bottom:3px solid transparent;margin-bottom:-2px;white-space:nowrap}.system-tab:hover{color:#07569f}.system-tab.active{color:#07569f;border-bottom-color:#07569f}.filter-form{display:grid;grid-template-columns:160px 160px minmax(240px,1fr) auto;gap:12px;align-items:end}.filter-form label{font-size:12px;font-weight:700;color:#475569}.filter-actions{padding-bottom:1px}.log-toolbar{padding:18px}.log-message{max-width:420px;overflow:hidden;text-overflow:ellipsis}.log-level{display:inline-flex;padding:4px 7px;border-radius:6px;font-size:10px;font-weight:850;background:#f1f5f9;color:#475569}.level-warning,.level-high{background:#fff4e5;color:#9a5200}.level-error,.level-critical{background:#fef3f2;color:#b42318}.level-info,.level-notice{background:#e8f1fc;color:#07569f}.log-detail-list{margin:0}.log-detail-list div{display:grid;grid-template-columns:120px 1fr;gap:12px;padding:7px 0;border-bottom:1px solid #edf0f4}.log-detail-list dt{color:var(--crm-muted)}.log-detail-list dd{margin:0;font-weight:650;overflow-wrap:anywhere}.log-pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e5e7eb;border-radius:8px;padding:12px;max-height:240px;overflow:auto;font-size:12px}

/* Foundation modals in CloudCRM dialog style */
dialog.foundation-modal{border:0;padding:0;max-height:min(90vh,920px);overflow:hidden;border-radius:20px;background:#f4f7fb;box-shadow:var(--crm-shadow-modal);color:var(--crm-text)}dialog.foundation-modal::backdrop{background:rgba(15,23,42,.5);backdrop-filter:blur(2px)}.foundation-modal.modal-sm{width:min(520px,calc(100% - 32px))}.foundation-modal.modal-md{width:min(720px,calc(100% - 32px))}.foundation-modal.modal-lg{width:min(980px,calc(100% - 36px))}.foundation-modal.modal-xl{width:min(1260px,calc(100% - 40px))}.modal-shell{max-height:88vh;overflow:auto;background:#fff}.dialog-head{position:sticky;top:0;z-index:2;display:flex;align-items:center;justify-content:space-between;gap:14px;padding:17px 20px;border-bottom:1px solid #e2e8f0;background:linear-gradient(to bottom,#eaf6ff 0%,#f7fbff 58%,#fff 100%)}.dialog-head h2{margin:0;color:#14203a;font-size:16px;font-weight:800}.modal-danger .dialog-head h2{color:#b91c1c}.dialog-close{display:grid;place-items:center;width:40px;height:40px;border:1px solid #bddcff;border-radius:12px;background:#e8f4ff;color:#07569f;font-size:23px;line-height:1;cursor:pointer}.dialog-close:hover{background:#d8ecff}.modal-body{padding:22px;color:#334155}.modal-body h3{font-size:14px;margin:18px 0 8px}.modal-form label{display:block;font-weight:700;font-size:13px;margin:14px 0}.modal-form textarea{resize:vertical}.dialog-actions{display:flex;justify-content:flex-end;gap:10px;padding:14px 20px;border-top:1px solid #e2e8f0;background:#f8fafc}

/* Login portal: same shell language, neutral Foundation content */
body.auth-page{min-height:100vh;min-height:100dvh;margin:0;background:#f5f6f8}.auth-shell{display:grid;grid-template-columns:minmax(500px,1fr) minmax(500px,1fr);min-height:100vh;min-height:100dvh}.auth-brand-panel{position:relative;isolation:isolate;display:flex;flex-direction:column;min-width:0;min-height:100%;padding:clamp(36px,5.5vh,62px) clamp(42px,6.2vw,98px) 38px;overflow:hidden;color:#fff;background:radial-gradient(100% 72% at 8% 4%,rgba(20,104,222,.55) 0%,transparent 58%),linear-gradient(145deg,#0b4db3 0%,#063c8e 52%,#043273 100%)}.auth-brand-panel:before,.auth-brand-panel:after{content:"";position:absolute;z-index:-1;left:-24%;width:148%;border-radius:50%;pointer-events:none}.auth-brand-panel:before{bottom:-15%;height:31%;background:rgba(20,92,200,.72);transform:rotate(6deg)}.auth-brand-panel:after{right:-30%;bottom:-22%;left:auto;width:138%;height:34%;background:rgba(14,76,173,.78);transform:rotate(-8deg)}.auth-foundation-brand{display:flex;align-items:center;gap:13px}.auth-foundation-brand>span{width:48px;height:48px;display:grid;place-items:center;border:1px solid rgba(255,255,255,.45);border-radius:13px;background:rgba(255,255,255,.12);font-size:27px;font-weight:850}.auth-foundation-brand>div{display:flex;flex-direction:column}.auth-foundation-brand strong{font-size:21px}.auth-foundation-brand small{margin-top:4px;font-size:9px;font-weight:850;letter-spacing:.18em;color:rgba(255,255,255,.7)}.auth-brand-copy{width:min(100%,560px);margin-top:clamp(80px,11vh,145px)}.auth-brand-copy h1{margin:0;color:#fff;font-size:clamp(30px,2.25vw,42px);font-weight:760;line-height:1.16;letter-spacing:-.025em}.auth-brand-copy>p{max-width:520px;margin:18px 0 0;color:rgba(255,255,255,.9);font-size:clamp(17px,1.15vw,21px);line-height:1.55}.auth-benefits{display:grid;gap:clamp(24px,3.2vh,38px);margin:clamp(48px,6.5vh,76px) 0 0;padding:0;list-style:none}.auth-benefits li{display:grid;grid-template-columns:52px minmax(0,1fr);align-items:start;gap:20px}.auth-benefit-icon{display:grid;place-items:center;width:50px;height:50px;color:#fff;border:1px solid rgba(255,255,255,.28);border-radius:14px;background:rgba(255,255,255,.08);font-size:12px;font-weight:850;letter-spacing:.05em}.auth-benefits li>span:last-child{color:rgba(255,255,255,.84);font-size:15px;line-height:1.55}.auth-benefits strong{display:block;margin:0 0 5px;color:#fff;font-size:17px;font-weight:760}.auth-brand-meta{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-top:auto;padding-top:36px;color:rgba(255,255,255,.72);font-size:12px}.auth-main{min-width:0;display:flex;flex-direction:column;background:#f5f6f8}.auth-main-inner{display:grid;place-items:center;width:100%;margin:auto;padding:clamp(40px,7vh,82px) clamp(24px,5vw,76px) 34px}.login-card{width:min(100%,480px);margin:0;padding:clamp(30px,3.4vw,44px);border:1px solid rgba(208,215,224,.92);border-radius:15px;background:rgba(255,255,255,.98);box-shadow:0 18px 46px rgba(15,32,55,.11)}.login-eyebrow{margin-bottom:9px;color:#07569f;font-size:10px;font-weight:850;letter-spacing:.14em}.login-card h1{margin:0;color:#101828;font-size:clamp(27px,1.8vw,31px);font-weight:780;letter-spacing:-.025em}.login-card>p{margin:12px 0 29px;color:#5f6b7c;font-size:15px;line-height:1.55}.auth-form{display:grid;gap:18px}.login-card label{display:block;margin:0;color:#101828;font-size:14px;font-weight:720}.login-card input{display:block;width:100%;min-height:54px;margin-top:8px;padding:13px 16px;border:1px solid #d6dce5;border-radius:8px;outline:none;color:#172033;background:#fff;font:inherit;font-size:16px;transition:border-color .18s,box-shadow .18s}.login-card input:focus{border-color:#0864d8;box-shadow:0 0 0 4px rgba(8,100,216,.2)}.login-foot{margin-top:24px;padding-top:18px;border-top:1px solid #edf0f4;text-align:center;color:#98a2b3;font-size:11px}

@media(max-width:1024px){.auth-shell{grid-template-columns:minmax(390px,.9fr) minmax(430px,1.1fr)}.auth-brand-panel{padding-left:42px;padding-right:42px}.header-user-name{display:none}.logo-area{min-width:auto}}
@media(max-width:900px){.sidebar-new{transform:translateX(-100%);transition:transform .2s ease;box-shadow:8px 0 30px rgba(15,23,42,.16)}body.nav-open .sidebar-new{transform:translateX(0)}.content{margin-left:0;padding-left:20px;padding-right:20px}.foundation-footer{left:0}.stats-grid{grid-template-columns:1fr 1fr}.grid-2{grid-template-columns:1fr}.permission-checks{grid-template-columns:1fr}.filter-form{grid-template-columns:1fr 1fr}.filter-search,.filter-actions{grid-column:1/-1}}
@media(max-width:800px){.auth-shell{display:block}.auth-brand-panel{display:none}.auth-main{min-height:100vh;min-height:100dvh}.auth-main-inner{min-height:100vh;min-height:100dvh}.header-clock{display:none}.header-profile-link{padding-left:0;border-left:0}}
@media(max-width:600px){.top-navbar{padding:0 12px}.foundation-brand__copy small{display:none}.foundation-brand__copy strong{font-size:16px}.header-right{gap:8px}.header-profile-link{display:none}.content{padding-left:14px;padding-right:14px;padding-top:calc(var(--header-h) + 24px)}.stats-grid{grid-template-columns:1fr}.page-head{flex-direction:column}.filter-form{grid-template-columns:1fr}.filter-search,.filter-actions{grid-column:auto}.log-detail-list div{grid-template-columns:1fr;gap:3px}.dialog-actions{flex-direction:column-reverse}.dialog-actions .button{width:100%}.foundation-footer{justify-content:center;padding:0 8px}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important}}
