/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #0f1429;
    --bg-sidebar: #0d1025;
    --bg-card: #131836;
    --bg-row-hover: #1a2040;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a8;
    --text-muted: #555570;
    --accent-pink: #e91e8c;
    --accent-blue: #4a9eff;
    --accent-green: #76ff03;
    --accent-yellow: #ffd600;
    --accent-red: #ff5252;
    --border-color: #1e2248;
    --sidebar-width: 200px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    min-height: 100vh;
    padding: 24px 0;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 100;
}

.sidebar-logo {
    padding: 0 24px;
    margin-bottom: 32px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
}

.sidebar-logo span {
    color: var(--accent-pink);
}

.sidebar-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav li {
    position: relative;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-row-hover);
    text-decoration: none;
}

.sidebar-nav a.active {
    color: #fff;
    background: var(--accent-pink);
    border-left-color: #fff;
    border-radius: 0 8px 8px 0;
    margin-right: 12px;
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 40px;
    min-height: 100vh;
}

.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--text-secondary);
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 32px 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-family);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 160px;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent-pink);
}

.filter-group input[type="text"] {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-family);
    min-width: 200px;
}

.filter-group input[type="text"]::placeholder {
    color: var(--text-muted);
}

.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-pink);
}

.table-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-row-hover);
}

.data-table td {
    padding: 16px;
    font-size: 14px;
    vertical-align: middle;
}

.data-table td a {
    color: var(--accent-blue);
    font-weight: 500;
}

/* ===== Brand Badges ===== */
.brand-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.brand-badge.canal { background: #1a1a2e; color: #fff; }
.brand-badge.orange { background: #e91e8c; color: #fff; }
.brand-badge.mtn { background: #ffd600; color: #000; }
.brand-badge.moov { background: #76ff03; color: #000; }
.brand-badge.solibra { background: #76ff03; color: #000; }
.brand-badge.heineken { background: #76ff03; color: #000; }
.brand-badge.unilever { background: #76ff03; color: #000; }

.brand-badge .telecom-icon::before {
    content: "\260E";
    margin-right: 2px;
}

/* ===== Risk Indicator ===== */
.risk-indicator {
    text-align: center;
}

.risk-none {
    color: var(--text-muted);
}

.risk-warning {
    color: var(--accent-yellow);
    font-size: 18px;
}

.risk-danger {
    color: var(--accent-red);
    font-size: 18px;
}

/* ===== Status Badges ===== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-green {
    background: rgba(118, 255, 3, 0.15);
    color: var(--accent-green);
}

.status-yellow {
    background: rgba(255, 214, 0, 0.15);
    color: var(--accent-yellow);
}

.status-blue {
    background: rgba(74, 158, 255, 0.15);
    color: var(--accent-blue);
}

.status-gray {
    background: rgba(136, 136, 168, 0.15);
    color: var(--text-secondary);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    padding: 16px 0;
}

.pagination button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.pagination button:hover {
    color: var(--text-primary);
    background: var(--bg-row-hover);
}

.pagination button.active {
    color: #fff;
    font-weight: 700;
}

.pagination button:disabled {
    color: var(--text-muted);
    cursor: default;
}

.pagination .ellipsis {
    color: var(--text-muted);
    padding: 6px 4px;
}

/* ===== Agent Detail Page ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.detail-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.detail-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-section .info-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
    margin-top: 12px;
}

.detail-section .info-label:first-of-type {
    margin-top: 0;
}

.detail-section .info-value {
    font-size: 14px;
    color: var(--text-primary);
}

.accounts-row {
    display: flex;
    gap: 24px;
    margin-top: 12px;
}

.account-item {
    font-size: 13px;
}

.account-item span {
    color: var(--text-muted);
    margin-right: 8px;
}

/* ===== Mobile Money Accounts ===== */
.mm-accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.mm-account {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.mm-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
}

.mm-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mm-provider-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mm-phone {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ===== Balance Box ===== */
.balance-box {
    background: linear-gradient(135deg, #1a0030 0%, #0d1025 100%);
    border: 1px solid var(--accent-pink);
    border-radius: 8px;
    padding: 20px 24px;
    margin: 24px 0;
    display: inline-block;
}

.balance-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.balance-value {
    font-size: 24px;
    font-weight: 700;
}

.balance-value.negative {
    color: var(--accent-green);
}

.balance-value.positive {
    color: var(--accent-green);
}

.balance-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Dashboard MM Cards ===== */
.mm-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.mm-dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.mm-dashboard-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mm-dashboard-provider {
    font-weight: 600;
    font-size: 14px;
}

.mm-dashboard-phone {
    font-size: 12px;
    color: var(--text-muted);
}

.mm-dashboard-balance {
    margin-bottom: 12px;
}

.mm-dashboard-transfer {
    font-size: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ===== Commission Section ===== */
.commission-section {
    margin: 32px 0;
}

.commission-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.commission-info {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    font-size: 14px;
}

.commission-info .label {
    color: var(--text-secondary);
}

.commission-bar {
    display: flex;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 12px;
    position: relative;
}

.commission-bar .bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    padding: 0 12px;
    white-space: nowrap;
}

.commission-bar .bar-stock {
    background: var(--accent-blue);
    color: #fff;
}

.commission-bar .bar-cash {
    background: var(--accent-green);
    color: #000;
}

.commission-bar .bar-commission {
    background: #9cff57;
    color: #000;
}

.bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Partner Brands Table ===== */
.section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 32px 0 16px;
}

.contract-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
}

.contract-active {
    color: var(--accent-green);
}

.contract-pending {
    color: var(--accent-blue);
}

.contract-warning {
    color: var(--accent-yellow);
}

/* ===== Transactions Table ===== */
.transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.transactions-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.transactions-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.amount-positive {
    color: var(--accent-green);
}

.amount-negative {
    color: var(--accent-red);
}

/* ===== Date Picker ===== */
.date-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.date-picker input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
}

.date-picker input:focus {
    outline: none;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px;
    color: var(--text-muted);
    font-size: 14px;
}

.loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-pink);
    border-radius: 50%;
    margin-left: 12px;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
}

.login-card .login-logo {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 8px;
    color: #fff;
}

.login-card .login-logo span {
    color: var(--accent-pink);
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color 0.2s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent-pink);
}

.login-card .login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-pink);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 8px;
}

.login-card .login-btn:hover {
    opacity: 0.9;
}

.login-card .login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-card .login-error {
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
}

.login-card .login-error.visible {
    display: block;
}

/* ===== App layout (hidden when logged out) ===== */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.app-layout.hidden {
    display: none;
}

.login-page.hidden {
    display: none;
}

/* ===== User bar ===== */
.user-bar {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-bar .username {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.user-bar .logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.user-bar .logout-btn:hover {
    color: var(--accent-red);
    background: var(--bg-row-hover);
}

.user-bar .settings-link {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.user-bar .settings-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ===== Settings Form ===== */
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
}

.settings-card h3 {
    margin-bottom: 24px;
    font-size: 16px;
    font-weight: 600;
}

.settings-card .form-group {
    margin-bottom: 16px;
}

.settings-card label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.settings-card input[type="password"] {
    width: 100%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-family);
}

.settings-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-pink);
}

.settings-card .save-btn {
    background: var(--accent-pink);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    margin-top: 8px;
}

.settings-card .save-btn:hover {
    opacity: 0.85;
}

.settings-card .save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-card .form-message {
    margin-top: 16px;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 8px;
    display: none;
}

.settings-card .form-message.success {
    display: block;
    background: rgba(118, 255, 3, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(118, 255, 3, 0.2);
}

.settings-card .form-message.error {
    display: block;
    background: rgba(255, 82, 82, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(255, 82, 82, 0.2);
}

/* ===== Action buttons (Import CSV / Import stock) ===== */
.import-csv-btn,
.import-stock-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    margin-right: 6px;
    white-space: nowrap;
}

.import-csv-btn {
    background: rgba(58, 143, 209, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(58, 143, 209, 0.35);
}

.import-stock-btn {
    background: rgba(46, 204, 113, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.import-csv-btn:hover {
    background: rgba(58, 143, 209, 0.28);
    border-color: rgba(58, 143, 209, 0.6);
}

.import-stock-btn:hover {
    background: rgba(46, 204, 113, 0.24);
    border-color: rgba(46, 204, 113, 0.55);
}

.import-csv-btn:active,
.import-stock-btn:active {
    transform: scale(0.97);
}

.import-csv-btn.disabled,
.import-stock-btn.disabled {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* ===== Add-provider toggle section ===== */
.provider-add-section {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.provider-add-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.provider-add-toggle:hover {
    background: var(--bg-row-hover);
}

.provider-add-toggle-icon {
    font-size: 1rem;
    color: var(--accent-blue);
    line-height: 1;
}

.provider-add-chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.provider-add-toggle[aria-expanded="true"] .provider-add-chevron {
    transform: rotate(180deg);
}

.provider-add-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.2s ease;
    background: var(--bg-secondary);
    border-top: 0px solid var(--border-color);
}

.provider-add-panel.open {
    max-height: 400px;
    padding: 18px;
    border-top-width: 1px;
}

.provider-add-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.provider-add-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    min-width: 150px;
}

.provider-add-card:hover {
    border-color: var(--accent-blue);
    background: rgba(58, 143, 209, 0.07);
}

.provider-add-card:active {
    transform: scale(0.97);
}

.provider-add-card:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.provider-add-card-plus {
    margin-left: auto;
    font-size: 1.1rem;
    color: var(--accent-blue);
    font-weight: 700;
    line-height: 1;
}

/* ===== CSV Import Modal ===== */
.csv-import-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.csv-import-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 24px;
    min-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.csv-import-modal-box h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.csv-import-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.csv-modal-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--font-family);
}

.csv-modal-cancel:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ===== Delete button ===== */
.delete-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.delete-btn:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: rgba(255, 82, 82, 0.1);
}

.delete-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Clickable CR rows & detail sub-table ===== */
.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}

.clickable-row:hover {
    background: var(--bg-row-hover);
}

.clickable-row.expanded {
    background: var(--bg-row-hover);
}

.detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border-color);
}

.detail-row-inner {
    background: var(--bg-secondary);
    padding: 12px 16px;
    animation: slideDown 0.2s ease-out;
}

.detail-row-inner .sub-table {
    font-size: 12px;
}

.detail-row-inner .sub-table th {
    font-size: 10px;
    padding: 6px 10px;
    color: var(--text-muted);
}

.detail-row-inner .sub-table td {
    padding: 6px 10px;
    font-size: 12px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* ===== Impersonation Bar ===== */
.impersonation-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #ff9800;
    color: #000;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 200;
}

.impersonation-bar.active {
    display: flex;
}

.impersonation-exit-btn {
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.3);
    color: #000;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s;
}

.impersonation-exit-btn:hover {
    background: rgba(0,0,0,0.25);
}

.main-content.with-impersonation-bar {
    padding-top: 68px;
}

/* ===== Guide Page ===== */
.guide-section {
    margin-bottom: 24px;
}

.guide-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.guide-intro {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 16px;
}

.guide-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.guide-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 10px 0;
}

.guide-card ul {
    margin: 8px 0 12px 0;
    padding-left: 20px;
}

.guide-card li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 4px;
}

.guide-card li strong {
    color: var(--text-primary);
}

.guide-tip {
    background: rgba(118, 255, 3, 0.06);
    border: 1px solid rgba(118, 255, 3, 0.15);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 8px;
}

.guide-tip strong {
    color: var(--accent-green);
}

/* ===== Dashboard top grid & map ===== */
.dashboard-top-grid {
    display: grid;
    grid-template-columns: minmax(300px, 560px) 1fr;
    gap: 32px;
    align-items: start;
    margin-bottom: 32px;
}

.africa-map-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 560px;
    height: 600px;
}

/* ===== Reusable layout helpers ===== */
.pdv-header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.balance-row {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* ===== KPI Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px 22px;
    border-left: 4px solid var(--accent-pink);
    transition: border-color 0.15s;
}

.kpi-card.accent-blue { border-left-color: var(--accent-blue); }
.kpi-card.accent-green { border-left-color: var(--accent-green); }
.kpi-card.accent-yellow { border-left-color: var(--accent-yellow); }

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi-label .kpi-icon {
    font-size: 15px;
    opacity: 0.8;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-value .kpi-unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* ===== Ranking Lists (Top PdV) ===== */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item:hover {
    background: var(--bg-row-hover);
}

.ranking-rank {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.ranking-rank.gold { background: rgba(255, 214, 0, 0.15); color: var(--accent-yellow); border-color: rgba(255, 214, 0, 0.3); }
.ranking-rank.silver { background: rgba(192, 192, 210, 0.12); color: #c0c0d2; border-color: rgba(192, 192, 210, 0.25); }
.ranking-rank.bronze { background: rgba(205, 127, 50, 0.12); color: #cd7f32; border-color: rgba(205, 127, 50, 0.25); }

.ranking-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.ranking-name a {
    color: var(--text-primary);
    transition: color 0.15s;
}

.ranking-name a:hover {
    color: var(--accent-blue);
    text-decoration: none;
}

.ranking-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ranking-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    display: block;
    margin-top: 1px;
}

.ranking-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

/* ===== MM Dashboard Cards (redesigned) ===== */
.mm-country-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.mm-dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px 20px;
    transition: border-color 0.15s;
}

.mm-dashboard-card:hover {
    border-color: var(--text-muted);
}

.mm-dashboard-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.mm-dashboard-balance {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 10px;
}

.mm-dashboard-balance .mm-currency {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

.mm-dashboard-transfer {
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.mm-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.mm-section-actions {
    display: flex;
    gap: 8px;
}

/* ===== Scan FAB & Modal ===== */
.scan-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.4);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.scan-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(74, 158, 255, 0.55);
}

.scan-fab:active {
    transform: scale(0.95);
}

.scan-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.scan-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px 24px;
    min-width: 320px;
    max-width: 400px;
    text-align: center;
}

.scan-modal-box h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.scan-result-success {
    background: rgba(118, 255, 3, 0.08);
    border: 1px solid rgba(118, 255, 3, 0.25);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
}

.scan-result-fail {
    background: rgba(255, 214, 0, 0.08);
    border: 1px solid rgba(255, 214, 0, 0.25);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
}

.scan-result-none {
    background: rgba(136, 136, 168, 0.08);
    border: 1px solid rgba(136, 136, 168, 0.25);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.scan-modal-close {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 24px;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s;
}

.scan-modal-close:hover {
    background: var(--bg-row-hover);
}

.scan-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 30%;
    border: 2px solid var(--accent-blue);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.scan-guide::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 4%;
    right: 4%;
    height: 2px;
    background: var(--accent-red);
    opacity: 0.7;
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 30%; }
    50% { top: 70%; }
}

.scan-modal-box--scanner {
    padding: 16px;
    max-width: 92vw;
    width: 460px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* ===== Multi-scan item list ===== */
.scan-item-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
    padding: 0 2px;
}

.scan-item-list:empty {
    display: none;
}

.scan-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    animation: scanItemIn 0.2s ease-out;
}

.scan-item .scan-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

.scan-item .scan-item-qty {
    background: var(--accent-pink);
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.scan-item .scan-item-price {
    color: var(--accent-green);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.scan-item.scan-item--unknown {
    border-color: rgba(255, 214, 0, 0.3);
    background: rgba(255, 214, 0, 0.06);
}

.scan-item.scan-item--unknown .scan-item-name {
    color: var(--accent-yellow);
}

@keyframes scanItemIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scan flash feedback */
.scan-flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 8px;
    z-index: 10;
    animation: scanFlash 0.4s ease-out forwards;
}

.scan-flash--success {
    background: rgba(118, 255, 3, 0.3);
}

.scan-flash--warning {
    background: rgba(255, 214, 0, 0.3);
}

@keyframes scanFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Scanner action buttons row */
.scan-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.scan-validate-btn {
    background: var(--accent-green);
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: opacity 0.15s;
}

.scan-validate-btn:hover {
    opacity: 0.85;
}

.scan-validate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Recap modal table */
.scan-recap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 12px 0;
    text-align: left;
}

.scan-recap-table th {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.scan-recap-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.scan-recap-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 700;
    border-top: 2px solid var(--border-color);
    margin-top: 8px;
}

.scan-recap-total .total-amount {
    color: var(--accent-green);
}

#scan-viewport {
    min-height: 240px;
    background: #000;
}

#scan-viewport video,
#scan-viewport canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
}

@media (max-width: 600px) {
    .scan-fab {
        bottom: 72px;
        right: 16px;
    }

    .scan-modal-box {
        min-width: auto;
        width: calc(100vw - 32px);
        max-width: none;
    }
}

/* ===== Responsive: Tablet (<=900px) ===== */
@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-top-grid {
        grid-template-columns: 1fr;
    }

    .africa-map-container {
        max-width: 100%;
        height: 400px;
    }

    .sidebar {
        width: 60px;
    }

    .sidebar-logo,
    .sidebar-nav a span:not(.nav-icon) {
        display: none;
    }

    .sidebar-nav a {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-nav a.active {
        margin-right: 4px;
    }

    .main-content {
        margin-left: 60px;
        padding: 24px 16px;
    }

    .impersonation-bar {
        left: 60px;
    }

    /* Filters: wrap on tablet */
    .filters {
        flex-wrap: wrap;
        gap: 12px;
    }

    .filter-group select,
    .filter-group input[type="text"] {
        min-width: 140px;
    }

    /* Tables: horizontal scroll */
    .data-table,
    .transactions-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .transactions-table thead,
    .transactions-table tbody,
    .transactions-table tr {
        display: table;
        width: 100%;
        table-layout: auto;
    }

    .data-table td,
    .data-table th {
        padding: 12px 10px;
        font-size: 13px;
    }

    /* Commission bar: smaller text */
    .commission-bar .bar-segment {
        font-size: 10px;
        padding: 0 6px;
    }

    /* User bar: hide text */
    .user-bar {
        padding: 12px 8px;
        align-items: center;
    }

    .user-bar .username {
        display: none;
    }

    .user-bar .settings-link,
    .user-bar .logout-btn {
        font-size: 11px;
        text-align: center;
    }

    /* Settings card: full width */
    .settings-card {
        max-width: 100%;
    }

    /* Modal: fit screen */
    .csv-import-modal-box {
        min-width: auto;
        width: 90vw;
        max-width: 400px;
    }

    /* KPI grid: 2 columns on tablet */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-value {
        font-size: 22px;
    }

    /* MM dashboard grid */
    .mm-dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Guide cards: less padding */
    .guide-card {
        padding: 20px;
    }
}

/* ===== Responsive: Mobile (<=600px) ===== */
@media (max-width: 600px) {
    /* Sidebar: bottom nav bar */
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-height: auto;
        height: 56px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 0;
        z-index: 100;
    }

    .sidebar-logo {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        height: 100%;
        gap: 0;
    }

    .sidebar-nav li {
        flex: 1;
    }

    .sidebar-nav a {
        flex-direction: column;
        gap: 2px;
        padding: 8px 4px;
        justify-content: center;
        align-items: center;
        border-left: none;
        font-size: 10px;
    }

    .sidebar-nav a span:not(.nav-icon) {
        display: none;
    }

    .sidebar-nav .nav-icon {
        font-size: 18px;
    }

    .sidebar-nav a.active {
        border-left: none;
        border-radius: 8px;
        margin: 4px 2px;
    }

    /* User bar: hidden on mobile, accessible via settings page */
    .user-bar {
        display: none;
    }

    /* Main content: no sidebar margin, bottom padding for nav */
    .main-content {
        margin-left: 0;
        padding: 16px 12px 72px 12px;
    }

    /* Impersonation bar: full width */
    .impersonation-bar {
        left: 0;
        font-size: 12px;
        padding: 6px 12px;
    }

    .main-content.with-impersonation-bar {
        padding-top: 52px;
    }

    /* Page title */
    .page-title {
        font-size: 18px;
        margin-bottom: 16px;
    }

    /* Filters: stack vertically */
    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group select,
    .filter-group input[type="text"] {
        min-width: 100%;
        width: 100%;
    }

    /* Tables: card-like layout for small screens */
    .data-table td,
    .data-table th {
        padding: 10px 8px;
        font-size: 12px;
    }

    .data-table thead th {
        font-size: 10px;
        padding: 8px;
    }

    .transactions-table td,
    .transactions-table th {
        padding: 6px 8px;
        font-size: 11px;
    }

    .transactions-table th {
        font-size: 10px;
    }

    /* Balance boxes: stack */
    .balance-value {
        font-size: 20px;
    }

    .balance-box {
        padding: 16px;
    }

    /* Commission bar: stack labels */
    .commission-info {
        flex-direction: column;
        gap: 8px;
    }

    .commission-bar {
        flex-direction: column;
        height: auto;
    }

    .commission-bar .bar-segment {
        height: 32px;
        font-size: 11px;
        width: 100% !important;
    }

    .bar-labels {
        flex-direction: column;
        gap: 2px;
    }

    /* Dashboard top grid: stack on mobile */
    .dashboard-top-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .africa-map-container {
        max-width: 100%;
        height: 300px;
    }

    /* Detail sections */
    .detail-section {
        padding: 16px;
    }

    /* Balance boxes: stack on mobile */
    .balance-row {
        flex-direction: column;
    }

    /* Login card */
    .login-card {
        padding: 32px 24px;
        margin: 0 12px;
        max-width: none;
    }

    /* Modal */
    .csv-import-modal-box {
        width: calc(100vw - 24px);
        max-width: none;
        padding: 20px 16px;
    }

    /* KPI grid: single column on mobile */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .kpi-card {
        padding: 14px 16px;
    }

    .kpi-value {
        font-size: 20px;
    }

    /* Ranking items: tighter */
    .ranking-item {
        padding: 10px 10px;
        gap: 8px;
    }

    /* MM dashboard grid: single column */
    .mm-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .mm-section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Settings card */
    .settings-card {
        max-width: 100%;
        padding: 20px 16px;
    }

    /* Guide page */
    .guide-card {
        padding: 16px;
    }

    .guide-section-title {
        font-size: 16px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 2px;
    }

    .pagination button {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 11px;
    }

    /* Status badges */
    .status-badge {
        font-size: 10px;
        padding: 2px 8px;
    }

    /* Action buttons */
    .import-csv-btn,
    .import-stock-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    /* Provider add section */
    .provider-add-cards {
        flex-direction: column;
    }

    .provider-add-card {
        min-width: auto;
    }

    /* Loading */
    .loading {
        padding: 32px;
    }
}
