/* VB Music Lab — единая семантическая тема (светлая по умолчанию). */

:root {
    color-scheme: light;
    --bg-primary:    #F5F7FB;
    --bg-secondary:  #F0F2F7;
    --bg-card:       #FFFFFF;
    --bg-card-hover: #FAFAFF;
    --bg-input:      #FFFFFF;
    --border:        #E4E7EC;
    --border-light:  #D0D5DD;
    --surface:       var(--bg-card);
    --surface-2:     var(--bg-secondary);
    --bg-tertiary:   #EAECF0;
    --chart-grid:    #EEF1F6;

    --text-primary:  #172033;
    --text-secondary:#5A6373;
    --text-muted:    #5D6675;

    --accent:        #6D3DF5;
    --accent-hover:  #5B2CD6;
    --accent-glow:   rgba(109, 61, 245, 0.14);

    --green:         #079455;
    --green-dim:     rgba(7, 148, 85, 0.10);
    --red:           #D92D20;
    --red-dim:       rgba(217, 45, 32, 0.10);
    --blue:          #3b82f6;
    --blue-dim:      rgba(59, 130, 246, 0.10);
    --orange:        #F79009;
    --orange-dim:    rgba(247, 144, 9, 0.11);
    --cyan:          #0891b2;
    --pink:          #ec4899;
    --success-text:  #05603A;
    --danger-text:   #912018;
    --warning-text:  #7A4A00;
    --focus-ring:    #6941C6;

    --nav-height:    72px;
    --radius:        12px;
    --radius-sm:     8px;
    --radius-xs:     6px;
    --shadow:        0 8px 28px rgba(16, 24, 40, 0.09);
    --shadow-sm:     0 2px 10px rgba(16, 24, 40, 0.07);
    --transition:    all 0.2s ease;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary:    #0f0f1a;
    --bg-secondary:  #1a1a2e;
    --bg-card:       #16213e;
    --bg-card-hover: #1c2a4a;
    --bg-input:      #0d1b2a;
    --border:        #2a2a4a;
    --border-light:  #3a3a67;
    --surface:       var(--bg-card);
    --surface-2:     var(--bg-secondary);
    --bg-tertiary:   #20203a;
    --chart-grid:    rgba(62, 62, 96, 0.45);
    --text-primary:  #e8e8f0;
    --text-secondary:#a7a7c3;
    --text-muted:    #9B9BC0;
    --accent:        #8B5CF6;
    --accent-hover:  #C4B5FD;
    --accent-glow:   rgba(139, 92, 246, 0.25);
    --green:         #34D399;
    --green-dim:     rgba(16, 185, 129, 0.15);
    --red:           #F87171;
    --red-dim:       rgba(239, 68, 68, 0.15);
    --orange:        #FBBF24;
    --orange-dim:    rgba(245, 158, 11, 0.15);
    --cyan:          #22D3EE;
    --success-text:  #6CE9A6;
    --danger-text:   #FDA29B;
    --warning-text:  #FEC84B;
    --focus-ring:    #C4B5FD;
    --shadow:        0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────── */
.navbar {
    background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.brand {
    color: var(--text-primary) !important;
    text-decoration: none;
    margin-right: 1.25rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand::before {
    display: none;
}

.brand:hover { color: var(--text-primary) !important; }

.brand-logo-frame {
    width: 114px;
    height: 48px;
    padding: 3px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #10111f;
    border: 1px solid rgba(139, 92, 246, 0.24);
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(16, 17, 31, 0.16);
}

.brand-logo-crop {
    position: relative;
    display: block;
    width: 104px;
    aspect-ratio: 1389 / 558;
    overflow: hidden;
}

.brand-logo-crop img {
    position: absolute;
    width: 110.58%;
    max-width: none;
    height: auto;
    left: -5.11%;
    top: -34.95%;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background: #10111f;
    border: 1px solid rgba(139, 92, 246, 0.24);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 17, 31, 0.16);
}

.brand-lockup-hero .brand-logo-crop { width: min(320px, 72vw); }
.brand-lockup-login .brand-logo-crop { width: 170px; }

.desktop-nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    min-width: 0;
}

.nav-top-link,
.nav-trigger,
.nav-help {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-xs);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    transition: color 0.16s ease, background-color 0.16s ease;
}

.nav-top-link:hover,
.nav-trigger:hover,
.nav-help:hover {
    color: var(--text-primary);
    background: var(--accent-glow);
}

.nav-top-link.active,
.nav-trigger.active,
.nav-help.active {
    color: var(--accent-hover);
    background: var(--accent-glow);
}

.nav-help {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
}

/* ── Dropdown menus ──────────────────────── */
.nav-dropdown {
    position: relative;
}

[x-cloak] { display: none !important; }

.nav-trigger {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.nav-trigger::-webkit-details-marker,
.mobile-nav-toggle::-webkit-details-marker,
.mobile-nav-group > summary::-webkit-details-marker {
    display: none;
}

.nav-trigger::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.16s ease;
}

.nav-dropdown[open] > .nav-trigger::after {
    transform: rotate(225deg) translate(-1px, -1px);
}

.nav-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 0;
    min-width: 250px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.55rem;
    z-index: 200;
    display: grid;
    gap: 0.5rem;
}

.nav-dropdown:not([open]) > .nav-menu {
    display: none;
}

.nav-menu::before {
    content: "";
    position: absolute;
    height: 0.7rem;
    top: -0.65rem;
    left: 0;
    right: 0;
}

.nav-menu-mega {
    width: min(590px, calc(100vw - 3rem));
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.nav-menu-wide {
    width: min(520px, calc(100vw - 3rem));
    grid-template-columns: repeat(2, minmax(210px, 1fr));
}

.nav-menu-right {
    left: auto;
    right: 0;
}

.nav-menu-section {
    min-width: 0;
    padding: 0.35rem;
}

.nav-menu-heading {
    display: block;
    padding: 0.2rem 0.65rem 0.35rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}

.nav-menu-link {
    display: block;
    padding: 0.5rem 0.65rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.35;
    border-radius: var(--radius-xs);
    transition: color 0.16s ease, background-color 0.16s ease;
}

.nav-menu-link:hover,
.nav-menu-link.active {
    color: var(--text-primary);
    background: var(--accent-glow);
}

.nav-menu-link.active {
    color: var(--accent-hover);
    font-weight: 600;
}

/* ── User section ────────────────────────── */
.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    border: 2px solid var(--accent);
    color: var(--accent-hover);
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-username {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
}

.mobile-nav {
    display: none;
}

/* ── Container ──────────────────────────── */
.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Typography ─────────────────────────── */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

a { color: var(--accent-hover); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Cards ──────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.card-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
}

.card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
    text-align: center;
}

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

.home-section-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.home-stat-grid .card { min-width: 0; padding: 1.25rem 0.75rem; }
.home-stat-grid .card-value { font-size: clamp(1.35rem, 2vw, 2.15rem); }
.home-stat-grid .home-stat-date { font-size: clamp(1rem, 1.6vw, 1.4rem); white-space: nowrap; }
.home-stat-grid .home-stat-period { font-size: clamp(0.9rem, 1.2vw, 1.1rem); overflow-wrap: anywhere; }

/* ── Panels (chart containers) ──────────── */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ── Tables ─────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
    font-size: 0.9rem;
}

tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-secondary) 35%, transparent); }
tr:hover td { background: var(--accent-glow); }
tr:last-child td { border-bottom: none; }
td a { color: var(--accent-hover); text-decoration: none; }
td a:hover { color: var(--accent-hover); text-decoration: underline; }

.text-green  { color: var(--green); }
.text-red    { color: var(--red); font-weight: 600; }
.text-orange { color: var(--orange); }
.text-muted  { color: var(--text-muted); }

/* ── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 16px var(--accent-glow);
    color: #fff;
}

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
    box-shadow: none;
}
.btn-outline.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-danger { background: var(--red); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 0 16px rgba(239, 68, 68, 0.3); }

.btn-ghost {
    background: color-mix(in srgb, var(--bg-secondary) 70%, transparent);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--accent-glow); color: var(--text-primary); box-shadow: none; }

.btn-group { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.theme-toggle {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--bg-card); color: var(--text-primary); cursor: pointer;
    transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); background: var(--accent-glow); }
.theme-icon::before { content: "☾"; font-size: 1rem; }
:root[data-theme="dark"] .theme-icon::before { content: "☀"; }

/* ── Alerts ──────────────────────────────── */
.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-success { background: var(--green-dim); color: var(--success-text); border-color: rgba(16, 185, 129, 0.3); }
.alert-error   { background: var(--red-dim); color: var(--danger-text); border-color: rgba(239, 68, 68, 0.3); }
.alert-error a { color: var(--danger-text); text-decoration: underline; }
.alert-warning { background: var(--orange-dim); color: var(--warning-text); border-color: rgba(245, 158, 11, 0.3); }

/* ── Forms / Inputs ─────────────────────── */
input[type="text"],
input[type="search"],
input[type="date"],
textarea,
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    transition: var(--transition);
    font-family: inherit;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="file"] {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

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

.table-responsive { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-scroll table { border: 0; border-radius: 0; min-width: 760px; }
.table-sticky thead th { position: sticky; top: 0; z-index: 4; }
.table-sticky th:first-child,
.table-sticky td:first-child { position: sticky; left: 0; z-index: 3; }
.table-sticky th:first-child { min-width: 92px; }
.table-sticky-song th:nth-child(2),
.table-sticky-song td:nth-child(2) { position: sticky; left: 92px; z-index: 3; }
.table-sticky thead th:first-child { z-index: 5; }
.table-sticky-song thead th:nth-child(2) { z-index: 5; }
.table-sticky td:first-child { background: var(--bg-card); }
.table-sticky-song td:nth-child(2) { background: var(--bg-card); min-width: 220px; }
.table-sticky tbody tr:nth-child(even) td:first-child { background: color-mix(in srgb, var(--bg-secondary) 35%, var(--bg-card)); }
.table-sticky-song tbody tr:nth-child(even) td:nth-child(2) { background: color-mix(in srgb, var(--bg-secondary) 35%, var(--bg-card)); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.status-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    border: 1px solid var(--border); border-radius: 999px;
    padding: 0.2rem 0.55rem; font-size: 0.75rem; line-height: 1.25;
    color: var(--text-secondary); background: var(--bg-secondary); white-space: nowrap;
}
.status-badge.status-stable,
.status-badge.status-confirmed_growth { color: var(--green); background: var(--green-dim); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.status-badge.status-one_wave_anomaly,
.status-badge.status-confirmed_decline { color: var(--red); background: var(--red-dim); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.status-badge.status-fluctuations,
.status-badge.status-insufficient { color: var(--orange); background: var(--orange-dim); border-color: color-mix(in srgb, var(--orange) 30%, transparent); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem 0.95rem; }
.kpi-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-label { margin-top: 0.25rem; color: var(--text-muted); font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.04em; }
.section-stack { display: grid; gap: 1rem; }
.details-card { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); }
.details-card summary { cursor: pointer; padding: 0.8rem 1rem; font-weight: 600; color: var(--text-primary); }
.details-card > div { padding: 0 1rem 1rem; }
.diff-leaders-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.decision-editor { display: grid; grid-template-columns: minmax(180px, 240px) 1fr auto; gap: 0.6rem; align-items: start; }

/* ── Sort Pills ─────────────────────────── */
.sort-pills { display: flex; gap: 0.3rem; margin-bottom: 1rem; flex-wrap: wrap; }

.sort-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.sort-pill:hover { border-color: var(--accent); color: var(--accent); }
.sort-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Stat Badges ────────────────────────── */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.stat-badge.green  { background: var(--green-dim); color: var(--green); }
.stat-badge.red    { background: var(--red-dim); color: var(--red); }
.stat-badge.blue   { background: var(--blue-dim); color: var(--blue); }
.stat-badge.orange { background: var(--orange-dim); color: var(--orange); }

/* ── Grid Layouts ───────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }

/* ── Compare Page ───────────────────────── */
.search-box { position: relative; }

.search-input {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 280px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow);
}

.autocomplete-list .ac-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.autocomplete-list .ac-item:hover {
    background: var(--accent-glow);
    color: var(--accent-hover);
}

.selected-songs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }

.song-tag {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.82rem;
    color: #fff; font-weight: 500;
}

.song-tag .remove {
    cursor: pointer; font-weight: bold; margin-left: 0.25rem;
    opacity: 0.7; transition: var(--transition);
}

.song-tag .remove:hover { opacity: 1; }

/* ── Page Meta ──────────────────────────── */
.page-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* ── Sortable table headers ─────────────── */
th.sortable:hover { color: var(--accent-hover); }
th.sort-active { color: var(--accent-hover); }
.sort-arrow { font-size: 0.75rem; }

/* ── Modal ──────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 960px;
    padding: 2rem;
    position: relative;
    margin-top: 1rem;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
    padding: 0.25rem;
}

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

/* ── Value Tooltips ─────────────────────── */
.val-tip {
    position: relative;
    cursor: default;
}
.val-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.val-tip:hover::after {
    opacity: 1;
}

/* ── Tier colors (positiv ranking) ──────── */
tr.tier-green { background: rgba(0, 176, 80, 0.10); }
tr.tier-green td:nth-child(4) { color: var(--green); font-weight: 600; }
tr.tier-yellow { background: rgba(255, 200, 0, 0.08); }
tr.tier-yellow td:nth-child(4) { color: var(--orange); font-weight: 600; }
tr.tier-red { background: rgba(255, 60, 60, 0.08); }
tr.tier-red td:nth-child(4) { color: var(--red); font-weight: 600; }

/* ── Events Feed ────────────────────────── */
.events-feed { display: flex; flex-direction: column; gap: 0.5rem; }

.event-card {
    display: flex; align-items: flex-start; gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 0.88rem;
    transition: var(--transition);
}
.event-card:hover { border-color: var(--border-light); }

.event-icon { font-size: 1.1rem; flex-shrink: 0; line-height: 1.5; }
.event-text { color: var(--text-primary); line-height: 1.5; }

.event-card.event-record { border-left: 3px solid var(--accent); }
.event-card.event-record .event-text { color: var(--accent-hover); }
.event-card.event-burnout { border-left: 3px solid var(--red); }
.event-card.event-burnout .event-text { color: var(--red); }
.event-card.event-new { border-left: 3px solid var(--green); }
.event-card.event-recovery { border-left: 3px solid var(--cyan); }
.event-card.event-info { border-left: 3px solid var(--blue); }
.event-card.event-candidate { border-left: 3px solid var(--accent); }
.event-card.event-candidate .event-text { color: var(--accent-hover); }
.event-card.event-market { border-left: 3px solid var(--blue); }
.event-card.event-rise { border-left: 3px solid var(--green); }
.event-card.event-rise .event-text { color: var(--green); }
.event-card.event-fall { border-left: 3px solid var(--red); }
.event-card.event-fall .event-text { color: var(--red); }

/* ── Records Bar ───────────────────────── */
.records-bar {
    display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.records-bar .rec-item { display: flex; align-items: center; gap: 0.35rem; }
.records-bar .rec-icon { font-size: 1rem; }
.records-bar .rec-val { color: var(--text-primary); font-weight: 600; }

/* ── Rotation Page ─────────────────────── */
.rotation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

.rotation-col .rotation-header {
    font-size: 0.85rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; padding: 0.6rem 1rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-bottom: 0;
}
.rotation-col .rotation-list { display: flex; flex-direction: column; gap: 0; }

.rotation-item {
    padding: 0.65rem 1rem;
    border: 1px solid var(--border); border-top: none;
    background: var(--bg-card);
    font-size: 0.85rem;
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.5rem;
}
.rotation-item:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.rotation-col.col-new .rotation-header { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.rotation-col.col-new .rotation-item { border-color: rgba(16,185,129,0.15); }

.rotation-col.col-veteran .rotation-header { background: rgba(124,58,237,0.15); color: var(--accent-hover); border: 1px solid rgba(124,58,237,0.3); }
.rotation-col.col-veteran .rotation-item { border-color: rgba(124,58,237,0.15); }

.rotation-col.col-dropped .rotation-header { background: rgba(90,90,122,0.15); color: var(--text-secondary); border: 1px solid rgba(90,90,122,0.3); }
.rotation-col.col-dropped .rotation-item { border-color: rgba(90,90,122,0.15); }

.rotation-meta { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.rotation-name a { color: var(--text-primary); }
.rotation-name a:hover { color: var(--accent-hover); }

/* ── Heatmap ───────────────────────────── */
.heatmap-table { border-collapse: collapse; width: 100%; }
.heatmap-table th { font-size: 0.72rem; padding: 0.4rem 0.5rem; text-align: center; white-space: nowrap; }
.heatmap-table td {
    text-align: center; font-size: 0.78rem; font-weight: 600;
    padding: 0.45rem 0.5rem; border: 1px solid rgba(42,42,74,0.4);
    position: relative; cursor: default;
}
.heatmap-table td:first-child {
    text-align: left; font-weight: 500; background: var(--bg-secondary) !important;
    color: var(--text-secondary); white-space: nowrap; font-size: 0.75rem;
}

/* ── Sparkline ─────────────────────────── */
.sparkline { vertical-align: middle; }

/* ── Global Toast Notifications ─────────── */
.toast-container {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 0.5rem; pointer-events: none;
}
.toast-item {
    padding: 0.75rem 1.25rem; border-radius: var(--radius-sm);
    color: #fff; font-size: 0.9rem; font-weight: 500;
    opacity: 0; transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto; box-shadow: var(--shadow);
}
.toast-item.show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--accent); }

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Music Section ─────────────────────── */

/* Badges */
.badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:0.75rem; font-weight:500; }
.badge-green { background:rgba(16,185,129,0.15); color:var(--green); }
.badge-yellow { background:rgba(245,158,11,0.15); color:var(--orange); }
.badge-red { background:rgba(239,68,68,0.15); color:var(--red); }
.badge-blue { background:rgba(59,130,246,0.15); color:#3b82f6; }
.badge-purple { background:rgba(124,58,237,0.15); color:var(--accent); }
.badge-grey { background:rgba(136,136,170,0.15); color:var(--text-muted); }

/* Tag pills */
.tag-pill { display:inline-block; padding:2px 8px; border-radius:10px; font-size:0.7rem; font-weight:500; margin:1px 2px; white-space:nowrap; }

.tag-pill-btn {
    display:inline-block; padding:4px 12px; border-radius:14px; font-size:0.8rem;
    border:1px solid var(--border); background:transparent; color:var(--text-muted);
    cursor:pointer; transition:all 0.2s; margin:2px;
}
.tag-pill-btn:hover { border-color:var(--tag-color, var(--accent)); color:var(--tag-color, var(--accent)); }
.tag-pill-btn.active {
    background:color-mix(in srgb, var(--tag-color, var(--accent)) 20%, transparent);
    border-color:var(--tag-color, var(--accent));
    color:var(--tag-color, var(--accent));
    font-weight:500;
}

/* Hook button */
.hook-btn { display:inline-flex; align-items:center; justify-content:center; width:28px; height:28px; border-radius:50%; border:none; font-size:0.8rem; cursor:pointer; }
.hook-play { background:rgba(124,58,237,0.2); color:var(--accent); transition:background 0.2s; }
.hook-play:hover { background:rgba(124,58,237,0.4); }
.hook-none { background:transparent; color:var(--text-muted); cursor:default; font-size:1rem; }

/* Button icons */
.btn-icon { background:none; border:none; cursor:pointer; font-size:1rem; padding:4px; color:var(--text-muted); transition:color 0.2s; }
.btn-icon:hover { color:var(--text-primary); }
.btn-icon-danger:hover { color:var(--red); }

/* Modal */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:1000;
    display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal-content {
    background:var(--bg-secondary); border:1px solid var(--border); border-radius:12px;
    padding:24px; width:100%; box-shadow:0 8px 40px rgba(0,0,0,0.5);
}
.modal-tab {
    padding:8px 16px; border:none; background:transparent; color:var(--text-muted);
    cursor:pointer; font-size:0.85rem; border-bottom:2px solid transparent; transition:all 0.2s;
}
.modal-tab:hover { color:var(--text-secondary); }
.modal-tab.active { color:var(--accent); border-bottom-color:var(--accent); }

/* Hook progress bar in table rows */
.hook-progress-bar { width:0%; }

/* ── Responsive ─────────────────────────── */
/* Help icon in section headers */
.help-icon {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    vertical-align: middle;
    margin-left: 6px;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.help-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Never hide keyboard focus, even where inputs use a custom focus border. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

@media (max-width: 1180px) {
    .desktop-nav { display: none; }
    .nav-user { margin-left: auto; }
    .nav-username,
    .nav-logout { display: none; }

    .mobile-nav {
        display: block;
        position: relative;
        margin-left: 0.65rem;
    }

    .mobile-nav-toggle {
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        list-style: none;
        cursor: pointer;
        color: var(--text-primary);
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }

    .mobile-nav-icon,
    .mobile-nav-icon::before,
    .mobile-nav-icon::after {
        width: 17px;
        height: 2px;
        display: block;
        position: relative;
        background: currentColor;
        border-radius: 2px;
        transition: transform 0.16s ease, opacity 0.16s ease;
    }

    .mobile-nav-icon::before,
    .mobile-nav-icon::after {
        content: "";
        position: absolute;
        left: 0;
    }

    .mobile-nav-icon::before { top: -5px; }
    .mobile-nav-icon::after { top: 5px; }
    .mobile-nav[open] .mobile-nav-icon { background: transparent; }
    .mobile-nav[open] .mobile-nav-icon::before { top: 0; transform: rotate(45deg); }
    .mobile-nav[open] .mobile-nav-icon::after { top: 0; transform: rotate(-45deg); }

    .mobile-nav-panel {
        width: min(440px, calc(100vw - 2rem));
        max-height: calc(100vh - var(--nav-height) - 1rem);
        overflow-y: auto;
        position: absolute;
        top: calc(100% + 0.65rem);
        right: 0;
        padding: 0.65rem;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }

    .mobile-nav:not([open]) > .mobile-nav-panel,
    .mobile-nav-group:not([open]) > .mobile-nav-content {
        display: none;
    }

    .mobile-nav-home,
    .mobile-nav-group > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.7rem 0.75rem;
        color: var(--text-primary);
        font-size: 0.9rem;
        font-weight: 600;
        line-height: 1.4;
        border-radius: var(--radius-xs);
        list-style: none;
        cursor: pointer;
    }

    .mobile-nav-home:hover,
    .mobile-nav-home.active,
    .mobile-nav-group > summary:hover {
        color: var(--accent-hover);
        background: var(--accent-glow);
    }

    .mobile-nav-group > summary::after {
        content: "+";
        color: var(--text-muted);
        font-size: 1rem;
        font-weight: 400;
    }

    .mobile-nav-group[open] > summary::after { content: "−"; }

    .mobile-nav-content {
        display: grid;
        gap: 0.35rem;
        padding: 0.15rem 0.25rem 0.65rem 0.6rem;
        border-bottom: 1px solid var(--border);
    }

    .mobile-nav-content .nav-menu-section { padding: 0.25rem; }
    .mobile-nav-content .nav-menu-heading { padding-top: 0.45rem; }
    .mobile-nav-content .nav-menu-link { font-size: 0.86rem; }

    .mobile-nav-footer {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.85rem 0.75rem 0.25rem;
        color: var(--text-muted);
        font-size: 0.8rem;
    }

    .mobile-nav-footer span { margin-right: auto; color: var(--text-secondary); font-weight: 600; }
    .mobile-nav-footer a { color: var(--text-secondary); }
    .home-section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    :root { --nav-height: 64px; }
    .navbar { padding: 0 1rem; }
    .brand { margin-right: 0.75rem; }
    .brand-logo-frame { width: 103px; height: 44px; padding: 3px 4px; }
    .brand-logo-crop { width: 93px; }
    .brand-lockup-hero .brand-logo-crop { width: min(270px, 76vw); }
    .brand-lockup-login .brand-logo-crop { width: 150px; }
    .nav-user { gap: 0.45rem; }
    .nav-avatar { width: 30px; height: 30px; }
    .theme-toggle { width: 32px; height: 32px; }
    .mobile-nav { margin-left: 0.45rem; }
    .container { padding: 1rem; }
    .grid-2, .grid-3, .rotation-grid, .diff-leaders-grid, .decision-editor { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-section-grid { grid-template-columns: 1fr; }
    .home-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    h1 { font-size: 1.4rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 0.5rem 0.6rem; }
}

@media (max-width: 390px) {
    .brand-logo-frame { width: 94px; height: 42px; }
    .brand-logo-crop { width: 84px; }
    .nav-avatar { display: none; }
}

/* Unsaved dialog: shared by sheet, catalogue, and matching windows. */
.vbml-unsaved-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(9, 13, 28, 0.72);
    backdrop-filter: blur(5px);
}
.vbml-unsaved-card {
    width: min(100%, 440px);
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
.vbml-unsaved-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 1.1rem;
}
.vbml-unsaved-card h2 { margin: 1rem 0 0.5rem; font-size: 1.15rem; }
.vbml-unsaved-card p { margin: 0; color: var(--text-secondary); line-height: 1.5; }
.vbml-unsaved-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
.vbml-unsaved-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 480px) {
    .vbml-unsaved-actions { flex-direction: column-reverse; }
    .vbml-unsaved-actions .btn { width: 100%; }
}
