/* =========================================================
   P2P Lending — Modern Yellow Theme (Light + Dark)
   ========================================================= */

/* ---------- Tokens (Light, default) ---------- */
:root,
[data-bs-theme="light"] {
    --brand-50:  #FFF9E5;
    --brand-100: #FFF1BF;
    --brand-200: #FFE48A;
    --brand-300: #FFD24D;
    --brand-400: #FFC120;
    --brand-500: #F5B400;   /* primary */
    --brand-600: #D99A00;
    --brand-700: #A87600;
    --brand-800: #7A5500;

    --bg-page:    #FAFAF6;
    --bg-surface: #FFFFFF;
    --bg-elev:    #FFFDF5;
    --bg-muted:   #F4F2EA;
    --border-subtle: #ECE9DD;
    --border-strong: #D9D5C2;

    --text-primary:   #1A1C1F;
    --text-secondary: #4B5563;
    --text-muted:     #6B7280;
    --text-on-brand:  #1A1C1F;

    --shadow-sm: 0 1px 2px rgba(20, 18, 6, .06);
    --shadow-md: 0 4px 14px rgba(20, 18, 6, .08);
    --shadow-lg: 0 12px 32px rgba(20, 18, 6, .10);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --navbar-bg:   #1A1C1F;
    --navbar-fg:   #FFFFFF;
    --sidebar-bg:  #FFFFFF;
    --sidebar-fg:  #3D3D3D;

    --success: #16A34A;
    --danger:  #DC2626;
    --warning: #F59E0B;
    --info:    #0EA5E9;
}

/* ---------- Tokens (Dark) ---------- */
[data-bs-theme="dark"] {
    --brand-50:  #2A2200;
    --brand-100: #3D3100;
    --brand-200: #5C4A00;
    --brand-300: #8A6F00;
    --brand-400: #C99B00;
    --brand-500: #FACC15;   /* primary (brighter for dark) */
    --brand-600: #FDE047;
    --brand-700: #FEF08A;
    --brand-800: #FEF9C3;

    --bg-page:    #0E1014;
    --bg-surface: #161A21;
    --bg-elev:    #1B2029;
    --bg-muted:   #21262F;
    --border-subtle: #262C36;
    --border-strong: #353C49;

    --text-primary:   #F3F4F6;
    --text-secondary: #C5C9D2;
    --text-muted:     #8B92A0;
    --text-on-brand:  #0E1014;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.55);

    --navbar-bg:   #0A0B0E;
    --navbar-fg:   #FACC15;
    --sidebar-bg:  #131820;
    --sidebar-fg:  #C5C9D2;

    --success: #4ADE80;
    --danger:  #F87171;
    --warning: #FBBF24;
    --info:    #38BDF8;

    color-scheme: dark;
}

/* ---------- Bootstrap variable overrides ---------- */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-primary:        var(--brand-500);
    --bs-primary-rgb:    245, 180, 0;
    --bs-link-color:     var(--brand-600);
    --bs-link-hover-color: var(--brand-700);
    --bs-body-bg:        var(--bg-page);
    --bs-body-color:     var(--text-primary);
    --bs-border-color:   var(--border-subtle);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg:    var(--bg-muted);
}

[data-bs-theme="dark"] {
    --bs-link-color:       var(--brand-500);
    --bs-link-hover-color: var(--brand-600);
}

/* ---------- Base ---------- */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    background: var(--bg-page);
    color: var(--text-primary);
}

body {
    padding-top: 64px;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    transition: background-color .25s ease, color .25s ease;
}

a { color: var(--brand-600); }
a:hover { color: var(--brand-700); }
[data-bs-theme="dark"] a { color: var(--brand-500); }
[data-bs-theme="dark"] a:hover { color: var(--brand-600); }

code, pre {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .85em;
}

hr { border-color: var(--border-subtle); opacity: 1; }

/* ---------- Layout ---------- */
:root {
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 68px;
    --sidebar-gap: 14px;
    --content-gutter: calc(var(--sidebar-w) + var(--sidebar-gap) * 2);
    --content-gutter-collapsed: calc(var(--sidebar-w-collapsed) + var(--sidebar-gap) * 2);
}

.layout-wrap {
    min-height: calc(100vh - 64px);
    position: relative;
}

/* Floating sidebar: fixed, detached from flow, rounded + shadow */
.layout-sidebar {
    position: fixed;
    top: calc(64px + var(--sidebar-gap));
    left: var(--sidebar-gap);
    bottom: var(--sidebar-gap);
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 14px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    transition: width .25s ease, left .25s ease, box-shadow .2s ease;
}
.layout-sidebar:hover {
    box-shadow: var(--shadow-lg);
}

html.sidebar-collapsed .layout-sidebar {
    width: var(--sidebar-w-collapsed);
}

.layout-content {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--content-gutter);
    transition: margin-left .25s ease;
}
html.sidebar-collapsed .layout-content {
    margin-left: var(--content-gutter-collapsed);
}

/* Section label */
.sidebar-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 14px 14px 6px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity .15s ease;
}
html.sidebar-collapsed .sidebar-section-label {
    opacity: 0;
    height: 14px;
    padding: 6px 0;
    overflow: hidden;
}

.layout-sidebar .nav-link {
    color: var(--sidebar-fg);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color .15s ease, color .15s ease, padding .25s ease;
    white-space: nowrap;
    overflow: hidden;
}

.layout-sidebar .nav-link i {
    width: 20px;
    margin: 0;
    font-size: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: center;
    transition: color .15s ease;
}

html.sidebar-collapsed .layout-sidebar .nav-link {
    padding: 10px 12px;
    justify-content: center;
}
html.sidebar-collapsed .layout-sidebar .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity .1s ease;
}

.layout-sidebar .nav-link:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}

.layout-sidebar .nav-link:hover i { color: var(--brand-600); }

.layout-sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-400));
    color: var(--text-on-brand);
    box-shadow: 0 4px 12px rgba(245, 180, 0, .35);
}

[data-bs-theme="dark"] .layout-sidebar .nav-link:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}
[data-bs-theme="dark"] .layout-sidebar .nav-link:hover i {
    color: var(--brand-500);
}
[data-bs-theme="dark"] .layout-sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: var(--text-on-brand);
    box-shadow: 0 4px 14px rgba(250, 204, 21, .25);
}

.layout-sidebar .nav-link.active i {
    color: var(--text-on-brand);
}

/* ---------- Navbar ---------- */
.navbar {
    background: var(--navbar-bg) !important;
    height: 64px;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    backdrop-filter: saturate(180%) blur(8px);
}

.navbar .navbar-brand {
    color: #fff;
    font-weight: 700;
    letter-spacing: -.01em;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.navbar .navbar-brand .brand-logo {
    height: 32px;
    width: auto;
    display: block;
    /* Slight glow behind logo to lift it from the dark navbar */
    filter: drop-shadow(0 2px 6px rgba(245, 180, 0, .25));
}

.navbar .navbar-brand .brand-divider {
    width: 1px;
    height: 22px;
    background: rgba(255,255,255,.18);
    display: inline-block;
}

.navbar .navbar-brand .brand-suffix {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .01em;
    color: rgba(255,255,255,.92);
}

[data-bs-theme="dark"] .navbar .navbar-brand .brand-logo {
    filter: drop-shadow(0 2px 8px rgba(250, 204, 21, .30));
}

.navbar .text-white { color: #fff !important; }
.navbar small.opacity-75 { color: rgba(255,255,255,.6); }

.navbar .btn-outline-light {
    border-color: rgba(255,255,255,.25);
    color: #fff;
}
.navbar .btn-outline-light:hover {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: var(--text-on-brand);
}

/* Navbar icon buttons (theme toggle, sidebar toggle) */
.nav-icon-btn,
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.05);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease, color .18s ease;
}
.nav-icon-btn:hover {
    background: var(--brand-500);
    color: var(--text-on-brand);
}
.theme-toggle:hover {
    background: var(--brand-500);
    color: var(--text-on-brand);
    transform: rotate(-12deg);
}
.theme-toggle .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle .bi-sun-fill { display: inline-block; }
[data-bs-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }

#sidebarToggle i {
    transition: transform .25s ease;
}
html.sidebar-collapsed #sidebarToggle i {
    transform: rotate(180deg);
}

/* Navbar global search */
.navbar-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 10px;
    padding: 0 12px;
    transition: background .15s ease, border-color .15s ease;
    width: 320px;
}
.navbar-search:focus-within {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.3);
}
.navbar-search i {
    color: rgba(255,255,255,.55);
    font-size: 13px;
    margin-right: 8px;
}
.navbar-search input {
    background: transparent;
    border: 0;
    color: #fff;
    outline: 0;
    font-size: 13px;
    padding: 7px 0;
    width: 100%;
}
.navbar-search input::placeholder { color: rgba(255,255,255,.45); }

/* Notification bell */
.nav-icon-btn .notif-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    background: #DC2626;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    border: 2px solid var(--navbar-bg);
}
.notif-dropdown {
    min-width: 360px;
    max-height: 460px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 6px;
    margin-top: 8px;
}
.notif-dropdown .dropdown-header { padding: 10px 12px; color: var(--text-primary); font-size: 13px; }
.notif-dropdown .notif-item {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    white-space: normal;
    transition: background .12s ease;
}
.notif-dropdown .notif-item:hover { background: var(--brand-50); }
[data-bs-theme="dark"] .notif-dropdown .notif-item:hover { background: rgba(250,204,21,.10); }
.notif-dropdown .notif-icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--bg-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.notif-dropdown .notif-text { line-height: 1.35; }

/* User menu */
.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.04);
    color: #fff;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}
.user-menu-btn:hover,
.user-menu-btn[aria-expanded="true"] {
    background: rgba(255,255,255,.10);
    border-color: rgba(255,255,255,.25);
}
.user-menu-btn .user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
    color: var(--text-on-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: 0 2px 6px rgba(245,180,0,.25);
}
.user-menu-btn .user-meta {
    line-height: 1.15;
    text-align: left;
}
.user-menu-btn .user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-btn .user-role {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,.60);
}
.user-menu-btn .user-caret {
    font-size: 12px;
    color: rgba(255,255,255,.55);
}

.user-dropdown {
    min-width: 220px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 6px;
    margin-top: 8px;
}
.user-dropdown .dropdown-header {
    padding: 8px 12px;
    color: var(--text-primary);
}
.user-dropdown .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color .12s ease;
}
.user-dropdown .dropdown-item:hover,
.user-dropdown .dropdown-item:focus {
    background: var(--brand-50);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .user-dropdown .dropdown-item:hover,
[data-bs-theme="dark"] .user-dropdown .dropdown-item:focus {
    background: rgba(250,204,21,.10);
}
.user-dropdown .dropdown-item.text-danger:hover {
    background: rgba(220,38,38,.10);
    color: #b91c1c !important;
}
.user-dropdown .dropdown-divider {
    border-color: var(--border-subtle);
    margin: 4px 0;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-subtle);
    padding: 14px 18px;
    font-weight: 600;
}

.card-body { padding: 18px; }

/* Stat cards */
.card-stat {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    position: relative;
    overflow: hidden;
}

.card-stat::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-300));
    opacity: 0;
    transition: opacity .2s ease;
}

.card-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-300);
}
.card-stat:hover::after { opacity: 1; }

.card-stat .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

/* Recolor BS contextual stat-icons to look harmonized in dark mode too */
.stat-icon.bg-primary    { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)) !important; color: var(--text-on-brand) !important; }
.stat-icon.bg-success    { background: linear-gradient(135deg, #16A34A, #15803D) !important; }
.stat-icon.bg-danger     { background: linear-gradient(135deg, #EF4444, #B91C1C) !important; }
.stat-icon.bg-warning    { background: linear-gradient(135deg, #F59E0B, #D97706) !important; color: #1A1C1F !important; }
.stat-icon.bg-info       { background: linear-gradient(135deg, #0EA5E9, #0284C7) !important; }
.stat-icon.bg-secondary  { background: linear-gradient(135deg, #64748B, #475569) !important; }
.stat-icon.bg-dark       { background: linear-gradient(135deg, #1F2937, #0F172A) !important; }

/* ---------- Page header (common pattern di list/detail pages) ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-header h4, .page-header h5 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -.01em;
}
.page-header .page-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}
.page-header .page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Filter toolbar (lighter than full card body) ---------- */
.toolbar {
    background: var(--bg-elev);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
}

/* ---------- Search input with icon ---------- */
.search-input-wrap {
    position: relative;
}
.search-input-wrap .bi-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 14px;
}
.search-input-wrap input.form-control {
    padding-left: 36px;
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--bg-muted);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.empty-state .empty-title {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 4px;
}
.empty-state .empty-hint {
    font-size: 13px;
    margin-bottom: 14px;
}

/* ---------- Table polish ---------- */
.table > tbody > tr {
    transition: background-color .12s ease;
}
.table > tbody > tr.row-hover-link { cursor: pointer; }

/* Table embedded inside .card should not have double border on top */
.card > .table-responsive > .table:first-child,
.card > .table:first-child {
    margin-bottom: 0;
}
.card > .card-footer {
    background: transparent;
    border-top: 1px solid var(--border-subtle);
}

/* ---------- Pagination ---------- */
.pagination .page-link {
    color: var(--text-secondary);
    background: var(--bg-surface);
    border-color: var(--border-subtle);
    font-size: 13px;
    padding: .35rem .7rem;
    margin: 0 2px;
    border-radius: var(--radius-sm) !important;
    transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.pagination .page-link:hover {
    background: var(--brand-50);
    color: var(--brand-700);
    border-color: var(--brand-300);
}
.pagination .page-item.active .page-link {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: var(--text-on-brand);
}
.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    background: transparent;
    border-color: var(--border-subtle);
    opacity: .5;
}
[data-bs-theme="dark"] .pagination .page-link:hover {
    background: rgba(250,204,21,.10);
    color: var(--brand-500);
}

/* ---------- Focus visible (a11y) ---------- */
:focus-visible {
    outline: 3px solid rgba(245, 180, 0, .35);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: none;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: .5rem 1rem;
    transition: transform .12s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}
.btn:active { transform: translateY(1px); }

/* Bootstrap 5.3 button styling via --bs-btn-* CSS variables.
   Cara ini overrides di kedua tema tanpa colliding sama dark-mode defaults. */
.btn-primary {
    --bs-btn-bg:               var(--brand-500);
    --bs-btn-border-color:     var(--brand-500);
    --bs-btn-color:            var(--text-on-brand);
    --bs-btn-hover-bg:         var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-hover-color:      var(--text-on-brand);
    --bs-btn-active-bg:        var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-active-color:     var(--text-on-brand);
    --bs-btn-disabled-bg:      var(--brand-300);
    --bs-btn-disabled-border-color: var(--brand-300);
    --bs-btn-disabled-color:   var(--text-on-brand);
    box-shadow: 0 4px 12px rgba(245, 180, 0, .25);
}
.btn-primary:hover,
.btn-primary:focus {
    box-shadow: 0 6px 16px rgba(245, 180, 0, .35);
}
/* Hard override — pastikan teks selalu hitam di atas bg kuning,
   walaupun ada extension/reset CSS lain yang mau mainan */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:disabled,
.btn-check:checked + .btn-primary {
    color: var(--text-on-brand) !important;
    background-color: var(--brand-500) !important;
    border-color: var(--brand-500) !important;
}
.btn-primary:hover {
    background-color: var(--brand-600) !important;
    border-color: var(--brand-600) !important;
}
.btn-primary > * { color: inherit !important; }

.btn-outline-primary {
    --bs-btn-color:               var(--brand-600);
    --bs-btn-border-color:        var(--brand-500);
    --bs-btn-hover-bg:            var(--brand-500);
    --bs-btn-hover-border-color:  var(--brand-500);
    --bs-btn-hover-color:         var(--text-on-brand);
    --bs-btn-active-bg:           var(--brand-600);
    --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-active-color:        var(--text-on-brand);
}
[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: var(--brand-500);
}

.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

/* ---------- Forms ---------- */
.form-control,
.form-select {
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.form-control:focus,
.form-select:focus {
    background: var(--bg-surface);
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(245, 180, 0, .18);
    color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-muted); opacity: .8; }
.form-label { font-weight: 500; color: var(--text-secondary); font-size: .88rem; }

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    box-shadow: 0 0 0 4px rgba(250, 204, 21, .15);
}

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: var(--bg-surface);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-subtle);
    --bs-table-striped-bg: var(--bg-elev);
    --bs-table-hover-bg: var(--brand-50);
    --bs-table-hover-color: var(--text-primary);
    color: var(--text-primary);
}

.table thead th,
.table > :not(caption) > * > * {
    border-bottom-color: var(--border-subtle);
}

.table thead th,
.table-light, .table-light > th, .table-light > td {
    background: var(--bg-muted) !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-subtle);
}

[data-bs-theme="dark"] .table {
    --bs-table-hover-bg: rgba(250, 204, 21, .08);
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    letter-spacing: .02em;
    border-radius: 999px;
    padding: .35em .7em;
}
.badge.bg-primary {
    background: var(--brand-500) !important;
    color: var(--text-on-brand);
}
.badge.bg-light.text-dark {
    background: var(--bg-muted) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-subtle);
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.alert-success { background: rgba(22,163,74,.10); border-color: rgba(22,163,74,.30); color: #15803d; }
.alert-danger  { background: rgba(220,38,38,.10); border-color: rgba(220,38,38,.30); color: #b91c1c; }
.alert-warning { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.alert-info    { background: rgba(14,165,233,.10); border-color: rgba(14,165,233,.30); color: #0369a1; }

[data-bs-theme="dark"] .alert-success { color: #86efac; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-bs-theme="dark"] .alert-warning { color: var(--brand-600); }
[data-bs-theme="dark"] .alert-info    { color: #7dd3fc; }

/* ---------- Login ---------- */
.login-wrap {
    position: relative;
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(60% 50% at 20% 10%, rgba(245,180,0,.10), transparent 60%),
        radial-gradient(50% 40% at 90% 90%, rgba(245,180,0,.08), transparent 60%),
        var(--bg-page);
    overflow: hidden;
    isolation: isolate;
}
[data-bs-theme="dark"] .login-wrap {
    background:
        radial-gradient(60% 50% at 20% 10%, rgba(250,204,21,.08), transparent 60%),
        radial-gradient(50% 40% at 90% 90%, rgba(250,204,21,.05), transparent 60%),
        var(--bg-page);
}

/* ---------- Animated yellow background blobs (login screen) ---------- */
.login-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.login-bg .blob {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    will-change: transform;
    background: radial-gradient(circle at 30% 30%, var(--brand-300), var(--brand-500) 55%, transparent 75%);
}

.login-bg .blob-1 {
    width: 520px; height: 520px;
    top: -120px; left: -140px;
    animation: blobDriftA 28s ease-in-out infinite;
}
.login-bg .blob-2 {
    width: 420px; height: 420px;
    bottom: -120px; right: -100px;
    background: radial-gradient(circle at 40% 40%, var(--brand-200), var(--brand-400) 60%, transparent 78%);
    opacity: .45;
    animation: blobDriftB 34s ease-in-out infinite;
}
.login-bg .blob-3 {
    width: 340px; height: 340px;
    top: 35%; left: 55%;
    background: radial-gradient(circle, var(--brand-100), var(--brand-300) 60%, transparent 80%);
    opacity: .40;
    animation: blobDriftC 24s ease-in-out infinite;
}
.login-bg .blob-4 {
    width: 280px; height: 280px;
    top: 65%; left: 8%;
    background: radial-gradient(circle, var(--brand-200), var(--brand-400) 55%, transparent 75%);
    opacity: .35;
    animation: blobDriftD 30s ease-in-out infinite;
}

[data-bs-theme="dark"] .login-bg .blob   { opacity: .35; filter: blur(80px); }
[data-bs-theme="dark"] .login-bg .blob-2 { opacity: .28; }
[data-bs-theme="dark"] .login-bg .blob-3 { opacity: .22; }
[data-bs-theme="dark"] .login-bg .blob-4 { opacity: .20; }

@keyframes blobDriftA {
    0%   { transform: translate(0, 0) scale(1); }
    25%  { transform: translate(80px, 60px) scale(1.08); }
    50%  { transform: translate(160px, 0)   scale(.95); }
    75%  { transform: translate(60px, -70px) scale(1.05); }
    100% { transform: translate(0, 0) scale(1); }
}
@keyframes blobDriftB {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(-90px, -70px) scale(1.10); }
    66%  { transform: translate(-40px, 60px)  scale(.92); }
    100% { transform: translate(0, 0) scale(1); }
}
@keyframes blobDriftC {
    0%   { transform: translate(-50%, -50%) scale(1); }
    50%  { transform: translate(calc(-50% + 120px), calc(-50% + 80px)) scale(1.12); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes blobDriftD {
    0%   { transform: translate(0, 0) scale(1); }
    40%  { transform: translate(70px, -50px) scale(1.06); }
    80%  { transform: translate(-30px, 40px) scale(.94); }
    100% { transform: translate(0, 0) scale(1); }
}

/* blob-3 is positioned by its own center via transform */
.login-bg .blob-3 { transform: translate(-50%, -50%); }

@media (prefers-reduced-motion: reduce) {
    .login-bg .blob { animation: none !important; }
}

/* ---------- Branch summary cards (tracking) ---------- */
.branch-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bg-surface);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.branch-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-300);
}
.branch-card .branch-icon {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
    color: var(--text-on-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(245, 180, 0, .25);
}
.branch-card .branch-code {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: 4px;
}
.branch-card .branch-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.6em;
}
.branch-card .branch-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 16px 0 14px;
}
.branch-card .branch-stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.branch-card .branch-stat-lbl {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-top: 2px;
}
.min-w-0 { min-width: 0; }

/* ---------- Confirm popover bubble ---------- */
.confirm-pop {
    position: absolute;
    z-index: 1080;
    min-width: 260px;
    max-width: 340px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 40px rgba(20, 18, 6, .18), 0 4px 10px rgba(20, 18, 6, .08);
    padding: 14px 14px 12px;
    opacity: 0;
    transform: translateY(4px) scale(.96);
    transform-origin: bottom center;
    transition: opacity .14s ease, transform .14s ease;
    pointer-events: none;
}
.confirm-pop.placed-below {
    transform-origin: top center;
    transform: translateY(-4px) scale(.96);
}
.confirm-pop.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.confirm-pop-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.confirm-pop-msg i {
    color: var(--brand-600);
    font-size: 18px;
    line-height: 1.3;
    flex-shrink: 0;
}
[data-bs-theme="dark"] .confirm-pop-msg i { color: var(--brand-500); }

.confirm-pop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.confirm-pop-actions .btn {
    padding: .35rem .85rem;
    font-size: 12.5px;
    font-weight: 600;
}

/* Arrow */
.confirm-pop-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transform: translateX(-50%) rotate(45deg);
    bottom: -7px;
    border-top: 0;
    border-left: 0;
}
.confirm-pop.placed-below .confirm-pop-arrow {
    bottom: auto;
    top: -7px;
    border: 1px solid var(--border-subtle);
    border-right: 0;
    border-bottom: 0;
}

/* ---------- Toast-style flash messages (auto-dismiss) ---------- */
.toast-stack {
    position: fixed;
    top: 78px;
    right: 16px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast-stack .toast-alert {
    position: relative;
    pointer-events: auto;
    margin-bottom: 0;
    padding: 12px 40px 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(20,18,6,.12), 0 2px 6px rgba(20,18,6,.06);
    overflow: hidden;
    animation: toastIn .28s cubic-bezier(.2,.7,.3,1);
}
[data-bs-theme="dark"] .toast-stack .toast-alert {
    box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.30);
}
.toast-stack .toast-alert.fade:not(.show) {
    animation: toastOut .25s ease forwards;
}
.toast-stack .toast-icon {
    font-size: 18px;
    line-height: 1.3;
    flex-shrink: 0;
}
.toast-stack .toast-msg {
    flex: 1 1 auto;
    line-height: 1.4;
    font-size: 13.5px;
    word-break: break-word;
}
.toast-stack .btn-close {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px;
    opacity: .55;
    font-size: 11px;
}
.toast-stack .btn-close:hover { opacity: 1; }

/* Bottom countdown progress bar */
.toast-stack .toast-progress {
    position: absolute;
    left: 0; bottom: 0;
    height: 3px;
    background: currentColor;
    opacity: .35;
    width: 100%;
    transform-origin: left center;
    animation: toastCountdown 10s linear forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(28px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(28px); }
}
@keyframes toastCountdown {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast-stack .toast-alert { animation: none; }
    .toast-stack .toast-progress { animation-duration: 0s; }
}

.login-card {
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
}
.login-card .text-primary { color: var(--brand-600) !important; }
[data-bs-theme="dark"] .login-card .text-primary { color: var(--brand-500) !important; }

.login-logo {
    height: 56px;
    width: auto;
    filter: drop-shadow(0 4px 12px rgba(245, 180, 0, .25));
}
[data-bs-theme="dark"] .login-logo {
    filter: drop-shadow(0 4px 14px rgba(250, 204, 21, .35));
}

/* ---------- Timeline ---------- */
.timeline {
    position: relative;
    padding-left: 30px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px; top: 0; bottom: 0;
    width: 2px;
    background: var(--border-subtle);
}
.timeline-item {
    position: relative;
    padding-bottom: 18px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px; top: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--brand-500);
    border: 3px solid var(--bg-surface);
    box-shadow: 0 0 0 2px var(--brand-500);
}
.timeline-item.timeline-success::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.timeline-warning::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-item.timeline-danger::before  { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger); }

/* ---------- Status flow ---------- */
.status-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.status-flow .step {
    padding: 6px 12px;
    background: var(--bg-muted);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}
.status-flow .step.done {
    background: var(--success);
    color: #fff;
    border-color: transparent;
}
.status-flow .step.current {
    background: var(--brand-500);
    color: var(--text-on-brand);
    font-weight: 600;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(245,180,0,.30);
}
.status-flow .arrow { color: var(--text-muted); }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted) !important; }
.bg-white { background: var(--bg-surface) !important; }

footer.text-center.text-muted {
    color: var(--text-muted) !important;
    border-top: 1px solid var(--border-subtle);
    margin-top: 24px;
    padding: 18px;
}

/* ---------- Responsive sidebar (mobile = full overlay) ---------- */
@media (max-width: 768px) {
    .layout-sidebar {
        left: calc(-1 * var(--sidebar-w) - var(--sidebar-gap) - 20px);
        width: var(--sidebar-w) !important;
        box-shadow: var(--shadow-lg);
    }
    .layout-sidebar.show {
        left: var(--sidebar-gap);
    }
    .layout-content {
        margin-left: 0 !important;
    }
    /* mobile: collapsed mode is meaningless — keep full overlay layout */
    html.sidebar-collapsed .layout-sidebar {
        width: var(--sidebar-w) !important;
    }
    html.sidebar-collapsed .layout-sidebar .nav-label {
        opacity: 1;
        width: auto;
    }
    html.sidebar-collapsed .layout-sidebar .nav-link {
        justify-content: flex-start;
        padding: 10px 14px;
    }
    html.sidebar-collapsed .sidebar-section-label {
        opacity: 1;
        height: auto;
        padding: 14px 14px 6px;
    }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(0,0,0,.40);
    z-index: 1010;
    cursor: pointer;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Scrollbar polish ---------- */
.layout-sidebar::-webkit-scrollbar { width: 6px; }
.layout-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}
.layout-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--brand-400);
}
