:root {
    --mts-red: #ef3124;
    --dark: #0d0f14;
    --dark-2: #151823;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f6f8fb;
    --muted: #c3c7d1;
    --card: rgba(21, 24, 35, 0.8);
    --accent: #f89d28;
    --green: #3dd598;
    --shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
    --header-height: 96px;
    --dynamic-header-height: 96px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(239, 49, 36, 0.08), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(248, 157, 40, 0.08), transparent 25%),
                #0b0d13;
    color: var(--text);
    line-height: 1.6;
    padding-top: var(--dynamic-header-height, var(--header-height));
    max-width: 100%;
    overflow-x: hidden;
}

html { overflow-x: hidden; }

.login-page {
    padding-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--card);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    width: min(420px, 92vw);
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 700;
}

.login-card input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    color: #fff;
}

a { color: inherit; text-decoration: none; }

.bg-pattern {
    position: fixed;
    inset: 0;
    background: url('https://www.transparenttextures.com/patterns/asfalt-dark.png');
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}

.hero {
    position: relative;
    padding: calc(var(--dynamic-header-height, var(--header-height)) + 44px) 48px 48px;
    background: linear-gradient(135deg, rgba(239, 49, 36, 0.9), rgba(14, 17, 25, 0.95));
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: visible;
    z-index: 4000;
}

.hero__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 14px 32px;
    margin: 0;
    background: linear-gradient(135deg, rgba(12,14,20,0.95), rgba(239,49,36,0.9));
    border-bottom: 1px solid var(--border);
    z-index: 5000;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    pointer-events: auto;
    gap: 12px;
}

.logo {
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 22px;
}

.logo span { color: var(--accent); }

.nav {
    display: flex;
    flex: 1;
    gap: 18px;
    font-weight: 600;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}

.nav a { padding: 8px 10px; border-radius: 10px; }
.nav a:hover { background: rgba(255,255,255,0.08); }

.team-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-weight: 700;
}

.team-switch select {
    background: transparent;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 8px;
    font-weight: 700;
}

.menu-toggle {
    display: none;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border);
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.back-top {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(239,49,36,0.85);
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: none;
    z-index: 50;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.back-top:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,0.35); }

.hero__content {
    margin-top: 32px;
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 32px;
    align-items: center;
}

.hero__content--solo {
    grid-template-columns: 1fr;
}

h1 {
    margin: 0 0 12px;
    font-size: 42px;
    line-height: 1.2;
}

.lead { color: var(--muted); max-width: 640px; }

.hero__actions { display: flex; gap: 12px; margin-top: 18px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary { background: var(--mts-red); color: #fff; box-shadow: 0 10px 30px rgba(239, 49, 36, 0.35); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-ghost { border-color: rgba(255,255,255,0.2); color: #fff; }
.btn--small { padding: 8px 12px; font-size: 13px; }

.hero__stats {
    margin-top: 22px;
    display: flex;
    gap: 18px;
}

.stat {
    background: rgba(255,255,255,0.08);
    padding: 12px 16px;
    border-radius: 12px;
    min-width: 150px;
}

.stat span {
    display: block;
    font-weight: 800;
    font-size: 22px;
}

.stat small { color: var(--muted); }

.hero__card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.hero__badge {
    display: inline-flex;
    padding: 6px 12px;
    background: rgba(239,49,36,0.14);
    border: 1px solid rgba(239,49,36,0.5);
    border-radius: 12px;
    font-weight: 700;
    margin-bottom: 10px;
}

.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }

main, .page-content { padding: 32px 48px 64px; position: relative; z-index: 1; }

.section { margin-bottom: 48px; scroll-margin-top: calc(var(--dynamic-header-height, var(--header-height)) + 32px); }

.section__header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }

h2 { margin: 6px 0 0; }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    color: var(--muted);
    margin: 0;
}

.pill {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    font-weight: 700;
    color: var(--muted);
}

.pill--score {
    background: rgba(61, 213, 152, 0.1);
    color: var(--text);
    border-color: rgba(61,213,152,0.4);
    font-size: 36px;
    padding: 14px 22px;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
    background: var(--card);
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: 18px;
    box-shadow: var(--shadow);
    min-height: 160px;
}

.card ul {
    margin: 10px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.card li + li { margin-top: 6px; }

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
}

.data-table tr:hover td {
    background: rgba(255,255,255,0.04);
}

.chart-small {
    max-width: 720px;
    margin: 0 auto;
}

.card.active { border-color: rgba(248,157,40,0.6); box-shadow: 0 14px 40px rgba(0,0,0,0.35); }

.card--tall { min-height: 420px; }

.card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.subtle { color: var(--muted); margin-top: 4px; }

.tag {
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    font-weight: 700;
    font-size: 12px;
    color: #fff;
}

.tag--accent { background: rgba(248, 157, 40, 0.14); border-color: rgba(248,157,40,0.5); }
.tag--dark { background: rgba(255,255,255,0.08); }

.project-list { display: flex; flex-direction: column; gap: 12px; }

.project-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.project-card .title { font-weight: 700; }
.project-card .meta { color: var(--muted); font-size: 13px; }

.status {
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
}

.status.active { background: rgba(61, 213, 152, 0.16); color: #caffe4; border: 1px solid rgba(61,213,152,0.4); }
.status.risk { background: rgba(239,49,36,0.16); color: #ffc6c2; border: 1px solid rgba(239,49,36,0.4); }
.status.ok { background: rgba(61,213,152,0.16); color: #caffe4; border: 1px solid rgba(61,213,152,0.4); }
.status.warning { background: rgba(248,157,40,0.16); color: #ffd9a8; border: 1px solid rgba(248,157,40,0.4); }
.status.info { background: rgba(255,255,255,0.12); color: #f6f8fb; border: 1px solid var(--border); }

.notifications { display: flex; flex-direction: column; gap: 10px; }

.notice {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.notice h4 { margin: 0 0 6px; }

.notice small { color: var(--muted); }

.notice.warning { border-color: rgba(248,157,40,0.5); }
.notice.critical { border-color: rgba(239,49,36,0.5); }
.notice.info { border-color: rgba(61,213,152,0.4); }

.list { display: flex; flex-direction: column; gap: 10px; }
.list.small .list-item { padding: 10px; cursor: default; }

.list-item {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    cursor: pointer;
}

.list-item.active { border-color: rgba(248,157,40,0.6); box-shadow: 0 12px 30px rgba(0,0,0,0.25); }

.meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; color: var(--muted); }
.meta span { padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,0.05); }

.builder {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.builder__pool, .builder__party {
    min-height: 90px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(255,255,255,0.02);
}

.badge {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 12px;
}

.role-chip { border-color: rgba(248,157,40,0.5); color: #fff; }
.badge + .badge { margin-left: 4px; }

#builder .card canvas {
    height: 480px;
    max-height: 520px;
}

.builder__party .badge {
    font-size: 24px;
    padding: 14px 18px;
}

.integr-card {
    padding: 14px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    margin: 10px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--mts-red), var(--accent));
    border-radius: 999px;
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 48px 36px;
    border-top: 1px solid var(--border);
    background: #0a0c12;
}

.footer__links { display: flex; gap: 12px; color: var(--muted); }
.footer__links a { color: var(--muted); }

select {
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
}

@media (max-width: 1280px) {
    :root { --header-height: 112px; }
    .hero { padding: calc(var(--dynamic-header-height, var(--header-height)) + 28px) 24px 40px; }
    .hero__content { grid-template-columns: 1fr; gap: 24px; }
    .hero__stats { flex-wrap: wrap; }
    .hero__actions { flex-wrap: wrap; }
    .section__header { flex-direction: column; align-items: flex-start; }
    .hero__top { align-items: flex-start; flex-wrap: wrap; }
    .header-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header-actions .team-switch { flex: 1 1 220px; }
    .header-actions #logoutButton { flex: 0 0 auto; }
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(12,14,20,0.95);
        border-bottom: 1px solid var(--border);
        padding: 10px 18px;
        flex-direction: column;
        gap: 8px;
        overflow-x: visible;
        white-space: normal;
    }
    .nav.open { display: flex; }
    .menu-toggle { display: inline-flex; }
}

@media (max-width: 960px) {
    .hero { padding: calc(var(--dynamic-header-height, var(--header-height)) + 16px) 18px 32px; }
    main, .page-content { padding: 24px 18px 56px; }
    .card { padding: 16px; }
    .pill--score { font-size: 30px; }
}

@media (max-width: 720px) {
    :root { --header-height: 128px; }
    .hero__top {
        padding: 10px 14px;
        gap: 10px;
    }
    .team-switch {
        width: 100%;
        justify-content: space-between;
    }
    #logoutButton { width: 100%; text-align: center; }
    .hero { padding-top: calc(var(--dynamic-header-height, var(--header-height)) + 8px); }
    h1 { font-size: 32px; }
    .lead { font-size: 15px; }
    .footer { flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; }
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }
    .header-actions .team-switch { flex: 1 1 200px; }
    .menu-toggle { order: 3; }
}

@media (max-width: 560px) {
    .hero { padding: 110px 14px 28px; }
    main, .page-content { padding: 20px 14px 48px; }
    .hero__stats { flex-direction: column; width: 100%; }
    .hero__actions { width: 100%; }
    .btn { width: 100%; justify-content: center; }
    .table-wrapper { margin: 0; }
}
