* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(1200px 600px at 20% -10%, #0f2a3d 0%, #0b1f2f 45%, #071522 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #334155;
    padding: 24px;
}

.portal-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; }

.portal-card {
    width: 100%;
    background: #ffffff;
    border-radius: 18px;
    padding: 36px 34px 30px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #0f172a;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 26px;
}

.portal-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff9e2c, #ff6a00);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.portal-title { font-family: 'Montserrat', sans-serif; font-size: 24px; font-weight: 700; color: #0f172a; }

.portal-blurb { color: #64748b; font-size: 14px; margin: 8px 0 22px; line-height: 1.55; }

.portal-alert {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13.5px;
    margin-bottom: 18px;
}

.portal-label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin: 0 0 6px; }

.portal-input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.portal-input:focus { border-color: #ff9e2c; box-shadow: 0 0 0 3px rgba(255, 158, 44, 0.18); }

.portal-btn {
    width: 100%;
    padding: 13px;
    margin-top: 4px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff9e2c, #ff6a00);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
}

.portal-btn:hover { box-shadow: 0 8px 20px rgba(255, 106, 0, 0.35); transform: translateY(-1px); }

.portal-meta { text-align: center; margin-top: 20px; font-size: 13.5px; }

.portal-meta a, .portal-foot a { color: #ff6a00; text-decoration: none; font-weight: 600; }

.portal-meta a:hover, .portal-foot a:hover { text-decoration: underline; }

.portal-foot { color: #94a3b8; font-size: 13px; margin-top: 20px; }

.portal-foot a { color: #cbd5e1; }

/* Signup form extras */
.portal-hint { font-size: 12.5px; color: #94a3b8; margin: -6px 0 16px; }

.portal-check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: #64748b; margin: 4px 0 20px; cursor: pointer; }

.portal-check input { width: 16px; height: 16px; margin: 1px 0 0; flex-shrink: 0; accent-color: #ff6a00; cursor: pointer; }

.portal-check a { color: #ff6a00; font-weight: 600; }

/* =================================================================== */
/*  SERVER-RENDERED PORTAL LAYOUT (separate pages, no JS dashboards)   */
/* =================================================================== */

.portal-body {
    background: #f2f4f8;
    color: #334155;
    display: block;
    padding: 0;
    align-items: initial;
    justify-content: initial;
}

/* ---------- TOPBAR ---------- */
.portal-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 66px;
    background: #ffffff;
    border-bottom: 1px solid #e6e9ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(11, 31, 47, 0.06);
}

.pt-brand { font-family: 'Montserrat', sans-serif; font-size: 17px; font-weight: 700; color: #0f172a; }
.pt-brand a { text-decoration: none; color: #0f172a; }
.pt-brand-spark { color: #ff9e2c; }

.pt-right { display: flex; align-items: center; gap: 18px; }
.pt-user { text-align: right; }
.pt-user-name { font-size: 13.5px; font-weight: 700; color: #0f172a; }
.pt-user-meta { font-size: 11.5px; color: #64748b; }
.pt-logout {
    padding: 8px 15px;
    background: #e5484d;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.15s;
}
.pt-logout:hover { opacity: 0.9; }

/* ---------- SIDEBAR ---------- */
.portal-sidebar {
    position: fixed;
    left: 0;
    top: 66px;
    bottom: 0;
    width: 268px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    padding: 22px 16px 16px;
    overflow-y: auto;
    z-index: 998;
}

.ps-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    padding: 6px 10px 14px;
}

.ps-nav { display: flex; flex-direction: column; gap: 3px; }

.ps-group {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 16px 10px 7px;
    border-top: 1px solid rgba(255, 158, 44, 0.16);
    margin-top: 8px;
}
.ps-group:first-child { border-top: none; margin-top: 0; }

.ps-link {
    display: block;
    padding: 10px 10px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
}
.ps-link:hover { background: rgba(255, 158, 44, 0.1); color: #ff9e2c; }
.ps-link.active { background: #ff9e2c; color: #fff; font-weight: 700; }

.ps-foot {
    margin-top: 26px;
    padding: 12px 10px;
    font-size: 11.5px;
    color: #64748b;
    line-height: 1.5;
}
.ps-foot a { color: #94a3b8; text-decoration: underline; }

/* ---------- MAIN ---------- */
.portal-main {
    margin-left: 268px;
    margin-top: 66px;
    padding: 28px 34px 60px;
    min-height: calc(100vh - 66px);
}

.page-head { margin-bottom: 22px; }
.page-head h1 { font-family: 'Montserrat', sans-serif; font-size: 24px; font-weight: 800; color: #0f172a; }
.page-head p { color: #64748b; font-size: 14px; margin-top: 5px; }

/* ---------- FLASH / ALERT ---------- */
.portal-alert.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

/* ---------- CARDS & GRIDS ---------- */
.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e6e9ef;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    padding: 20px 22px;
    margin-bottom: 22px;
}
.card h2 { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 6px; font-family: 'Montserrat', sans-serif; }
.card .sub { color: #64748b; font-size: 13px; margin-bottom: 14px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e6e9ef;
    border-left: 4px solid #ff9e2c;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.stat-card.s-volt { border-left-color: #3e7cff; }
.stat-card.s-ok { border-left-color: #1fae68; }
.stat-card.s-warn { border-left-color: #e8a415; }
.stat-card.s-danger { border-left-color: #e5484d; }
.stat-card .stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
}
.stat-card .stat-value { font-family: 'Montserrat', sans-serif; font-size: 27px; font-weight: 800; color: #0f172a; }
.stat-card .stat-sub { font-size: 12px; color: #94a3b8; margin-top: 7px; }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table.portal-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.portal-table th {
    text-align: left;
    padding: 11px 12px;
    background: #f8fafc;
    border-bottom: 2px solid #e6e9ef;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    font-weight: 700;
    white-space: nowrap;
}
.portal-table td {
    padding: 11px 12px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: top;
}
.portal-table tr:hover td { background: #fbfcfe; }
.table-foot { color: #94a3b8; font-size: 12.5px; margin-top: 12px; }

/* ---------- PILLS / BADGES ---------- */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.pill.st-ok { background: #ecfdf5; color: #047857; }
.pill.st-warn { background: #fffbeb; color: #b45309; }
.pill.st-bad { background: #fef2f2; color: #b91c1c; }
.pill.st-idle { background: #f1f5f9; color: #475569; }

/* ---------- FORMS ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #ff9e2c; }
.form-group .hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.btn-group { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn-primary { background: linear-gradient(135deg, #ff9e2c, #ff6a00); color: #fff; }
.btn-ghost { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }

/* ---------- ACTION ROW ---------- */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- DETAIL / META GRID ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 16px; }
.meta-item { padding: 12px; background: #f8fafc; border-radius: 9px; }
.meta-item .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: #94a3b8; font-weight: 700; }
.meta-item .v { font-size: 14px; color: #1e293b; font-weight: 600; margin-top: 4px; word-break: break-word; }

/* ---------- FORM CARDS (mirrors administrator/company-form.php) ---------- */
.form-card { background: #fff; padding: 24px; border-radius: 12px; margin-bottom: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.08); max-width: 960px; }
.section-title { font-family: 'Montserrat', sans-serif; font-size: 17px; font-weight: 700; color: #0f172a; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid #ff9e2c; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-row.three-col { grid-template-columns: 1fr 1fr 1fr; }
.form-group .required { color: #b91c1c; }
.form-group small, .form-group .hint { display: block; font-size: 12px; color: #94a3b8; margin-top: 4px; }
select[multiple] { min-height: 110px; }
select[multiple] option:checked { background: #3e7cff; color: #fff; }
.checkbox-group { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.checkbox-group label { margin: 0; cursor: pointer; font-weight: 500; }
.upload-current { margin-top: 12px; }
.upload-current img { max-width: 170px; max-height: 150px; border-radius: 8px; border: 1px solid #e2e8f0; }
.upload-current p { margin-top: 8px; font-size: 12px; color: #94a3b8; }
.faq-item, .location-item { margin-bottom: 18px; padding: 16px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fafafa; position: relative; }
.faq-item .faq-remove, .location-item .loc-remove { position: absolute; top: 10px; right: 10px; }
.button-group { display: flex; gap: 10px; margin-top: 10px; padding-top: 18px; border-top: 1px solid #e5e5e5; flex-wrap: wrap; }
.btn-secondary { background: #e2e3e5; color: #0f172a; border: 1px solid #d4d4d4; }
.btn-secondary:hover { background: #d4d4d4; }

@media (max-width: 900px) {
    .form-row, .form-row.three-col { grid-template-columns: 1fr; }
}

/* ---------- EMPTY STATE ---------- */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 14px;
}
.empty strong { display: block; color: #475569; font-size: 15px; margin-bottom: 4px; }

/* ---------- INLINE DETAIL TEMPLATE (analytics etc.) ---------- */
.inline-figure { font-family: 'Montserrat', sans-serif; font-size: 22px; font-weight: 800; color: #0f172a; }

@media (max-width: 1080px) {
    .portal-sidebar { width: 230px; }
    .portal-main { margin-left: 230px; padding: 22px 20px 50px; }
}

/* ---------- PROFILE COMPLETION ---------- */
.completion-head { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; }
.completion-label { font-size:12px; color:#94a3b8; text-transform:uppercase; letter-spacing:.6px; font-weight:600; }
.completion-score { font-family:'Montserrat',sans-serif; font-size:36px; font-weight:800; color:#0f172a; line-height:1.1; }
.progress { height:12px; background:#eef1f5; border-radius:999px; overflow:hidden; }
.progress-bar { height:100%; border-radius:999px; background:linear-gradient(90deg,#ff9e2c,#ff6a00); transition:width .4s ease; }
.tip-list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px; }
.tip-list li { display:flex; align-items:center; justify-content:space-between; gap:10px; background:#f8fafc; border:1px solid #eef1f5; border-radius:9px; padding:9px 12px; font-size:13.5px; }
.tip-list li a { text-decoration:none; color:#0f172a; font-weight:600; }
.tip-list li a:hover { color:#ff6a00; }
.tip-badge { background:#fffbeb; color:#b45309; border:1px solid #fde68a; font-weight:700; padding:2px 9px; border-radius:999px; font-size:11.5px; white-space:nowrap; }
.section-pill { display:inline-block; padding:3px 10px; border-radius:999px; font-size:11.5px; font-weight:700; margin-left:8px; vertical-align:middle; }
.section-pill.ok { background:#ecfdf5; color:#047857; }
.section-pill.warn { background:#fffbeb; color:#b45309; border:1px solid #fde68a; }
.completion-divider { border:none; border-top:1px solid #eef1f5; margin:14px 0; }
.completion-verify { margin-top:12px; font-size:13px; }

/* =================================================================== */
/*  MOBILE APP SHELL (portals): burger + off-canvas sidebar + tabbar    */
/* =================================================================== */
.pt-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-right: 8px;
    border: none;
    border-radius: 11px;
    background: #f1f5f9;
    color: #0f172a;
    cursor: pointer;
}
.pt-burger:active { background: #e2e8f0; }
.pt-burger .material-symbols-outlined { font-size: 24px; }

.pt-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 21, 34, 0.5);
    z-index: 997;
}

.app-tabbar.portal-tabbar { display: none; }

@media (max-width: 900px) {
    body.portal-body {
        -webkit-tap-highlight-color: transparent;
        padding-bottom: 0;
    }

    /* -------- Topbar -------- */
    .portal-topbar {
        height: calc(58px + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 12px 0;
        box-shadow: 0 2px 12px rgba(11, 31, 47, 0.08);
    }
    .pt-burger { display: flex; }
    .pt-brand { font-size: 15px; }
    .pt-right { gap: 10px; }
    .pt-user-meta { display: none; }
    .pt-user-name { font-size: 12.5px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pt-logout { padding: 8px 12px; font-size: 12.5px; }

    /* -------- Off-canvas sidebar -------- */
    .portal-sidebar {
        top: 0;
        bottom: auto;
        height: 100vh;
        width: 84%;
        max-width: 320px;
        padding: calc(66px + env(safe-area-inset-top, 0px)) 12px calc(78px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 998;
        box-shadow: 6px 0 30px rgba(0, 0, 0, 0.35);
        -webkit-overflow-scrolling: touch;
    }
    body.sidebar-open .portal-sidebar { transform: translateX(0); }
    body.sidebar-open .pt-backdrop { display: block; }
    .ps-link { padding: 13px 12px; font-size: 15px; }

    /* -------- Main -------- */
    .portal-main {
        margin-left: 0;
        margin-top: calc(58px + env(safe-area-inset-top, 0px));
        padding: 18px 16px calc(84px + env(safe-area-inset-bottom, 0px));
        min-height: calc(100vh - 58px);
    }
    .page-head h1 { font-size: 21px; }
    .card { padding: 16px 15px; border-radius: 14px; }
    .stat-grid { gap: 12px; }
    .stat-card { padding: 15px 16px; border-radius: 14px; }
    .stat-card .stat-value { font-size: 24px; }
    .portal-table th, .portal-table td { padding: 10px 10px; }
    .btn-group .btn { flex: 1 1 auto; }

    /* -------- Bottom tab bar -------- */
    .app-tabbar.portal-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 999;
        height: calc(58px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.97);
        -webkit-backdrop-filter: saturate(180%) blur(14px);
        backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid #e6e9ef;
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
        align-items: stretch;
        justify-content: space-around;
    }
    .app-tabbar.portal-tabbar a {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        color: #94a3b8;
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        padding: 6px 2px 0;
    }
    .app-tabbar.portal-tabbar a .material-symbols-outlined { font-size: 23px; }
    .app-tabbar.portal-tabbar a.active { color: #ff6a00; }
    .app-tabbar.portal-tabbar a > span:last-child {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media print {
    .app-tabbar.portal-tabbar, .pt-burger { display: none !important; }
}