:root {
    color-scheme: light;
    --ink: #172026;
    --muted: #66737d;
    --paper: #f4f7f5;
    --panel: rgba(255, 255, 255, .88);
    --panel-solid: #ffffff;
    --line: rgba(23, 32, 38, .1);
    --green: #197653;
    --green-dark: #10583d;
    --blue: #2d6cdf;
    --amber: #b36b00;
    --red: #b4233d;
    --violet: #6b4fd8;
    --shadow: 0 24px 70px rgba(23, 32, 38, .12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(140deg, rgba(25, 118, 83, .13), transparent 30%),
        linear-gradient(315deg, rgba(45, 108, 223, .11), transparent 34%),
        #eef3f1;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
input {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 282px;
    height: 100vh;
    padding: 24px 18px;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: rgba(251, 252, 250, .76);
    backdrop-filter: blur(22px);
}

.brand-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    aspect-ratio: 1;
    border-radius: var(--radius);
    color: #fff;
    background: var(--green);
    box-shadow: 0 14px 32px rgba(25, 118, 83, .26);
    font-weight: 900;
}

.brand-row strong,
.brand-row small {
    display: block;
}

.brand-row small,
.eyebrow,
.panel-head span,
.metric-card small,
.module-card small,
.module-card p,
.empty,
.mini-row small,
.mini-row span {
    color: var(--muted);
}

.nav-stack {
    display: grid;
    gap: 7px;
}

.nav-label {
    margin: 12px 2px 2px;
    color: #789186;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: #52606b;
    transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.nav-item span {
    display: grid;
    place-items: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(25, 118, 83, .08);
    color: var(--green-dark);
    font-size: 11px;
    font-weight: 900;
}

.nav-item:hover,
.nav-item.active {
    color: #123227;
    background: #fff;
    box-shadow: 0 12px 30px rgba(23, 32, 38, .08);
    transform: translateX(3px);
}

.sidebar-card {
    margin-top: auto;
    padding: 15px;
    border: 1px solid rgba(25, 118, 83, .16);
    border-radius: var(--radius);
    background: #e8f5ee;
}

.sidebar-card strong {
    display: block;
    margin-bottom: 6px;
}

.sidebar-card p {
    margin: 0;
    color: #527064;
    font-size: 13px;
    line-height: 1.5;
}

.workspace-main {
    min-width: 0;
    margin-left: 282px;
    padding: 26px clamp(18px, 4vw, 44px) 64px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 5px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 42px);
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 19px;
    letter-spacing: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

button,
.ghost-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 800;
}

button {
    color: #fff;
    background: var(--green);
}

button:hover {
    background: var(--green-dark);
}

.ghost-button,
.secondary-button {
    color: var(--ink);
    background: rgba(255, 255, 255, .72);
    border-color: var(--line);
}

.danger-button {
    min-height: 32px;
    color: #fff;
    background: var(--red);
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 800;
}

.success {
    color: #17613d;
    background: #e6f6ee;
}

.error {
    color: #8d2323;
    background: #fdecec;
}

.hero-panel,
.panel,
.metric-card,
.module-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 14px 44px rgba(23, 32, 38, .07);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 22px;
    align-items: end;
    margin-bottom: 18px;
    padding: clamp(20px, 4vw, 32px);
}

.hero-panel h2 {
    max-width: 760px;
    margin-bottom: 10px;
    font-size: clamp(25px, 4vw, 38px);
}

.hero-panel p {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.6;
}

.profile-card {
    padding: 17px;
    border: 1px solid rgba(25, 118, 83, .16);
    border-radius: var(--radius);
    background: #f6fbf8;
}

.profile-card span,
.profile-card small {
    display: block;
    color: var(--muted);
}

.profile-card strong {
    display: block;
    margin: 6px 0 4px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card {
    min-height: 138px;
    padding: 17px;
    overflow: hidden;
}

.metric-card span,
.metric-card small,
.metric-card strong {
    display: block;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.metric-card strong {
    margin: 12px 0 6px;
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.metric-card.green { border-top: 4px solid var(--green); }
.metric-card.blue { border-top: 4px solid var(--blue); }
.metric-card.amber { border-top: 4px solid var(--amber); }
.metric-card.red { border-top: 4px solid var(--red); }
.metric-card.violet { border-top: 4px solid var(--violet); }

.dashboard-grid,
.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
    gap: 16px;
    margin-bottom: 18px;
}

.panel {
    padding: 18px;
}

.panel.wide {
    grid-column: span 1;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.queue-list,
.readiness-list,
.mini-list,
.backup-list {
    display: grid;
    gap: 10px;
}

.queue-row,
.mini-row,
.backup-list a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid #edf1ef;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .72);
}

.queue-row strong,
.queue-row small,
.backup-list strong,
.backup-list span {
    display: block;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(25, 118, 83, .1);
}

.pill,
.count-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--green-dark);
    background: #e8f5ee;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.readiness-list span,
.chip-cloud span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid #dbe9e2;
    border-radius: 999px;
    background: #f7fbf9;
    color: #385f4f;
    font-size: 13px;
    font-weight: 800;
}

.chip-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.module-card {
    position: relative;
    min-height: 184px;
    padding: 17px;
    transition: transform .18s ease, box-shadow .18s ease;
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.module-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    color: #fff;
    background: var(--green);
    font-size: 12px;
    font-weight: 950;
}

.module-card strong,
.module-card small {
    display: block;
}

.module-card p {
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 1.5;
}

.module-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.field-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

input {
    width: 100%;
    height: 40px;
    border: 1px solid #d8e1e6;
    border-radius: var(--radius);
    padding: 0 11px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(25, 118, 83, .12);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 11px 9px;
    border-bottom: 1px solid #edf1ef;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.uuid {
    max-width: 176px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

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

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel {
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .9);
    box-shadow: var(--shadow);
}

.auth-panel h1 {
    margin-top: 26px;
}

.auth-panel p {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 13px;
    margin-top: 18px;
}

.backup-list a {
    grid-template-columns: minmax(0, 1fr) auto;
}

@media (max-width: 1180px) {
    .metric-grid,
    .module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .settings-grid,
    .hero-panel,
    .module-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .workspace-main {
        margin-left: 0;
        padding: 22px 16px 42px;
    }

    .topbar,
    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .top-actions,
    .top-actions form,
    .top-actions button,
    .top-actions a,
    .metric-grid,
    .module-grid {
        width: 100%;
    }

    .metric-grid,
    .module-grid {
        grid-template-columns: 1fr;
    }
}
