:root {
    --bg-from: oklch(0.78 0.10 215);
    --bg-to: oklch(0.93 0.04 205);
    --primary: oklch(0.55 0.18 225);
    --teal: oklch(0.65 0.15 170);
    --purple: oklch(0.60 0.16 285);
    --text: oklch(0.22 0.02 225);
    --muted: oklch(0.55 0.04 225);
    --card-bg: rgba(255, 255, 255, 0.92);
    --sidebar-bg: rgba(255, 255, 255, 0.65);
    --border: rgba(255, 255, 255, 0.70);
    --success: #3cb87a;
    --warning: #f0a23a;
    --danger: #e05e5e;
    --shadow: 0 20px 80px rgba(60, 100, 180, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.6);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, var(--bg-from), var(--bg-to));
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

.shell {
    min-height: calc(100vh - 32px);
    margin: 16px;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    overflow: hidden;
    border-radius: 20px;
    background: rgba(248, 250, 255, 0.70);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.sidebar {
    position: sticky;
    top: 16px;
    height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 18px 14px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    box-shadow: 0 12px 28px rgba(60, 110, 190, 0.28);
}

.brand strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
}

.brand span:last-child {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.nav-list {
    display: grid;
    gap: 4px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
}

.nav-item span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: transparent;
}

.nav-item:hover,
.nav-item.active {
    color: var(--text);
    background: color-mix(in oklch, var(--primary) 13%, transparent);
}

.nav-item.active span {
    background: var(--primary);
}

.side-meta {
    margin-top: auto;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--border);
}

.side-meta span,
.side-meta small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.side-meta strong {
    display: block;
    margin: 4px 0;
    font-size: 18px;
    font-weight: 800;
}

.workspace {
    min-width: 0;
    padding: 20px 24px 28px;
    overflow: auto;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
    animation: fadeUp 0.5s ease both;
}

.overline {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--text);
    font-weight: 800;
}

h1 {
    font-size: 28px;
    line-height: 1.05;
}

h2 {
    font-size: 18px;
}

.subcopy {
    max-width: 620px;
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.controls {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.controls label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.controls input,
.controls select {
    min-height: 38px;
    border: 1px solid rgba(90, 120, 170, 0.16);
    border-radius: 10px;
    padding: 0 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.84);
    outline: none;
}

.controls input:focus,
.controls select:focus {
    border-color: color-mix(in oklch, var(--primary) 45%, white);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 12%, transparent);
}

.toggle {
    min-height: 38px;
    display: flex !important;
    grid-template-columns: none;
    align-items: center;
    gap: 8px !important;
    padding: 0 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(90, 120, 170, 0.14);
}

.toggle input {
    min-height: auto;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

button {
    min-height: 38px;
    border: 0;
    border-radius: 10px;
    padding: 0 16px;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(70, 120, 190, 0.23);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(70, 120, 190, 0.28);
}

.logout-form {
    margin-top: 12px;
}

.logout-form button {
    width: 100%;
    min-height: 34px;
}

.notice {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #8a5a00;
    background: #f0a23a18;
    border: 1px solid rgba(240, 162, 58, 0.28);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-panel {
    width: min(100%, 380px);
    padding: 22px;
    border-radius: 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-brand {
    margin-bottom: 18px;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.auth-form input {
    min-height: 42px;
    border: 1px solid rgba(90, 120, 170, 0.16);
    border-radius: 10px;
    padding: 0 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.84);
    outline: none;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    position: relative;
    min-height: 112px;
    padding: 15px 16px;
    overflow: hidden;
    border-radius: 14px;
    background: var(--card-bg);
    border-left: 3px solid var(--primary);
    box-shadow: 0 12px 34px rgba(70, 100, 160, 0.10);
    animation: fadeUp 0.5s ease both;
}

.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }
.stat-card:nth-child(4) { animation-delay: 0.24s; }

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 7px;
    font-size: 30px;
    font-weight: 800;
}

.stat-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.stat-card svg {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 80px;
    height: 32px;
    opacity: 0.72;
}

.stat-card path {
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 200;
    animation: chartDraw 1.2s cubic-bezier(.2, .7, .2, 1) both;
}

.accent-green { border-left-color: var(--success); color: var(--success); }
.accent-blue { border-left-color: var(--primary); color: var(--primary); }
.accent-orange { border-left-color: var(--warning); color: var(--warning); }
.accent-purple { border-left-color: var(--purple); color: var(--purple); }

.summary-strip,
.universe,
.score-section {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid var(--border);
    box-shadow: 0 12px 34px rgba(70, 100, 160, 0.08);
}

.summary-strip {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 14px;
    animation: fadeUp 0.5s ease 0.18s both;
}

.summary-strip strong {
    display: block;
    font-size: 15px;
    line-height: 1.4;
}

.groups {
    display: grid;
    gap: 14px;
}

.score-section {
    overflow: hidden;
    animation: fadeUp 0.5s ease both;
}

.score-section:nth-child(2) { animation-delay: 0.08s; }
.score-section:nth-child(3) { animation-delay: 0.16s; }
.score-section:nth-child(4) { animation-delay: 0.24s; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 16px;
    border-bottom: 1px solid rgba(90, 120, 170, 0.10);
}

.count-badge {
    display: inline-grid;
    min-width: 36px;
    height: 28px;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    background: color-mix(in oklch, var(--primary) 13%, transparent);
}

.score-3 .count-badge {
    color: var(--success);
    background: #3cb87a18;
}

.score-2 .count-badge {
    color: var(--warning);
    background: #f0a23a18;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(90, 120, 170, 0.09);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.44);
}

td {
    color: color-mix(in oklch, var(--text) 92%, black);
}

tbody tr {
    transition: background 0.18s ease, transform 0.18s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.58);
}

.num {
    text-align: right;
}

.badge {
    display: inline-grid;
    min-width: 42px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
}

.badge.ok {
    color: var(--success);
    background: #3cb87a18;
}

.badge.off {
    color: color-mix(in oklch, var(--muted) 88%, black);
    background: rgba(90, 120, 170, 0.10);
}

.empty-row {
    height: 54px;
    color: var(--muted);
    text-align: center;
}

.universe {
    margin-top: 14px;
    animation: fadeUp 0.5s ease 0.2s both;
}

.sector-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    padding: 14px 16px 16px;
}

.sector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.75);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.sector-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(70, 100, 160, 0.10);
}

.sector-item span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.sector-item strong {
    font-size: 14px;
    font-weight: 800;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes chartDraw {
    from {
        stroke-dashoffset: 200;
    }
    to {
        stroke-dashoffset: 0;
    }
}

@media (max-width: 1040px) {
    .shell {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .brand div,
    .nav-item {
        font-size: 0;
    }

    .nav-item {
        justify-content: center;
    }

    .side-meta {
        display: none;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        display: grid;
    }

    .controls {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .shell {
        min-height: 100vh;
        margin: 0;
        grid-template-columns: 1fr;
        border-radius: 0;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .brand div,
    .nav-item {
        font-size: initial;
    }

    .nav-list {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
    }

    .workspace {
        padding: 18px 14px 24px;
    }

    .stat-grid,
    .summary-strip {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 24px;
    }
}
