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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    line-height: 1.5;
}

header {
    background: #1e293b;
    color: #fff;
    padding: 1rem 2rem;
}

header h1 { font-size: 1.25rem; font-weight: 600; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Alert */
.alert {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.filter-bar label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; }
.filter-bar input[type="date"] { padding: 0.3rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; }
.filter-bar select { padding: 0.3rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; }

.filter-bar button {
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 0.4rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.filter-bar button:hover { background: #2563eb; }
.filter-bar button.btn-secondary { background: #64748b; }
.filter-bar button.btn-secondary:hover { background: #475569; }
.filter-bar button:disabled { opacity: 0.6; cursor: default; }

/* Summary cards */
.summary-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.card {
    flex: 1;
    min-width: 150px;
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card h3 { font-size: 0.75rem; text-transform: uppercase; color: #64748b; margin-bottom: 0.25rem; }
.card span { font-size: 1.5rem; font-weight: 700; }

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.chart-container.full-width { grid-column: 1 / -1; }
.chart-container h3 { font-size: 0.875rem; margin-bottom: 0.75rem; color: #334155; }

/* Tables */
.tables-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.table-container {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.table-container h3 { font-size: 0.875rem; margin-bottom: 0.75rem; color: #334155; }

table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
thead th { text-align: left; padding: 0.5rem; border-bottom: 2px solid #e2e8f0; color: #64748b; font-weight: 600; }
tbody td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #f1f5f9; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #e0f2fe; }

/* Search bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.search-input {
    padding: 0.4rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.875rem;
    width: 220px;
}

.search-bar button {
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 0.4rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.search-bar button:hover { background: #2563eb; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 1100px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 { font-size: 1rem; color: #1e293b; }

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}

.modal-close-btn:hover { color: #1e293b; }

.modal-body {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Pager */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.pager button {
    background: #e2e8f0;
    border: none;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8125rem;
}

.pager button:hover { background: #cbd5e1; }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager button.active { background: #3b82f6; color: #fff; }
.pager span { font-size: 0.8125rem; color: #64748b; }

/* Status code colors */
.status-2xx { color: #16a34a; }
.status-3xx { color: #2563eb; }
.status-4xx { color: #ea580c; }
.status-5xx { color: #dc2626; }

/* Drill-down status filter */
.status-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 1rem;
    font-size: 0.8125rem;
}

.status-filter select {
    padding: 0.2rem 0.4rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.8125rem;
}

/* Referrer toggle */
.referrer-toggle {
    font-size: 0.75rem;
    font-weight: 400;
    margin-left: 1rem;
    color: #64748b;
    text-transform: none;
}

/* Summary card variants */
.card.card-warning span { color: #f97316; }
.card.card-danger span { color: #ef4444; }

/* Heatmap */
.heatmap-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; table-layout: fixed; }
.heatmap-table th { padding: 0.25rem 0.15rem; text-align: center; font-weight: 600; color: #64748b; font-size: 0.7rem; }
.heatmap-table .heatmap-day { font-weight: 600; color: #334155; text-align: right; padding-right: 0.5rem; width: 2.5rem; }
.heatmap-cell {
    text-align: center;
    padding: 0.3rem 0.1rem;
    border-radius: 2px;
    cursor: default;
    font-size: 0.65rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.heatmap-cell:hover { outline: 2px solid #1e293b; z-index: 1; position: relative; }
