:root {
    --bg: #0b0e13;
    --panel: #121722;
    --panel-2: #171d29;
    --line: #293142;
    --text: #f5f7fb;
    --muted: #aab3c2;
    --muted-2: #7f899b;
    --accent: #e44343;
    --accent-hover: #f05252;
    --success: #57d38c;
    --warning: #f3bf59;
    --danger: #ff6b6b;
    --radius: 16px;
    --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html {
    font-size: 17px;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 80% 0%, rgba(228,67,67,.10), transparent 28rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a { color: inherit; }

button, input, select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0,1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 20px;
    background: rgba(13,17,24,.97);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--accent), #8e2020);
    font-weight: 900;
    letter-spacing: -.03em;
    box-shadow: 0 10px 28px rgba(228,67,67,.28);
}

.brand strong {
    display: block;
    font-size: 1.04rem;
    line-height: 1.2;
}

.brand small {
    color: var(--muted);
    font-size: .85rem;
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 42px;
}

.nav a {
    padding: 13px 15px;
    border-radius: 11px;
    color: var(--muted);
    text-decoration: none;
    font-size: .98rem;
    font-weight: 700;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
    background: var(--panel-2);
}

.nav a.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 7px 9px;
    align-items: center;
    color: var(--muted-2);
    font-size: .82rem;
}

.sidebar-footer a {
    grid-column: 2;
    color: var(--muted);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(87,211,140,.12);
}

.main {
    min-width: 0;
    padding: 0 34px 48px;
}

.topbar {
    min-height: 112px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid rgba(41,49,66,.65);
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: clamp(1.65rem, 3vw, 2.25rem);
    line-height: 1.15;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.menu-button {
    display: none;
    border: 0;
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 12px;
}

.hero {
    margin: 34px 0 24px;
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(125deg, rgba(228,67,67,.13), transparent 45%),
        var(--panel);
    display: flex;
    justify-content: space-between;
    gap: 25px;
    align-items: center;
    box-shadow: var(--shadow);
}

.hero.compact { padding: 26px 30px; }

.hero h2 {
    margin: 5px 0 8px;
    font-size: clamp(1.45rem, 2.7vw, 2rem);
    line-height: 1.22;
}

.hero p:not(.eyebrow) {
    max-width: 780px;
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 46px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
}

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

.button-primary:hover { background: var(--accent-hover); }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.metric-card strong {
    display: block;
    margin: 5px 0 2px;
    font-size: clamp(1.7rem, 3vw, 2.3rem);
    line-height: 1.15;
}

.metric-card small,
.metric-label {
    color: var(--muted);
}

.metric-label {
    font-size: .88rem;
    font-weight: 800;
}

.metric-card small {
    display: block;
    font-size: .82rem;
}

.metric-time { font-size: 1.45rem !important; }

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr);
    gap: 20px;
}

.panel {
    padding: 25px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 14px 36px rgba(0,0,0,.18);
}

.panel-header,
.module-title-row,
.module-heading,
.activity-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.panel-header {
    margin-bottom: 20px;
}

.panel h2 {
    margin: 3px 0 0;
    font-size: 1.35rem;
}

.text-link {
    color: #ff8b8b;
    font-weight: 800;
}

.summary-list {
    display: grid;
    gap: 2px;
}

.summary-list > div {
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.summary-list > div:last-child { border-bottom: 0; }
.summary-list span { color: var(--muted); }

.activity-list {
    display: grid;
}

.activity-item {
    display: grid;
    grid-template-columns: 12px minmax(0,1fr);
    gap: 14px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}

.activity-item:last-child { border-bottom: 0; }

.activity-icon {
    width: 10px;
    height: 10px;
    margin-top: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(228,67,67,.11);
}

.activity-item p {
    margin: 3px 0;
    color: var(--muted);
}

.activity-item small { color: var(--muted-2); }

.module-toolbar {
    display: grid;
    grid-template-columns: minmax(260px,1fr) 220px 220px;
    gap: 12px;
    margin-bottom: 20px;
}

input,
select {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(228,67,67,.13);
}

.module-list {
    display: grid;
    gap: 14px;
}

.module-card {
    padding: 21px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-2);
}

.module-card[hidden] { display: none; }

.module-heading {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.module-heading h3 {
    margin: 0;
    font-size: 1.18rem;
}

.module-card code {
    display: block;
    margin-top: 4px;
    color: #c8cfda;
    font-size: .82rem;
    overflow-wrap: anywhere;
}

.module-description {
    margin: 14px 0;
    color: var(--muted);
    font-size: .96rem;
}

.module-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 22px;
    color: var(--muted);
    font-size: .86rem;
}

.module-meta strong { color: var(--text); }

.module-status-row {
    margin-top: 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 13px;
}

.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 900;
}

.badge {
    color: #d9dfeb;
    background: #252d3b;
}

.status-pill.success { color: #aaf1c9; background: rgba(87,211,140,.13); }
.status-pill.warning { color: #ffe0a0; background: rgba(243,191,89,.14); }
.status-pill.danger { color: #ffb3b3; background: rgba(255,107,107,.14); }
.status-pill.neutral { color: #c6cfdd; background: rgba(170,179,194,.10); }

.subtle-text {
    color: var(--muted-2);
    font-size: .82rem;
}

.module-error {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(255,107,107,.25);
    border-radius: 10px;
    background: rgba(255,107,107,.08);
    color: #ffc1c1;
    font-size: .86rem;
}

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 54px;
    height: 30px;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #41495a;
    cursor: pointer;
    transition: .2s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    top: 4px;
    left: 4px;
    border-radius: 50%;
    background: white;
    transition: .2s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,.35);
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(24px);
}

.switch input:disabled + .switch-track {
    opacity: .55;
    cursor: wait;
}

.empty-state {
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    display: block;
    color: var(--text);
    font-size: 1.05rem;
}

.empty-state.large { padding: 42px 24px; }

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: 420px;
    padding: 14px 17px;
    border-radius: 11px;
    color: white;
    background: #28764a;
    box-shadow: var(--shadow);
    font-weight: 750;
    z-index: 50;
}

.toast.error { background: #9f3434; }

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 460px);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-brand { margin-bottom: 28px; }

.login-card h1 {
    margin: 0 0 7px;
    font-size: 1.8rem;
}

.login-card > p {
    margin: 0 0 22px;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 15px;
}

.stack-form label span {
    display: block;
    margin-bottom: 6px;
    font-weight: 800;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 10px;
}

.alert-error {
    color: #ffc1c1;
    background: rgba(255,107,107,.11);
    border: 1px solid rgba(255,107,107,.25);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .content-grid { grid-template-columns: 1fr; }
    .module-toolbar { grid-template-columns: 1fr 1fr; }
    .module-toolbar .search-box { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
    html { font-size: 16px; }

    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-104%);
        width: min(86vw, 310px);
        transition: transform .22s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.open { transform: translateX(0); }

    .main { padding: 0 16px 34px; }
    .topbar { min-height: 90px; }
    .menu-button { display: inline-flex; }
    .hero { align-items: flex-start; flex-direction: column; padding: 23px; }
    .metric-grid { grid-template-columns: 1fr; }
    .module-toolbar { grid-template-columns: 1fr; }
    .module-toolbar .search-box { grid-column: auto; }
    .module-title-row { align-items: flex-start; }
    .module-meta { display: grid; gap: 5px; }
    .panel { padding: 19px; }
}
