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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.container.hidden {
    display: none;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

.login-box {
    background: #2a2a4a;
    border-radius: 12px;
    padding: 40px;
    border: 1px solid #333;
    text-align: center;
    width: 100%;
    max-width: 360px;
    margin: 20px;
}

.login-box h2 {
    color: #00d4ff;
    margin-bottom: 24px;
    font-size: 20px;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a2e;
    color: #eee;
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.login-box input::placeholder {
    color: #666;
}

.login-box button {
    width: 100%;
}

.login-error {
    color: #ff4444;
    margin-top: 12px;
    font-size: 14px;
}

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

/* Logout button */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.logout-btn {
    background: #444;
    color: #eee;
}

.logout-btn:hover {
    background: #555;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    color: #00d4ff;
}

.header-controls {
    display: flex;
    gap: 20px;
    align-items: center;
}

.db-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.db-switcher select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #444;
    background: #2a2a4a;
    color: #eee;
    cursor: pointer;
}

.ws-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
}

.indicator.online {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

.indicator.offline {
    background: #ff4444;
    box-shadow: 0 0 8px #ff4444;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    background: #00d4ff;
    color: #1a1a2e;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #00b4d8;
}

.btn.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #2a2a4a;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    border: 1px solid #333;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #00d4ff;
}

.stat-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.main-content {
    background: #2a2a4a;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #333;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 12px;
}

.tab {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: #eee;
    background: #333;
}

.tab.active {
    color: #00d4ff;
    background: #1a1a2e;
    border: 1px solid #00d4ff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #00d4ff;
}

.refresh-controls, .filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.filter-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
}

.filter-controls input[type="checkbox"] {
    cursor: pointer;
}

.log-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.log-filters input,
.log-filters select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #444;
    background: #1a1a2e;
    color: #eee;
    font-size: 14px;
}

.log-filters input::placeholder {
    color: #666;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    background: #1a1a2e;
    color: #00d4ff;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr:hover {
    background: rgba(0, 212, 255, 0.1);
}

.loading {
    text-align: center;
    color: #666;
    padding: 40px !important;
}

.match-type {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.match-type.PREMATCH { background: #336699; }
.match-type.LIVE { background: #00aa55; }
.match-type.CHECK_RESULTS { background: #ffaa00; color: #1a1a2e; }
.match-type.CLOSED { background: #555; }

.stake-action {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.stake-action.WIN { background: #00aa55; color: white; }
.stake-action.LOSS { background: #aa0000; color: white; }
.stake-action.REFUND { background: #ffaa00; color: #1a1a2e; }
.stake-action.SKIP { background: #666; color: white; }
.stake-action.LOCK { background: #aa5500; color: white; }

.reason-code {
    font-family: monospace;
    font-size: 11px;
    background: #333;
    padding: 2px 6px;
    border-radius: 3px;
}

.handler-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.handler-status.COMPLETED { background: #00aa55; }
.handler-status.FAILED { background: #aa0000; }
.handler-status.STARTED { background: #336699; }

.handler-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.handler-card {
    background: #1a1a2e;
    border-radius: 6px;
    padding: 16px;
    border: 1px solid #333;
}

.handler-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.handler-card-name {
    font-weight: 600;
    color: #00d4ff;
}

.handler-card-status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.handler-card-status.COMPLETED { background: #00aa55; }
.handler-card-status.FAILED { background: #aa0000; }
.handler-card-status.STARTED { background: #336699; }

.handler-card-time {
    font-size: 12px;
    color: #888;
}

.handler-card-stats {
    font-size: 12px;
    color: #aaa;
    margin-top: 8px;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 6px;
    background: #2a2a4a;
    border: 1px solid #00d4ff;
    color: #eee;
    z-index: 1000;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.toast.error {
    border-color: #aa0000;
}

.toast.success {
    border-color: #00aa55;
}

.action-btn {
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    background: #336699;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #4477aa;
}

/* Compare Tab */
.compare-summary {
    margin-bottom: 16px;
}

.compare-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px;
    background: #1a1a2e;
    border-radius: 6px;
    border: 1px solid #333;
    font-size: 13px;
}

.compare-stats span {
    color: #aaa;
}

.compare-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.compare-status.match { background: #00aa55; color: white; }
.compare-status.diff { background: #aa0000; color: white; }
.compare-status.DB_NULL { background: #ff8800; color: #1a1a2e; }
.compare-status.REFUND { background: #8800ff; color: white; }
.compare-status.SKIP_CALC { background: #666; color: white; }

.error {
    color: #ff4444;
    padding: 12px;
    background: rgba(255, 68, 68, 0.1);
    border-radius: 6px;
    border: 1px solid #aa0000;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .header-controls {
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .db-switcher {
        flex-wrap: wrap;
        width: 100%;
    }

    .db-switcher select {
        flex: 1;
        min-width: 100px;
    }

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

    .stat-card {
        padding: 14px;
    }

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

    .stat-label {
        font-size: 10px;
    }

    .tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .main-content {
        padding: 12px;
    }

    .panel h2 {
        font-size: 16px;
    }

    .refresh-controls,
    .filter-controls,
    .log-filters {
        flex-wrap: wrap;
        gap: 8px;
    }

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

    .table-container {
        max-height: 400px;
        font-size: 12px;
    }

    th, td {
        padding: 8px 6px;
        font-size: 12px;
    }

    th {
        font-size: 11px;
    }

    .handler-summary {
        grid-template-columns: 1fr;
    }

    .handler-card {
        padding: 12px;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 18px;
    }

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

    .tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn.btn-small {
        padding: 8px 12px;
        font-size: 12px;
    }

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

    .login-box {
        padding: 24px;
        margin: 16px;
    }

    .login-box h2 {
        font-size: 18px;
    }

    .login-box input {
        font-size: 16px;
        padding: 14px;
    }
}

/* Banner Settings */
.banner-section {
    background: #252540;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.banner-section h3 {
    margin-bottom: 12px;
    color: #fff;
}

.banner-preview {
    width: 100%;
    max-width: 400px;
    height: 120px;
    background: #1a1a2e;
    border-radius: 6px;
    margin-bottom: 12px;
    background-size: cover;
    background-position: center;
    border: 1px solid #333;
}

.banner-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden-input + .btn {
    cursor: pointer;
}
