:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #181818;
    --bg-card-hover: #1e1e1e;
    --bg-sidebar: #0e0e0e;
    --bg-input: #1a1a1a;
    --border-color: #2a2a2a;
    --border-light: #333333;
    --text-primary: #e8e8e8;
    --text-secondary: #999999;
    --text-muted: #666666;
    --accent-green: #00c853;
    --accent-green-dim: rgba(0, 200, 83, 0.15);
    --accent-blue: #2196f3;
    --accent-blue-dim: rgba(33, 150, 243, 0.15);
    --accent-orange: #ff9800;
    --accent-orange-dim: rgba(255, 152, 0, 0.15);
    --accent-purple: #ab47bc;
    --accent-purple-dim: rgba(171, 71, 188, 0.15);
    --accent-red: #ef5350;
    --accent-red-dim: rgba(239, 83, 80, 0.15);
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s;
    overflow: hidden;
}
.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.sidebar-header .subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
    text-decoration: none;
}
.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
}
.nav-item svg { margin-right: 10px; flex-shrink: 0; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
}
.sidebar-footer a { color: var(--accent-red); }

/* Main content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: var(--bg-primary);
}
.page-header {
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 22px;
    font-weight: 600;
}
.page-header .page-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards */
.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-light); }
.card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.card-value {
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.card-value.green { color: var(--accent-green); }
.card-value.blue { color: var(--accent-blue); }
.card-value.orange { color: var(--accent-orange); }
.card-value.purple { color: var(--accent-purple); }

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
}
.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-card); }

/* Source badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-psc { background: var(--accent-orange-dim); color: var(--accent-orange); }
.badge-paypal { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-bank { background: var(--accent-purple-dim); color: var(--accent-purple); }

/* Feed */
.live-feed {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.feed-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}
.feed-header h3 { font-size: 14px; font-weight: 600; }
.live-dot {
    width: 8px; height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.feed-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
    list-style: none;
}
.feed-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.feed-item .feed-source { width: 60px; flex-shrink: 0; }
.feed-item .feed-user { flex: 1; color: var(--text-secondary); font-size: 13px; }
.feed-item .feed-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.feed-item .feed-time { color: var(--text-muted); font-size: 12px; margin-left: 16px; min-width: 50px; text-align: right; }
.feed-empty { padding: 40px; text-align: center; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--accent-blue); }
.form-control::placeholder { color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #1e88e5; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #e53935; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}
.login-box {
    width: 360px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.login-box h1 {
    font-size: 20px;
    margin-bottom: 8px;
    text-align: center;
}
.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}
.login-error {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}
.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header h3 { font-size: 16px; font-weight: 600; }

/* Mobile header — hidden on desktop */
.mobile-header { display: none; }

/* Image previews */
.feed-image-row {
    list-style: none;
    padding: 8px 16px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    animation: slideIn 0.2s ease;
}
.feed-image-row img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    display: block;
}
.history-image-row { animation: slideIn 0.2s ease; }
.history-image-cell {
    padding: 12px !important;
    background: var(--bg-secondary);
    text-align: center;
}
.history-image-cell img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
}
.history-image-close {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}
.history-image-close:hover { color: var(--text-primary); }

/* Responsive — Mobile */
@media (max-width: 768px) {
    /* Hide sidebar, show bottom tab bar */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100% !important;
        height: 56px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        z-index: 100;
    }
    .sidebar-header, .sidebar-footer { display: none; }
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        width: 100%;
        height: 100%;
        align-items: stretch;
    }
    .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 4px 0;
        margin: 0;
        border-radius: 0;
        font-size: 10px;
        gap: 2px;
    }
    .nav-item svg { margin-right: 0; width: 20px; height: 20px; }
    .nav-text { display: block !important; }

    /* Main content adjustments */
    .app-container { flex-direction: column; }
    .main-content {
        padding: 16px 12px 72px;
        height: auto;
        overflow-y: auto;
    }

    /* Page header */
    .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
    .page-header h2 { font-size: 18px; }

    /* Cards */
    .cards-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .card { padding: 14px; }
    .card-value { font-size: 20px; }
    .card-label { font-size: 11px; }

    /* Tables */
    .data-table { font-size: 12px; }
    .data-table thead th { padding: 8px 6px; font-size: 10px; }
    .data-table tbody td { padding: 8px 6px; }

    /* Feed */
    .feed-item {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 4px;
    }
    .feed-item .feed-source { order: 1; }
    .feed-item .feed-user { order: 2; flex: 1; }
    .feed-item .feed-amount { order: 3; }
    .feed-item .feed-time { order: 4; min-width: auto; margin-left: 8px; }
    .feed-image-row { padding: 8px 12px; }
    .feed-image-row img { max-height: 300px; }

    /* History image */
    .history-image-cell img { max-height: 300px; }

    /* Worker grid */
    .worker-grid { grid-template-columns: 1fr; }

    /* Forms */
    .form-control { font-size: 16px; padding: 12px; }
    .btn { min-height: 44px; font-size: 14px; }

    /* Filters */
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar select, .filters-bar input { width: 100%; font-size: 16px; padding: 10px 12px; }

    /* Pagination */
    .pagination { flex-wrap: wrap; }
    .pagination button { min-height: 44px; padding: 8px 16px; }

    /* Response time */
    .rt-value { font-size: 26px; }

    /* Mobile header with logout */
    .mobile-header {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 8px;
    }
    .mobile-logout {
        font-size: 12px;
        color: var(--text-muted);
        padding: 4px 8px;
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}
.pagination button {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
}
.pagination button:hover { background: var(--bg-card-hover); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .page-info { font-size: 13px; color: var(--text-secondary); }

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.filters-bar select, .filters-bar input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}
.filters-bar select:focus, .filters-bar input:focus { border-color: var(--accent-blue); }

/* Worker card */
.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.worker-card { padding: 16px; }
.worker-card .worker-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.worker-card .worker-id { font-size: 12px; color: var(--text-muted); }
.worker-card .worker-status { margin-top: 8px; font-size: 12px; }
.status-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.authorized { background: var(--accent-green); }
.status-dot.pending { background: var(--accent-orange); }
.status-dot.none { background: var(--text-muted); }

/* Response time display */
.rt-card {
    padding: 16px;
}
.rt-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-blue);
}
.rt-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.rt-detail {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}
