/* ==========================================================================
   BcKash MFB — Admin Portal UI
   ========================================================================== */
:root {
    --brand: #124035; --brand-600: #195644; --brand-700: #0d2e26;
    --accent: #ff7300; --accent-600: #e66700; --accent-50: #fff4ea;
    --ink: #10241d; --white: #ffffff;
    --gray-900:#0f172a; --gray-800:#1e293b; --gray-700:#334155; --gray-600:#475569;
    --gray-500:#64748b; --gray-400:#94a3b8; --gray-300:#cbd5e1; --gray-200:#e2e8f0;
    --gray-100:#f1f5f9; --gray-50:#f8fafc;
    --success:#12805c; --success-bg:#e6f4ee;
    --danger:#dc2626;  --danger-bg:#fdeaea;
    --warning:#d97706; --warning-bg:#fef3e2;
    --info:#2563eb;    --info-bg:#e8f0fe;
    --bg:#f4f6f7; --surface:#ffffff; --border:#e6eaed; --hairline:#eef1f0;
    --r-sm:8px; --r:12px; --r-lg:16px; --r-pill:999px;
    --shadow-sm:0 1px 2px rgba(16,36,29,.06);
    --shadow:0 2px 8px rgba(16,36,29,.07);
    --shadow-lg:0 12px 32px rgba(16,36,29,.14);
    --sidebar-w:262px; --transition:.18s ease;
    --fs-xs:12px; --fs-sm:13px; --fs-base:14px; --fs-md:15px; --fs-lg:18px; --fs-xl:22px; --fs-2xl:28px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg); color: var(--ink); font-size: var(--fs-base); line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img, svg { display: block; }
svg { stroke-width: 2; }

/* ---------- Layout ---------- */
.admin { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    background: var(--brand); color: rgba(255,255,255,.85);
    display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.sidebar__brand img { height: 34px; width: auto; }
.sidebar__brand .word { font-size: 19px; font-weight: 800; color: #fff; letter-spacing: .2px; }
.sidebar__brand .word b { color: var(--accent); }
.sidebar__tag { font-size: 11px; color: rgba(255,255,255,.5); padding: 0 20px 14px; letter-spacing: .12em; text-transform: uppercase; }
.nav-group { padding: 6px 12px; }
.nav-group__title { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.42); padding: 12px 12px 6px; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
    font-size: var(--fs-base); font-weight: 500; color: rgba(255,255,255,.82); transition: background var(--transition), color var(--transition);
}
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav-link.active svg { color: var(--accent); opacity: 1; }
.nav-link .count { margin-left: auto; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.16); color: #fff; padding: 1px 8px; border-radius: var(--r-pill); }
.sidebar__foot { margin-top: auto; padding: 16px; }
.sidebar__foot .logout { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: var(--r-sm); color: rgba(255,255,255,.75); font-weight: 500; }
.sidebar__foot .logout:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar__foot .logout svg { width: 18px; height: 18px; }

/* Main */
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
    height: 64px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__toggle { display: none; width: 40px; height: 40px; border-radius: var(--r-sm); align-items: center; justify-content: center; color: var(--gray-600); }
.topbar__title { font-size: var(--fs-lg); font-weight: 700; color: var(--ink); }
.topbar__search { margin-left: auto; position: relative; width: 300px; max-width: 40vw; }
.topbar__search input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--gray-50); padding: 0 16px 0 40px; font-size: var(--fs-sm); color: var(--ink); }
.topbar__search input:focus { outline: none; border-color: var(--brand-600); background: #fff; }
.topbar__search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--gray-400); }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center; color: var(--gray-600); position: relative; }
.icon-btn:hover { background: var(--gray-100); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.admin-user { display: flex; align-items: center; gap: 10px; padding-left: 8px; border-left: 1px solid var(--border); }
.admin-user__avatar { width: 38px; height: 38px; border-radius: var(--r-pill); background: linear-gradient(135deg, var(--brand-600), var(--accent)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.admin-user__meta { line-height: 1.25; }
.admin-user__name { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.admin-user__role { font-size: 11px; color: var(--gray-500); }

.content { padding: 26px 28px 40px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.page-head p { font-size: var(--fs-sm); color: var(--gray-500); margin-top: 4px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--hairline); }
.card__title { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.card__body { padding: 18px 20px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__icon { width: 44px; height: 44px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; }
.stat__icon svg { width: 22px; height: 22px; }
.stat__icon.green { background: var(--success-bg); color: var(--success); }
.stat__icon.orange { background: var(--accent-50); color: var(--accent); }
.stat__icon.blue { background: var(--info-bg); color: var(--info); }
.stat__icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat__delta { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill); }
.stat__delta.up { background: var(--success-bg); color: var(--success); }
.stat__delta.down { background: var(--danger-bg); color: var(--danger); }
.stat__value { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 16px; letter-spacing: -.02em; }
.stat__label { font-size: var(--fs-sm); color: var(--gray-500); margin-top: 2px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.toolbar .search input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); padding: 0 14px 0 38px; font-size: var(--fs-sm); }
.toolbar .search input:focus { outline: none; border-color: var(--brand-600); }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); }
.select { height: 40px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); padding: 0 12px; font-size: var(--fs-sm); color: var(--gray-700); }
.toolbar .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; transition: background var(--transition), border-color var(--transition), color var(--transition); white-space: nowrap; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-700); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-600); }
.btn--outline { border: 1px solid var(--border); color: var(--gray-700); background: var(--surface); }
.btn--outline:hover { border-color: var(--brand-600); color: var(--brand-600); }
.btn--ghost { color: var(--gray-600); }
.btn--ghost:hover { background: var(--gray-100); }
.btn--sm { height: 34px; padding: 0 12px; font-size: var(--fs-xs); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data thead th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gray-500); padding: 13px 16px; background: var(--gray-50); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tbody td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); color: var(--gray-700); vertical-align: middle; white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--gray-50); }
table.data .strong { font-weight: 600; color: var(--ink); }
table.data .muted { color: var(--gray-400); }
table.data .mono { font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace; font-size: 12.5px; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: flex; align-items: center; gap: 10px; }
.cell-avatar { width: 34px; height: 34px; border-radius: var(--r-pill); background: var(--brand-600); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.cell-sub { color: var(--gray-400); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .act { width: 32px; height: 32px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: var(--gray-500); }
.row-actions .act svg { width: 16px; height: 16px; }
.row-actions .act:hover { background: var(--gray-100); color: var(--brand-600); }
.row-actions .act.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--muted { background: var(--gray-100); color: var(--gray-500); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pagination__info { font-size: var(--fs-sm); color: var(--gray-500); }
.pagination__pages { display: flex; gap: 4px; }
.pagination__pages button { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-sm); font-weight: 600; color: var(--gray-600); }
.pagination__pages button:hover { border-color: var(--brand-600); color: var(--brand-600); }
.pagination__pages button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination__pages button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(16,36,29,.45); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.show { display: flex; animation: aFade .18s ease; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); max-height: 88vh; display: flex; flex-direction: column; animation: aPop .24s cubic-bezier(.16,1,.3,1); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--hairline); }
.modal__head h3 { font-size: var(--fs-lg); font-weight: 700; }
.modal__close { width: 34px; height: 34px; border-radius: var(--r-pill); font-size: 22px; color: var(--gray-400); display: flex; align-items: center; justify-content: center; }
.modal__close:hover { background: var(--gray-100); }
.modal__body { padding: 20px 22px; overflow-y: auto; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--hairline); }
.detail-row { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: var(--fs-sm); }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { flex: 0 0 42%; color: var(--gray-500); }
.detail-row .v { flex: 1; font-weight: 600; color: var(--ink); word-break: break-word; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 14px; font-size: var(--fs-sm); font-family: inherit; }
.field textarea { height: auto; padding: 12px 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand-600); }

/* Toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 360px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand-600); border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 500; animation: aSlide .28s cubic-bezier(.16,1,.3,1); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }

@keyframes aFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes aPop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes aSlide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login__brand { background: linear-gradient(160deg, var(--brand-700), var(--brand) 55%, var(--brand-600)); color: #fff; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login__brand::after { content: ''; position: absolute; right: -120px; top: -120px; width: 360px; height: 360px; border-radius: 50%; background: rgba(255,115,0,.14); }
.login__logo { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; position: relative; z-index: 1; }
.login__logo img { height: 40px; }
.login__logo b { color: var(--accent); }
.login__brand-mid { margin: auto 0; position: relative; z-index: 1; }
.login__brand-mid h1 { font-size: 34px; font-weight: 800; line-height: 1.2; max-width: 16ch; letter-spacing: -.02em; }
.login__brand-mid p { margin-top: 16px; color: rgba(255,255,255,.8); font-size: 15px; line-height: 1.6; max-width: 42ch; }
.login__brand-list { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.login__brand-list li { list-style: none; display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,.9); }
.login__brand-list li svg { width: 18px; height: 18px; color: var(--accent); }
.login__foot { position: relative; z-index: 1; font-size: 13px; color: rgba(255,255,255,.6); }
.login__form-side { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.login__form { width: 100%; max-width: 380px; }
.login__form .brand-mini { display: none; }
.login__form h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login__form .sub { color: var(--gray-500); font-size: var(--fs-sm); margin: 6px 0 26px; }
.login__pw { position: relative; }
.login__pw button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: var(--r-sm); color: var(--gray-400); display: flex; align-items: center; justify-content: center; }
.login__row { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-sm); margin: 4px 0 22px; color: var(--gray-600); }
.login__row label { display: flex; align-items: center; gap: 8px; }
.login__note { margin-top: 22px; font-size: 12px; color: var(--gray-400); text-align: center; }

/* ---------- Responsive ---------- */
.hidden { display: none !important; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; gap: 12px; }
    .topbar__toggle { display: flex; }
    .topbar__search { display: none; }
    /* Search (which carried margin-left:auto) is hidden — push the actions to the far right */
    .topbar__title { margin-right: auto; }
}
@media (max-width: 720px) {
    .login { grid-template-columns: 1fr; }
    .login__brand { display: none; }
    .login__form .brand-mini { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 20px; font-weight: 800; margin-bottom: 22px; }
    .login__form .brand-mini img { height: 34px; }
    .login__form .brand-mini b { color: var(--accent); }
    .stat-grid { grid-template-columns: 1fr; }
    .content { padding: 18px 16px 32px; }
    .admin-user__meta { display: none; }
    .admin-user { border-left: none; padding-left: 0; }
    .topbar__title { font-size: var(--fs-md); }
    .page-head h1 { font-size: var(--fs-xl); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Dashboard columns stack on smaller screens */
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr !important; } }

/* Detail modal — nested blocks (corporate directors/documents, financials, etc.) */
.detail-block { margin-top: 14px; }
.detail-block__title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin-bottom: 6px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.detail-mini { padding: 8px 12px; margin-bottom: 8px; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--gray-50); }
.detail-mini .detail-row { padding: 5px 0; }
.detail-mini .detail-row:last-child { border-bottom: none; }
