
:root{
    --bg:#f5f7fa;
    --panel:#ffffff;
    --soft:#f8fafc;
    --text:#1f2937;
    --muted:#6b7280;
    --line:#e3e8ef;
    --navy:#173a63;
    --navy2:#244f7c;
    --blue:#2f6fed;
    --blue-soft:#edf4ff;
    --green:#16814a;
    --green-soft:#edf9f2;
    --amber:#a16207;
    --amber-soft:#fff8e7;
    --red:#b42318;
    --red-soft:#fff1ef;
    --purple:#6d5bd0;
    --teal:#0f766e;
    --shadow:0 8px 24px rgba(15,23,42,.06);
    --radius:14px;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
    margin:0;
    font-family:Inter,Segoe UI,Arial,sans-serif;
    background:var(--bg);
    color:var(--text);
    line-height:1.45;
}
button,input,select,textarea{font:inherit}
a{color:inherit}
code{
    background:#eef2f6;
    padding:2px 5px;
    border-radius:5px;
    color:#425466;
    font-size:10px;
}

/* =========================
   GLOBAL HEADER
   ========================= */
.topbar{
    background:linear-gradient(135deg,var(--navy),var(--navy2));
    color:#fff;
    box-shadow:0 3px 14px rgba(15,23,42,.16);
}
.topbar-inner{
    max-width:1580px;
    margin:auto;
    padding:10px 18px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
}
.brand{
    display:flex;
    align-items:center;
    gap:11px;
    text-decoration:none;
}
.brand-logo-box{
    flex:0 0 62px !important;
    width:62px !important;
    height:40px !important;
    min-width:62px !important;
    max-width:62px !important;
    min-height:40px !important;
    max-height:40px !important;
    background:#fff;
    border-radius:8px;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    padding:3px 4px !important;
    overflow:hidden !important;
    box-shadow:0 3px 10px rgba(0,0,0,.12);
}
.cecb-header-logo,
.brand-logo-box img{
    display:block !important;
    width:54px !important;
    height:34px !important;
    min-width:54px !important;
    max-width:54px !important;
    min-height:34px !important;
    max-height:34px !important;
    object-fit:contain !important;
}
.brand-copy strong{
    display:block;
    font-size:14px;
}
.brand-copy small{
    display:block;
    margin-top:2px;
    font-size:10px;
    opacity:.74;
}
.nav{
    display:flex;
    gap:5px;
    flex-wrap:wrap;
}
.nav a{
    text-decoration:none;
    padding:7px 10px;
    border-radius:8px;
    font-size:11px;
    color:rgba(255,255,255,.86);
}
.nav a:hover,.nav a.active{
    background:rgba(255,255,255,.14);
    color:#fff;
}

/* =========================
   PAGE STRUCTURE
   ========================= */
.page{
    max-width:1580px;
    margin:0 auto;
    padding:18px 18px 50px;
}
.page-head{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:16px;
    box-shadow:var(--shadow);
    padding:16px 17px;
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    margin-bottom:13px;
}
.page-head h1{
    margin:0;
    color:var(--navy);
    font-size:24px;
    letter-spacing:-.3px;
}
.page-head h2{
    margin:0;
    color:var(--navy);
    font-size:17px;
}
.page-head p{
    margin:5px 0 0;
    color:var(--muted);
    font-size:11px;
}
.actions{
    display:flex;
    gap:7px;
    flex-wrap:wrap;
    align-items:center;
}
.btn{
    border:1px solid transparent;
    border-radius:9px;
    min-height:34px;
    padding:7px 11px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:5px;
    background:#fff;
    color:#334155;
    font-size:10.5px;
    font-weight:800;
    text-decoration:none;
    cursor:pointer;
    white-space:nowrap;
}
.btn-primary{background:var(--navy);color:#fff}
.btn-soft{border-color:#d7e0ea;background:#fff}
.btn-success{background:var(--green-soft);border-color:#bce6ca;color:#166534}
.btn:disabled{opacity:.45;cursor:not-allowed}

/* =========================
   NOTICES
   ========================= */
.notice{
    padding:10px 12px;
    border-radius:10px;
    margin:0 0 12px;
    font-size:10.8px;
    border:1px solid;
}
.notice-ok{background:var(--green-soft);border-color:#bce6ca;color:#166534}
.notice-warn{background:var(--amber-soft);border-color:#ecd598;color:#92400e}
.notice-error{background:var(--red-soft);border-color:#efbbb5;color:#991b1b}

/* =========================
   DASHBOARD CARDS
   ========================= */
.grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:10px;
}
.card{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:12px;
    box-shadow:0 3px 12px rgba(15,23,42,.035);
}
.stat{
    padding:12px 13px;
    position:relative;
    overflow:hidden;
}
.stat:before{
    content:"";
    position:absolute;
    left:0;
    top:0;
    bottom:0;
    width:4px;
    background:var(--blue);
}
.stat:nth-child(2):before{background:var(--green)}
.stat:nth-child(3):before{background:var(--purple)}
.stat:nth-child(4):before{background:var(--amber)}
.stat:nth-child(5):before{background:var(--teal)}
.stat:nth-child(6):before{background:#9f1239}
.stat:nth-child(7):before{background:#5b6472}
.stat:nth-child(8):before{background:#dd7a1f}
.stat .label{
    color:#7b8795;
    font-size:8.4px;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.45px;
}
.stat .value{
    font-size:23px;
    font-weight:900;
    color:var(--navy);
    margin-top:3px;
    line-height:1.05;
}
.stat .sub{
    font-size:9px;
    color:var(--muted);
    margin-top:4px;
}
.section{
    padding:14px;
    margin-top:13px;
}
.section h2{
    font-size:15px;
    margin:0 0 10px;
    color:var(--navy);
}
.profile-list{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px;
}
.profile-item{
    border:1px solid #e6ebf1;
    border-radius:9px;
    padding:9px 10px;
    display:flex;
    justify-content:space-between;
    gap:10px;
    align-items:center;
    background:#fbfcfe;
}
.profile-item:hover{background:#f7faff;border-color:#d5e0ec}
.name{
    font-weight:900;
    color:#24364b;
    font-size:11px;
}
.meta{
    color:var(--muted);
    font-size:9px;
    margin-top:2px;
}
.badge{
    display:inline-flex;
    align-items:center;
    padding:3px 6px;
    border-radius:999px;
    font-size:7.8px;
    font-weight:900;
    white-space:nowrap;
}
.badge-green{background:var(--green-soft);color:#166534}
.badge-blue{background:var(--blue-soft);color:#1d4ed8}
.badge-amber{background:var(--amber-soft);color:#92400e}
.badge-gray{background:#eef2f6;color:#475569}
.weight-good{color:var(--green);font-weight:900}
.weight-bad{color:var(--red);font-weight:900}

/* =========================
   FILTERS / FORM CONTROLS
   ========================= */
input,select,textarea{
    width:100%;
    border:1px solid #d6dfe9;
    border-radius:8px;
    padding:8px 9px;
    background:#fff;
    color:var(--text);
    font-size:10.5px;
}
input:focus,select:focus,textarea:focus{
    outline:none;
    border-color:#86afe8;
    box-shadow:0 0 0 3px rgba(47,111,237,.08);
}
.filters{
    display:grid;
    grid-template-columns:2fr repeat(4,1fr) auto;
    gap:7px;
    padding:9px;
    margin-bottom:11px;
    box-shadow:var(--shadow);
}
.filters .search{min-width:0}
.inline-form{
    display:grid;
    grid-template-columns:minmax(175px,1fr) 120px auto;
    gap:5px;
    align-items:center;
    min-width:390px;
}

/* =========================
   STAFF PROFILE ASSIGNMENT
   ========================= */
.mini-grid{
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:9px;
    margin-bottom:11px;
}
.mini-stat{
    background:#fff;
    border:1px solid var(--line);
    border-radius:11px;
    padding:10px 11px;
    box-shadow:0 3px 10px rgba(15,23,42,.03);
}
.mini-stat .v{
    font-size:20px;
    font-weight:900;
    color:var(--navy);
}
.mini-stat .k{
    margin-top:3px;
    font-size:8px;
    color:var(--muted);
    text-transform:uppercase;
    letter-spacing:.35px;
    font-weight:900;
}
.bulkbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    background:#f8fbff;
    border:1px solid #cfe0ff;
    border-radius:10px;
    padding:9px 10px;
    margin:0 0 10px;
    font-size:10px;
}
.bulkbar .left{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
}
.summary-bar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;
    margin:8px 0;
    color:var(--muted);
    font-size:9.5px;
}
.pagination{
    display:flex;
    gap:4px;
    flex-wrap:wrap;
    justify-content:flex-end;
}
.pagination a,.pagination span{
    min-width:29px;
    padding:5px 7px;
    border:1px solid var(--line);
    border-radius:7px;
    text-align:center;
    text-decoration:none;
    background:#fff;
    font-size:9px;
}
.pagination .current{
    background:var(--navy);
    color:#fff;
    border-color:var(--navy);
}
.table-wrap{
    overflow:auto;
    border:1px solid var(--line);
    border-radius:10px;
    background:#fff;
}
table{
    width:100%;
    border-collapse:collapse;
    min-width:900px;
}
th{
    text-align:left;
    padding:8px 9px;
    background:#eef3f8;
    color:#526172;
    font-size:7.8px;
    text-transform:uppercase;
    letter-spacing:.35px;
    border-bottom:1px solid var(--line);
    white-space:nowrap;
}
td{
    padding:8px 9px;
    border-bottom:1px solid #edf1f5;
    font-size:9.6px;
    vertical-align:top;
}
tr:last-child td{border-bottom:none}
tr:hover td{background:#fbfdff}
.checkbox-cell{
    width:34px;
    text-align:center;
}
.checkbox-cell input{
    width:auto;
    transform:scale(1.03);
}
.epf{
    font-family:Consolas,monospace;
    font-weight:900;
    color:#334155;
}
.details-box{margin-top:5px}
.details-box summary{
    cursor:pointer;
    color:#1d4ed8;
    font-size:8.5px;
    font-weight:800;
}
.factor-preview{
    margin-top:5px;
    padding:6px 7px;
    background:#f8fafc;
    border:1px solid #e7edf4;
    border-radius:7px;
    max-width:350px;
}
.factor-preview div{
    display:flex;
    justify-content:space-between;
    gap:8px;
    font-size:8px;
    padding:2px 0;
}
.factor-preview strong{white-space:nowrap}

/* =========================
   PROFILE BUILDER
   ========================= */
.builder-layout{
    display:grid;
    grid-template-columns:300px minmax(0,1fr);
    gap:13px;
    align-items:start;
}
.profile-side{
    position:sticky;
    top:12px;
}
.profile-side a{
    display:block;
    text-decoration:none;
    padding:8px 9px;
    border-radius:8px;
    border:1px solid transparent;
    margin-bottom:4px;
    font-size:9.5px;
}
.profile-side a:hover{
    background:#f5f8fc;
    border-color:var(--line);
}
.profile-side a.active{
    background:#edf4ff;
    border-color:#cfe0ff;
    color:#1d4ed8;
    font-weight:900;
}
.profile-meta{
    display:flex;
    gap:5px;
    flex-wrap:wrap;
    margin-top:6px;
}
.builder-total{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    padding:9px 11px;
    border:1px solid var(--line);
    border-radius:9px;
    background:#f8fafc;
    margin-bottom:10px;
}
.builder-total .number{
    font-size:22px;
    font-weight:900;
}
.builder-total.good{
    background:var(--green-soft);
    border-color:#bce6ca;
}
.builder-total.good .number{color:#166534}
.builder-total.bad{
    background:var(--red-soft);
    border-color:#efbbb5;
}
.builder-total.bad .number{color:var(--red)}
.factor-table input[type="number"]{min-width:72px}
.factor-table .target-text{min-width:155px}
.factor-table .sort-input{width:64px}
.factor-name{
    font-weight:900;
    color:#24364b;
    font-size:9.7px;
}
.factor-sub{
    margin-top:2px;
    font-size:7.8px;
    color:var(--muted);
}
.add-factor{
    display:grid;
    grid-template-columns:minmax(250px,1fr) auto;
    gap:7px;
    align-items:center;
}
.inline-note{
    font-size:9px;
    color:var(--muted);
}

/* =========================
   FOOTER
   ========================= */
.footer{
    max-width:1580px;
    margin:0 auto;
    padding:0 18px 18px;
    color:#8a94a3;
    font-size:9px;
}
.footer>div{
    border-top:1px solid #dde4ec;
    padding-top:12px;
    display:flex;
    justify-content:space-between;
    gap:10px;
}
.footer strong{color:#64748b}

/* =========================
   RESPONSIVE
   ========================= */
@media(max-width:1100px){
    .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
    .mini-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
    .filters{grid-template-columns:1fr 1fr}
    .filters .search{grid-column:1/-1}
    .builder-layout{grid-template-columns:1fr}
    .profile-side{position:static}
}
@media(max-width:760px){
    .topbar-inner,.page-head{
        flex-direction:column;
        align-items:stretch;
    }
    .brand-logo-box{flex-basis:58px !important;width:58px !important;height:38px !important;min-width:58px !important;max-width:58px !important;min-height:38px !important;max-height:38px !important}
    .cecb-header-logo,.brand-logo-box img{width:50px !important;height:31px !important;min-width:50px !important;max-width:50px !important;min-height:31px !important;max-height:31px !important}
    .page{padding:14px 10px 40px}
    .grid,.profile-list,.mini-grid{grid-template-columns:1fr}
    .filters{grid-template-columns:1fr}
    .filters .search{grid-column:auto}
    .bulkbar{align-items:flex-start;flex-direction:column}
    .add-factor{grid-template-columns:1fr}
    .footer{padding:0 10px 14px}
    .footer>div{flex-direction:column}
}
