:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-soft: #eef4f1;
    --text: #1d2726;
    --muted: #61706c;
    --line: #d7e0dc;
    --teal: #0f766e;
    --green: #2f7d46;
    --gold: #a16207;
    --red: #b42318;
    --ink: #16201f;
    --shadow: 0 16px 34px rgba(29, 39, 38, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

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

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
}

h2 {
    font-size: 18px;
    line-height: 1.25;
}

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

button,
input,
select {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 22px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand,
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--ink);
    color: #ffffff;
    font-weight: 800;
    font-size: 13px;
}

.brand small,
.account span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
}

.nav a {
    white-space: nowrap;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 650;
}

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

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

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

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

.auth-card {
    width: min(440px, 100%);
    padding: 30px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.setup-card {
    width: min(560px, 100%);
}

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

.auth-brand h1 {
    font-size: 24px;
}

.page-head,
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.page-head {
    margin-bottom: 22px;
}

.page-head p,
.panel-head p {
    margin-top: 6px;
}

.actions,
.inline-form,
.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 750;
    white-space: nowrap;
}

.button-primary {
    background: var(--teal);
    color: #ffffff;
}

.button-secondary {
    background: var(--ink);
    color: #ffffff;
}

.button-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.button:hover {
    filter: brightness(0.96);
}

.stack {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
}

input:focus,
select:focus {
    outline: 3px solid rgba(15, 118, 110, 0.18);
    border-color: var(--teal);
}

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

.metric-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    position: relative;
    min-height: 136px;
    padding: 18px;
    overflow: hidden;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--teal);
}

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

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

.metric-card strong {
    display: block;
    margin: 14px 0 8px;
    font-size: 28px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.accent-green::before {
    background: var(--green);
}

.accent-gold::before {
    background: var(--gold);
}

.accent-red::before {
    background: var(--red);
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
    gap: 18px;
    align-items: start;
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
}

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

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 850;
}

.right {
    text-align: right;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.badge-good {
    background: #e7f6ed;
    color: var(--green);
}

.badge-warn {
    background: #fff6db;
    color: var(--gold);
}

.badge-muted {
    background: var(--surface-soft);
    color: var(--muted);
}

.activity-list,
.stat-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.activity-row,
.stat-row,
.empty-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 12px;
    background: var(--surface-soft);
    border-radius: 8px;
}

.stat-row {
    grid-template-columns: 1fr auto auto;
}

.activity-row small,
.stat-row small {
    display: block;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
}

.status-dot.success {
    background: var(--green);
}

.status-dot.failed {
    background: var(--red);
}

.filters {
    align-items: end;
}

.filters label {
    min-width: 220px;
}

.alert {
    margin-bottom: 16px;
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    font-weight: 700;
}

.alert-success {
    border-color: #b8dfc4;
    color: var(--green);
}

.alert-error {
    border-color: #f1b4ae;
    color: var(--red);
}

.empty-state {
    display: grid;
    gap: 12px;
    padding: 18px;
    background: var(--surface-soft);
    border-radius: 8px;
}

.check-list {
    display: grid;
    gap: 10px;
    padding-left: 18px;
    margin: 16px 0 0;
    color: var(--muted);
}

.raw-box {
    max-height: 420px;
    overflow: auto;
    padding: 14px;
    background: #101817;
    color: #e7f6ed;
    border-radius: 8px;
    white-space: pre-wrap;
}

@media (max-width: 980px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .account {
        justify-content: space-between;
    }

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

@media (max-width: 640px) {
    .shell {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .page-head,
    .panel-head {
        display: grid;
    }

    .actions,
    .inline-form,
    .filters {
        display: grid;
        width: 100%;
    }

    .filters label {
        min-width: 0;
    }

    .button {
        width: 100%;
    }

    h1 {
        font-size: 25px;
    }
}
