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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1e40af;
    --secondary-color: #0ea5e9;
    --secondary-hover: #0284c7;
    --success-color: #16a34a;
    --success-hover: #15803d;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --error-color: #dc2626;
    --background: #eef2ff;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #dfe7fb;
    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.12);
    --shadow-xl: 0 30px 70px rgba(15, 23, 42, 0.18);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    background-image: linear-gradient(180deg, #f8fbff 0%, #eef2ff 55%, #e4e9ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 24px;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--surface);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    text-align: center;
    flex: 1;
}

.header-buttons {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-hover));
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #0f9d58);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--success-hover), var(--success-color));
}

.btn-sm {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
}

/* Search Section */
.search-section {
    background: var(--surface);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.search-section-date-only {
    padding: 12px 20px;
}

.search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.date-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.date-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.date-input {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.1);
}

.header-with-toolbar .title {
    text-align: left;
    min-width: 0;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.icon-btn:active {
    transform: translateY(0);
}

.icon-btn-search:hover {
    background: rgba(37, 99, 235, 0.08);
}

.icon-btn-refresh:hover {
    background: rgba(22, 163, 74, 0.08);
    border-color: var(--success-color);
    color: var(--success-color);
}

.search-dialog-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    box-sizing: border-box;
}

.search-dialog-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Statistics Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 1px solid rgba(37, 99, 235, 0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(135deg, var(--primary-color), #38bdf8);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -1px;
}

/* Clients Container */
.clients-container {
    background: var(--surface);
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    max-height: 650px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.client-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--surface);
    position: relative;
}

.client-card:last-child {
    margin-bottom: 0;
}

.client-header {
    margin-bottom: 10px;
}

.client-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
    margin: 0;
    text-align: left;
}

.client-details {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.detail-item {
    display: flex;
    gap: 5px;
    align-items: center;
}

.detail-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

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

.client-balance {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(56, 189, 248, 0.12));
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 12px;
    text-align: center;
}

.balance-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.balance-amount {
    font-size: 22px;
    font-weight: 800;
    color: var(--success-color);
}

.client-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Scrollbar Styling */
.clients-container::-webkit-scrollbar {
    width: 10px;
}

.clients-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.clients-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
    border: 2px solid var(--border-color);
}

.clients-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Agent layout — sidebar + hamburger (matches admin) */
body.agent-layout {
    padding: 0;
}

.agent-layout {
    display: flex;
    min-height: 100vh;
}

.agent-sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 8px 0 30px rgba(15, 23, 42, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.agent-sidebar-title {
    font-size: 16px;
    font-weight: 800;
    color: #3b82f6;
    padding: 24px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-sidebar-agent {
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.agent-main {
    flex: 1;
    margin-left: 260px;
    width: calc(100% - 260px);
    min-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
}

.agent-main .container {
    max-width: 1000px;
    margin: 0 auto;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: #3b82f6;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 16px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-menu-item {
    width: 100%;
}

.sidebar-menu-button {
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    background: white;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.sidebar-menu-button:hover,
.sidebar-menu-button:focus-visible {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(14, 165, 233, 0.12));
    color: #3b82f6;
    outline: none;
}

.sidebar-menu-button-danger {
    color: var(--danger-color);
}

.sidebar-menu-button-danger:hover,
.sidebar-menu-button-danger:focus-visible {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger-color);
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    margin: 4px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive Design */
@media (max-width: 768px) {
    body.agent-layout {
        padding: 0;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-close-btn {
        display: flex;
    }

    .agent-sidebar {
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        z-index: 101;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .agent-sidebar.mobile-visible {
        transform: translateX(0);
    }

    .agent-main {
        margin-left: 0;
        width: 100%;
        padding: 16px;
        padding-top: 76px;
    }

    .header-with-toolbar {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
    }

    .header-with-toolbar .title {
        font-size: 15px;
        line-height: 1.3;
    }

    .header-toolbar {
        margin-left: auto;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
    }

    .header-buttons {
        display: none;
    }

    .search-section {
        padding: 14px 16px;
    }

    .date-section {
        flex-direction: row;
        align-items: center;
        width: 100%;
        flex-wrap: wrap;
    }

    .date-input {
        width: 100%;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 28px;
    }

    .clients-container {
        padding: 16px;
    }

    .client-card {
        padding: 20px;
    }

    .client-details {
        flex-direction: column;
        gap: 12px;
    }

    .client-actions {
        flex-direction: column;
    }

    .client-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .agent-main {
        padding-top: 72px;
    }

    .mobile-menu-toggle {
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
    }

    .agent-sidebar {
        width: 100%;
        max-width: 100vw;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .title {
        font-size: 20px;
    }
}

/* Loading and Animation States */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.client-card {
    animation: fadeIn 0.3s ease-out;
}

.stat-card {
    animation: fadeIn 0.3s ease-out;
}

/* Focus States for Accessibility */
.btn:focus-visible,
.search-input:focus-visible,
.date-input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Custom Dialog/Modal */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.dialog-overlay.show {
    opacity: 1;
    visibility: visible;
}

.dialog-box {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    width: 90%;
    padding: 0;
    transform: scale(0.9) translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.dialog-overlay.show .dialog-box {
    transform: scale(1) translateY(0);
}

.dialog-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.dialog-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.dialog-icon.success {
    background: #dcfce7;
    color: #166534;
}

.dialog-icon.error {
    background: #fee2e2;
    color: #991b1b;
}

.dialog-icon.info {
    background: #dbeafe;
    color: #1e40af;
}

.dialog-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.dialog-body {
    padding: 24px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.dialog-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.dialog-btn-primary {
    background: var(--primary-color);
    color: white;
}

.dialog-btn-primary:hover {
    background: var(--primary-hover);
}

.dialog-btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.dialog-btn-secondary:hover {
    background: var(--secondary-hover);
}

/* Deposit Dialog Form Styles */
#depositForm .form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

#depositForm .form-input::placeholder {
    color: var(--text-secondary);
}

#depositForm textarea.form-input {
    font-family: inherit;
    resize: vertical;
}

/* System toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(24px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(24px);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #dcfce7;
    color: #166534;
}

.toast-error .toast-icon {
    background: #fee2e2;
    color: #991b1b;
}

.toast-warning .toast-icon {
    background: #fef3c7;
    color: #92400e;
}

.toast-info .toast-icon {
    background: #dbeafe;
    color: #1e40af;
}

.toast-success {
    border-left: 4px solid #16a34a;
}

.toast-error {
    border-left: 4px solid #dc2626;
}

.toast-warning {
    border-left: 4px solid #d97706;
}

.toast-info {
    border-left: 4px solid #2563eb;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: -2px 0 0 4px;
}

.toast-close:hover {
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

/* Responsive Dialog */
@media (max-width: 480px) {
    .dialog-box {
        max-width: 95%;
        margin: 20px;
    }

    .dialog-header {
        padding: 16px 20px;
    }

    .dialog-title {
        font-size: 16px;
    }

    .dialog-body {
        padding: 20px;
        font-size: 13px;
    }

    .dialog-footer {
        padding: 12px 20px;
        flex-direction: column-reverse;
    }

    .dialog-btn {
        width: 100%;
    }
}
