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

:root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --border: #e4e8ef;
    --border2: #d0d7e2;
    --text: #0d1117;
    --text2: #3d4757;
    --muted: #6b7685;
    --dim: #9ba5b4;
    --sidebar-bg: #0d1117;
    --sidebar-txt: #c9d1dc;
    --sidebar-dim: #5a6272;
    --green: #16a34a;
    --green-light: #dcfce7;
    --green-bar: #22c55e;
    --red: #dc2626;
    --red-light: #fee2e2;
    --red-bar: #ef4444;
    --orange: #ea580c;
    --blue: #2563eb;
    --blue-light: #dbeafe;
    --yellow: #d97706;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .04);
    --mono: 'Geist Mono', monospace;
    --sans: 'Geist', system-ui, sans-serif;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 99px;
}

#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

#login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    animation: fadeUp 0.3s ease;
}

#login-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 28px;
}

#login-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-light);
}

#login-box h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

#login-sub {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 24px;
}

#login-error {
    background: var(--red-light);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    color: var(--red);
    font-size: 13px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
}

.field input {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--sans);
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field input::placeholder {
    color: var(--dim);
}

#login-btn {
    width: 100%;
    margin-top: 8px;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--sans);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

#login-btn:hover {
    opacity: 0.85;
}

#login-btn:active {
    transform: scale(0.98);
}

#login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#dashboard {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    border-right: 1px solid #1e242e;
    flex-shrink: 0;
}

#sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    padding: 4px 8px 20px;
    border-bottom: 1px solid #1e242e;
    margin-bottom: 12px;
}

#sidebar-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--sidebar-dim);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
    background: #1a2030;
    color: var(--sidebar-txt);
}

.nav-item.active {
    background: #1a2030;
    color: #fff;
}

#sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 8px 0;
    border-top: 1px solid #1e242e;
}

#sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

#sidebar-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

#sidebar-email-label {
    font-size: 11px;
    color: var(--sidebar-dim);
    font-family: var(--mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#logout-btn {
    background: none;
    border: none;
    color: var(--sidebar-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.12s;
}

#logout-btn:hover {
    color: var(--red-bar);
}

#main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 4px;
    flex-shrink: 0;
}

#page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

#page-sub {
    font-size: 12px;
    color: var(--muted);
    font-family: var(--mono);
}

#topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#last-updated {
    font-size: 11px;
    color: var(--dim);
    font-family: var(--mono);
}

#refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-size: 12px;
    font-family: var(--sans);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

#refresh-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

#error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--red-light);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--red);
    font-size: 13px;
    flex-shrink: 0;
}

#stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    flex-shrink: 0;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.3s ease both;
}

.sc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sc-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sc-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-icon.neutral {
    background: #f1f5f9;
    color: var(--muted);
}

.sc-icon.green {
    background: var(--green-light);
    color: var(--green);
}

.sc-icon.red {
    background: var(--red-light);
    color: var(--red);
}

.sc-icon.blue {
    background: var(--blue-light);
    color: var(--blue);
}

.sc-value {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-bottom: 4px;
}

.sc-value.green {
    color: var(--green);
}

.sc-value.red {
    color: var(--red);
}

.sc-value.blue {
    color: var(--blue);
}

.sc-sub {
    font-size: 11px;
    color: var(--dim);
    font-family: var(--mono);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: fadeUp 0.35s ease both;
}

.card.fill {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.card-sub {
    font-size: 11px;
    color: var(--muted);
    font-family: var(--mono);
}

#chart-legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

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

.leg-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.leg-dot.green {
    background: var(--green-bar);
}

.leg-dot.red {
    background: var(--red-bar);
}

#chart-wrap {
    display: flex;
    padding: 24px 20px 0;
    gap: 10px;
    align-items: flex-end;
}

#chart-y {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    min-width: 36px;
    height: 200px;
    padding-bottom: 28px;
    font-size: 10px;
    font-family: var(--mono);
    color: var(--dim);
}

#chart-body {
    flex: 1;
    overflow: hidden;
}

#chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    padding: 8px 4px 0;
    background: repeating-linear-gradient(to top,
            transparent,
            transparent calc(25% - 1px),
            #f1f5f9 calc(25% - 1px),
            #f1f5f9 25%);
    border-radius: 2px 2px 0 0;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    cursor: pointer;
    position: relative;
    transition: opacity 0.15s;
    min-width: 0;
}

.bar-col:hover {
    opacity: 0.8;
}

.bar-success {
    background: var(--green-bar);
    width: 100%;
    min-height: 0;
    border-radius: 0;
}

.bar-failed {
    background: var(--red-bar);
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
}

.bar-only-success {
    border-radius: 3px 3px 0 0;
}

#chart-x {
    display: flex;
    gap: 4px;
    padding-top: 6px;
    padding-bottom: 20px;
    padding-left: 4px;
}

.x-label {
    flex: 1;
    text-align: center;
    font-size: 9px;
    font-family: var(--mono);
    color: var(--dim);
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
}

#chart-tooltip {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #0d1117;
    color: #f1f5f9;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    font-family: var(--mono);
    pointer-events: none;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    min-width: 160px;
    border: 1px solid #1e242e;
}

.tt-hour {
    color: #64748b;
    font-size: 11px;
    margin-bottom: 8px;
    font-weight: 500;
}

.tt-success {
    color: #4ade80;
    margin-bottom: 3px;
}

.tt-failed {
    color: #f87171;
}

.tt-total {
    color: #94a3b8;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #1e242e;
    font-size: 11px;
}

.badge-red {
    font-size: 11px;
    font-family: var(--mono);
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fca5a5;
    border-radius: 99px;
    padding: 2px 10px;
    font-weight: 500;
}

#table-wrap {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--mono);
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
}

thead tr {
    border-bottom: 1px solid var(--border);
}

th {
    padding: 9px 16px;
    text-align: left;
    color: var(--dim);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background: var(--surface);
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.selected {
    background: #eff6ff;
}

td {
    padding: 10px 16px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

td.td-method {
    color: var(--muted);
    font-weight: 500;
}

td.td-path {
    color: var(--text);
    max-width: 180px;
}

td.td-error {
    color: var(--muted);
    max-width: 220px;
}

td.td-duration {
    color: var(--dim);
}

td.td-ip {
    color: var(--dim);
}

td.td-time {
    color: var(--dim);
}

.status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: 5px;
    padding: 2px 7px;
}

.s5xx {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fca5a5;
}

.s4xx {
    background: #fff7ed;
    color: var(--orange);
    border: 1px solid #fed7aa;
}

.s401,
.s403 {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fca5a5;
}

.s429 {
    background: #fefce8;
    color: var(--yellow);
    border: 1px solid #fde68a;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 44px 20px;
    color: var(--dim);
    font-size: 13px;
    font-family: var(--mono);
}

.spin {
    animation: spin 1s linear infinite;
}

.hidden {
    display: none !important;
}

#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.15s ease;
}

#modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalUp 0.2s ease;
}

#modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: #f8fafc;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#modal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--mono);
}

#modal-close {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background 0.1s, color 0.1s;
}

#modal-close:hover {
    background: var(--border);
    color: var(--text);
}

#modal-body {
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    padding: 20px;
}

#modal-content {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--blue);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.7;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes modalUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 900px) {
    #stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    #sidebar {
        display: none;
    }

    #stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    #main {
        padding: 16px;
    }
}