/* ═══════════════════════════════════════════════════════════════════════
   Speed Slalom Lab · Design System
   Theme: white bg · vivid magenta-pink accent · minimalist/modern
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --pink: #D42FC2;
    --pink-light: #F5C8F0;
    --pink-pale: #FDF0FC;
    --pink-dark: #A020A0;
    --text: #111118;
    --text-2: #6B6B80;
    --text-3: #9999AA;
    --bg: #FFFFFF;
    --bg-2: #F9F7FB;
    --bg-3: #F2EEF8;
    --border: #EDE8F5;
    --border-strong: #D8D0EC;
    --radius: 10px;
    --radius-lg: 16px;
    --sidebar-w: 224px;
    --shadow-sm: 0 1px 4px rgba(180, 60, 200, .06), 0 0 0 1px rgba(180, 60, 200, .05);
    --shadow-md: 0 4px 20px rgba(100, 0, 140, .09), 0 0 0 1px rgba(180, 60, 200, .07);
    --transition: 180ms cubic-bezier(.25, .46, .45, .94);
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ──────────────────────────── SIDEBAR ────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
}

.logo-mark {
    font-size: 22px;
    color: var(--pink);
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(212, 47, 194, .4));
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--text);
}

.logo-domain {
    color: var(--pink);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
}

.nav-group-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 10px;
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-3);
    color: var(--text);
}

.nav-item.active {
    background: var(--pink-pale);
    color: var(--pink);
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.version-badge {
    font-size: 10px;
    color: var(--text-3);
    letter-spacing: .04em;
}

/* ──────────────────────────── MAIN ───────────────────────────────── */

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.section {
    display: none;
    flex-direction: column;
    flex: 1;
    padding: 32px 36px;
    gap: 24px;
}

.section.active {
    display: flex;
}

/* ──────────────────────────── PAGE HEADER ────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.4px;
    color: var(--text);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 3px;
}

/* ──────────────────────────── FILTERS BAR ────────────────────────── */

.filters-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

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

.filter-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
}

.model-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chip {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--pink-light);
    color: var(--pink);
}

.chip.active {
    background: var(--pink);
    border-color: var(--pink);
    color: #fff;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-input {
    padding: 5px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.date-input:focus {
    border-color: var(--pink);
}

.date-sep {
    color: var(--text-3);
    font-size: 12px;
}

/* ──────────────────────────── CONTENT GRID ───────────────────────── */

.content-grid {
    display: grid;
    grid-template-columns: minmax(320px, 38%) 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* ──────────────────────────── PANEL ──────────────────────────────── */

.panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    min-height: 480px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.panel-hint {
    font-size: 11px;
    color: var(--text-3);
}

/* ──────────────────────────── MEASUREMENTS LIST ──────────────────── */

.measurements-list {
    flex: 1;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    min-height: 200px;
    color: var(--text-3);
    text-align: center;
    padding: 32px;
}

.empty-icon {
    font-size: 32px;
    opacity: .4;
}

.empty-state p {
    font-size: 12px;
    line-height: 1.6;
}

.measurement-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.measurement-row:last-child {
    border-bottom: none;
}

.measurement-row:hover {
    background: var(--bg-2);
}

.measurement-row.selected {
    background: var(--pink-pale);
}

.row-checkbox {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    background: var(--bg);
}

.measurement-row.selected .row-checkbox {
    background: var(--pink);
    border-color: var(--pink);
    color: #fff;
}

.row-checkbox::after {
    content: '';
    display: none;
    width: 8px;
    height: 5px;
    border-left: 1.5px solid #fff;
    border-bottom: 1.5px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.measurement-row.selected .row-checkbox::after {
    display: block;
}

.row-content {
    flex: 1;
    min-width: 0;
}

.row-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-meta {
    display: flex;
    gap: 10px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.row-tag {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-3);
    color: var(--text-2);
}

.row-tag.model {
    background: var(--pink-pale);
    color: var(--pink-dark);
}

.row-date {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
}

.row-color-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
    display: none;
}

.measurement-row.selected .row-color-dot {
    display: block;
}

.row-delete {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    font-size: 16px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: all var(--transition);
    line-height: 1;
}

.measurement-row:hover .row-delete {
    opacity: 1;
}

.row-delete:hover {
    color: #d00;
    background: #fff0f0;
}

/* ──────────────────────────── CHART PANEL ────────────────────────── */

.chart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-sm {
    padding: 4px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    padding: 16px;
    min-height: 0;
}

canvas#overlay-chart {
    width: 100% !important;
    height: 100% !important;
    min-height: 300px;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}

.chart-legend {
    padding: 10px 18px 14px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    min-height: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-2);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ──────────────────────────── BUTTONS ────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
    white-space: nowrap;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn-primary {
    background: var(--pink);
    color: #fff;
    box-shadow: 0 2px 8px rgba(212, 47, 194, .28);
}

.btn-primary:hover {
    background: var(--pink-dark);
    box-shadow: 0 4px 14px rgba(212, 47, 194, .36);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-strong);
}

.btn-ghost:hover {
    background: var(--bg-2);
    color: var(--text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ──────────────────────────── MODAL ──────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 0, 30, .4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-3);
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-3);
    color: var(--text);
}

.modal-body {
    padding: 20px 24px;
}

.form-row {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
}

.hint {
    font-weight: 400;
    color: var(--text-3);
    font-size: 11px;
}

.form-input {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

.form-input:focus {
    border-color: var(--pink);
}

.form-textarea {
    resize: vertical;
    min-height: 72px;
}

.mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

/* ──────────────────────────── SCROLLBAR ──────────────────────────── */

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

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

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

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

/* ──────────────────────────── RESPONSIVE ─────────────────────────── */

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