:root {
    /* Steel Blue Palette */
    --primary: #546DE5;
    --primary-hover: #485cc7;
    --secondary: #778BEB;
    --accent: #F8A5C2;
    --bg-dark: #0A0F1A;
    --bg-panel: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(0, 0, 0, 0.2);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(119, 139, 235, 0.5);

    --success: #2ed573;
    --warning: #ffa502;
    --error: #ff4757;
    --info: #1aa3ff;

    --text-main: #FFFFFF;
    --text-muted: rgba(255, 255, 255, 0.6);
    --text-dark: #1e272e;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(84, 109, 229, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(248, 165, 194, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    background: rgba(84, 109, 229, 0.1);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

/* Layout */
.grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    /* Important for scrollable children */
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 2rem 0 1.5rem 0;
}

/* Controls Form */
.control-group {
    margin-bottom: 1.25rem;
}

.control-group.row {
    display: flex;
    gap: 1rem;
}

.input-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 0.6rem 0.75rem;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
    transition: all var(--transition);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--border-focus);
}

/* Buttons */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.server-actions {
    align-items: center;
    justify-content: space-between;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    flex: 1;
}

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

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

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn.outline {
    background: transparent;
    flex: 0 1 auto;
}

.version-badge {
    background: var(--accent);
    color: var(--bg-dark);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Timeline Panel */
.timeline-panel {
    overflow: hidden;
    /* Contains the scrollable timeline */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.cache-status-badges {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    position: relative;
    cursor: help;
}

.badge.local {
    background: rgba(46, 213, 115, 0.1);
    color: var(--success);
    border-color: rgba(46, 213, 115, 0.3);
}

.badge.edge {
    background: rgba(26, 163, 255, 0.1);
    color: var(--info);
    border-color: rgba(26, 163, 255, 0.3);
}

.badge.empty {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* Tooltip */
.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 5px;
    background: var(--text-main);
    color: var(--bg-dark);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Timeline Content */
.timeline {
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Custom Scrollbar */
.timeline::-webkit-scrollbar {
    width: 6px;
}

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

.timeline::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

/* Network Flow Event Cards */
.event-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
}

.event-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.status-code {
    font-family: ui-monospace, monospace;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-200 {
    background: rgba(46, 213, 115, 0.2);
    color: var(--success);
}

.status-304 {
    background: rgba(255, 165, 2, 0.2);
    color: var(--warning);
}

.status-local {
    background: rgba(162, 155, 254, 0.2);
    color: var(--secondary);
}

.time-stamp {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.event-body {
    padding: 1rem;
}

.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
}

.node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    width: 60px;
}

.node.active {
    color: var(--text-main);
}

.node svg {
    width: 24px;
    height: 24px;
}

.path {
    flex: 1;
    height: 2px;
    background: var(--border);
    position: relative;
    margin: 0 10px;
}

.path.active {
    background: var(--primary);
}

.path.cache-hit {
    background: var(--success);
}

.path.not-modified {
    background: var(--warning);
}

.path.skipped {
    opacity: 0.2;
}

.path::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    transform: translate(0, -50%);
    border-left: 6px solid inherit;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.path.active::after {
    border-left-color: var(--primary);
}

.path.cache-hit::after {
    border-left-color: var(--success);
}

.path.not-modified::after {
    border-left-color: var(--warning);
    border-right: 6px solid var(--warning);
    border-left: none;
    left: 0;
    right: auto;
}

/* Reverse arrow for 304 */

.headers-box {
    background: #000;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
}

.headers-box .section-title {
    color: var(--secondary);
    font-weight: 700;
    margin-bottom: 0.25rem;
    display: block;
}

.headers-box .req-headers {
    color: var(--accent);
    margin-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.75rem;
}

.headers-box .res-headers {
    color: var(--success);
}

/* Responsive */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .app-container {
        height: auto;
        display: block;
    }

    .timeline {
        overflow-y: visible;
    }
}