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

:root {
    --primary: #0B6B3A;
    --primary-dark: #084F2A;
    --primary-light: #1E8A52;
    --accent: #D4AF37;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --warning: #f59e0b;
    --error: #dc2626;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.08);
}

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

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

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-accent {
    background: var(--accent);
    color: #1a1a1a;
}

.btn-accent:hover {
    background: #c4a137;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card h3 {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary);
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
    max-width: 100%;
}

@media (max-width: 640px) {
    .stat-card .value {
        font-size: 18px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .stat-card .value {
        font-size: 22px;
    }
}

.filter-bar {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input, .filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 107, 58, 0.1);
}

.token-section {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.token-input-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.token-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 12px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table-wrapper {
    overflow-x: auto;
}

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

.table th, .table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: #f9fafb;
    font-weight: 600;
}

.table tr {
    transition: background 0.2s;
}

.table tr:hover {
    background: #f9fafb;
    cursor: pointer;
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    display: inline-block;
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    display: inline-block;
}

.badge-info {
    background: #dbeafe;
    color: #2563eb;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    display: inline-block;
}

.view-receipt-btn {
    background: var(--accent);
    color: #1a1a1a;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.view-receipt-btn:hover {
    background: #c4a137;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    margin-top: 10px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-dark);
}

.pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.health-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.health-badge {
    background: white;
    padding: 15px;
    border-radius: var(--radius-lg);
    text-align: center;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.health-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.health-badge.healthy {
    border-left-color: var(--success);
}

.health-badge.unhealthy {
    border-left-color: var(--error);
}

.health-badge .status {
    font-size: 18px;
    font-weight: bold;
}

.health-badge.healthy .status {
    color: var(--success);
}

.health-badge.unhealthy .status {
    color: var(--error);
}

.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.worker-badge {
    background: #f8f9fa;
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: center;
    border-left: 3px solid var(--success);
    transition: transform 0.2s;
}

.worker-badge:hover {
    transform: translateX(2px);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
}

.metric-card .metric-value {
    font-size: 28px;
    font-weight: bold;
}

.metric-card h4 {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    animation: fadeIn 0.2s;
}

.modal-content {
    position: relative;
    background: white;
    margin: 50px auto;
    padding: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    animation: slideIn 0.3s ease;
}

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

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    transition: color 0.2s;
}

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

.loading, .error {
    text-align: center;
    padding: 40px;
}

.error {
    color: var(--error);
}

.alert {
    padding: 10px;
    border-radius: var(--radius-md);
    margin-top: 10px;
    display: none;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    display: block;
}

.alert-error {
    background: #fee2e2;
    color: var(--error);
    display: block;
}

.alert-warning {
    background: #fef3c7;
    color: var(--warning);
    display: block;
}

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

.mt-2 {
    margin-top: 16px;
}

pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 12px;
    font-family: monospace;
}

code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.historical-controls {
    background: #f9fafb;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.time-period-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.custom-date-range {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.custom-date-range label {
    font-size: 13px;
    color: var(--muted);
}

.historical-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.historical-stats-grid .stat-card {
    background: white;
    padding: 20px 16px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 0;
    overflow: hidden;
}

.historical-stats-grid .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.historical-stats-grid .stat-card h3 {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.historical-stats-grid .stat-card .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
    max-width: 100%;
}

@media (max-width: 768px) {
    .historical-stats-grid .stat-card .value {
        font-size: 18px;
    }
}

.period-info {
    background: #f0fdf4;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    border-left: 3px solid var(--primary);
    font-size: 13px;
}

.period-info p {
    margin: 4px 0;
}

#historical-chart {
    max-height: 400px;
    width: 100%;
    margin-top: 20px;
}

canvas#historical-chart {
    max-width: 100%;
    height: auto;
}

@media print {
    .token-section, .tabs, .filter-bar, .pagination, .btn, .close, .historical-controls {
        display: none;
    }
    
    .modal-content {
        margin: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

@media (max-width: 768px) {
    .container { padding: 12px; }
    .stats-grid { gap: 12px; }
    .stat-card .value { font-size: 20px; }
    .filter-group { flex-direction: column; }
    .filter-input, .filter-select { width: 100%; }
    .table th, .table td { padding: 8px; font-size: 12px; }
    .historical-controls { padding: 16px; }
    .time-period-buttons { justify-content: center; }
    .custom-date-range { justify-content: center; }
    .historical-stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .historical-stats-grid .stat-card .value { font-size: 20px; }
    .metric-card .metric-value { font-size: 20px; }
    .health-status { grid-template-columns: 1fr; }
    #historical-chart { max-height: 300px; }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

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

.formatted-currency {
    cursor: help;
    border-bottom: 1px dotted rgba(11, 107, 58, 0.3);
    transition: all 0.2s ease;
}

.formatted-currency:hover {
    background-color: rgba(11, 107, 58, 0.05);
    border-bottom-color: var(--primary);
}

.formatted-currency::after {
    content: ' ℹ️';
    font-size: 10px;
    opacity: 0.6;
    visibility: hidden;
}

.formatted-currency:hover::after {
    visibility: visible;
}
