:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe5ef;
    --blue: #1358a8;
    --blue-light: #eff6ff;
    --teal: #00796b;
    --green: #18864b;
    --green-light: #ecfdf5;
    --red: #b42318;
    --red-light: #fef2f2;
    --amber: #a15c07;
    --amber-light: #fffbeb;
    --purple: #6b21a8;
    --purple-light: #f5f3ff;
    --shadow: 0 10px 30px rgba(23, 32, 51, 0.07);
    --shadow-lg: 0 20px 50px rgba(23, 32, 51, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; }
body {
    min-height: 100%;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ── Portal Shell & Desktop Sidebar ── */
.portal-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.portal-side {
    background: #0f1c2e;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}
.brand img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    padding: 3px;
    object-fit: contain;
}
.brand strong { display: block; font-size: 16px; font-weight: 800; line-height: 1.1; }
.brand span { display: block; color: rgba(255,255,255,.65); font-size: 12px; margin-top: 3px; }

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.side-nav a, .side-nav button {
    border: 0;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: rgba(255,255,255,.82);
    background: transparent;
    padding: 11px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .2s, color .2s;
}
.side-nav a.active, .side-nav button.active, .side-nav a:hover, .side-nav button:hover {
    color: #fff;
    background: rgba(255,255,255,.14);
}
.side-foot {
    margin-top: auto;
    color: rgba(255,255,255,.55);
    font-size: 12px;
    padding: 8px 4px;
}

/* ── Main Workspace ── */
.portal-main {
    min-width: 0;
    padding: 24px 28px;
}

.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #0f1c2e;
    color: #fff;
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
}
.mobile-header .brand { color: #fff; }
.mobile-header .brand img { width: 36px; height: 36px; }
.menu-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ── Buttons ── */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: transform .1s ease, box-shadow .2s ease;
    white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: scale(0.98); }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.primary:hover { background: #0e4484; }
.btn.success { border-color: var(--green); background: var(--green); color: #fff; }
.btn.success:hover { background: #136c3c; }
.btn.danger { border-color: var(--red); background: var(--red); color: #fff; }
.btn.danger:hover { background: #961b12; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 6px; }

/* ── Grids & Cards ── */
.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.stat-label {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 24px;
    font-weight: 850;
    margin-top: 8px;
    letter-spacing: -0.5px;
}
.stat-sub { margin-top: 6px; color: var(--muted); font-size: 12px; }

.amount-credit { color: var(--green); }
.amount-debit { color: var(--red); }

/* ── Panels ── */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: #fafbfc;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 20px; }

/* ── Forms & Inputs ── */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.input, .search {
    min-height: 40px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--ink);
    outline: none;
    transition: border-color .2s ease;
}
.input:focus, .search:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(19, 88, 168, 0.12);
}
.form-row {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-row label {
    font-size: 12.5px;
    font-weight: 700;
    color: #344054;
}
.form-row .input { width: 100%; }

/* ── Badges & Pills ── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 800;
    background: #f2f4f7;
    color: #344054;
    text-transform: capitalize;
}
.pill.green { background: var(--green-light); color: var(--green); border: 1px solid rgba(24,134,75,0.2); }
.pill.red { background: var(--red-light); color: var(--red); border: 1px solid rgba(180,35,24,0.2); }
.pill.blue { background: var(--blue-light); color: var(--blue); border: 1px solid rgba(19,88,168,0.2); }
.pill.amber { background: var(--amber-light); color: var(--amber); border: 1px solid rgba(161,92,7,0.2); }
.pill.purple { background: var(--purple-light); color: var(--purple); border: 1px solid rgba(107,33,168,0.2); }
.pill.teal { background: #e6fffa; color: #0d9488; border: 1px solid rgba(13,148,136,0.2); }

/* ── Data Tables ── */
.table-wrap {
    overflow-x: auto;
    width: 100%;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}
.data-table th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 800;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.data-table tr:hover td {
    background: #fbfcfe;
}
.empty {
    text-align: center;
    color: var(--muted);
    padding: 32px 16px;
    font-weight: 600;
}
.error {
    text-align: center;
    color: var(--red);
    padding: 20px 16px;
    font-weight: 600;
}

/* ── Profile Grid ── */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.profile-field {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
}
.profile-field .label {
    font-size: 11.5px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.profile-field .value {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    overflow-wrap: anywhere;
}

/* ── Modals & Overlays ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 28, 46, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99990;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}
.modal-card {
    background: #fff;
    border-radius: 14px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: fpgs-scale-in .2s ease-out;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}
.modal-body { padding: 22px; }

/* ── Mobile Sidebar Drawer ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99980;
    display: none;
}
.sidebar-overlay.active { display: block; }
.sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    background: #0f1c2e;
    color: #fff;
    padding: 24px 18px;
    z-index: 99985;
    transform: translateX(-100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.sidebar-drawer.open { transform: translateX(0); }
.drawer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}
.sidebar-drawer nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar-drawer nav a, .sidebar-drawer nav button {
    border: 0;
    width: 100%;
    text-align: left;
    color: rgba(255,255,255,.85);
    background: transparent;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-drawer nav a.active, .sidebar-drawer nav a:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
}

/* ── Public Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #0A2E6E 0%, #1565C0 100%);
}
.login-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 440px;
    padding: 32px 28px;
}
.role-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    margin: 20px 0;
}
.role-tab {
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    transition: all .2s ease;
}
.role-tab.active {
    background: #ffffff;
    color: var(--blue);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.notice {
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.45;
}

.hidden { display: none !important; }

/* ── Responsive Breakpoints ── */
@media (max-width: 1024px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .portal-shell { grid-template-columns: 1fr; }
    .portal-side { display: none; }
    .mobile-header { display: flex; }
    .portal-main { padding: 16px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .portal-main { padding: 12px; }
    .card { padding: 14px; }
    .stat-value { font-size: 20px; }
    .btn { padding: 8px 12px; font-size: 12.5px; }
    .filters { flex-direction: column; align-items: stretch; }
    .filters .input, .filters .btn { width: 100%; }
}
