:root {
    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-2: #eef3f4;
    --text: #172124;
    --muted: #647174;
    --line: #d8e1e3;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b91c1c;
    --warning: #a16207;
    --success: #15803d;
    --info: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    margin: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
}

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

button.secondary {
    background: #fff;
    border-color: #bbc8ca;
    color: var(--text);
}

button.secondary:hover {
    background: var(--surface-2);
}

button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

button:disabled {
    background: #a8b3b6;
    border-color: #a8b3b6;
    cursor: not-allowed;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid #c7d3d6;
    border-radius: 6px;
    color: var(--text);
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

textarea {
    min-height: 82px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
    outline: none;
}

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

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

h1 {
    font-size: 25px;
    line-height: 1.15;
    margin-bottom: 8px;
}

h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

h3 {
    font-size: 15px;
    margin-bottom: 8px;
}

a {
    color: var(--primary-dark);
}

.loading-screen,
.auth-screen {
    align-items: center;
    display: flex;
    min-height: 100vh;
    padding: 18px;
}

.loading-box,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 460px;
    padding: 24px;
    width: 100%;
}

.loading-box {
    display: grid;
    gap: 4px;
}

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

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-height: 62px;
    padding: 10px clamp(14px, 3vw, 30px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    align-items: center;
    display: flex;
    font-weight: 700;
    gap: 10px;
}

.brand-mark {
    align-items: center;
    background: var(--primary);
    border-radius: 7px;
    color: #fff;
    display: inline-flex;
    font-size: 13px;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.userbox {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
}

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

.nav {
    background: #243133;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px clamp(12px, 3vw, 28px);
}

.nav button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #eef7f7;
    min-height: 36px;
    white-space: nowrap;
}

.nav button.active,
.nav button:hover {
    background: #fff;
    color: var(--primary-dark);
}

.container {
    margin: 0 auto;
    max-width: 1380px;
    padding: 20px clamp(12px, 3vw, 28px) 40px;
}

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

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

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

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

.split {
    align-items: start;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .55fr);
}

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

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

.stat {
    padding: 15px;
}

.stat span {
    color: var(--muted);
    display: block;
}

.stat strong {
    display: block;
    font-size: 27px;
    line-height: 1.1;
    margin-top: 4px;
}

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

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filters {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tabs button {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

.tabs button.active,
.tabs button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

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

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

th {
    background: var(--surface-2);
    color: #344447;
    font-size: 12px;
    text-transform: uppercase;
}

.number {
    text-align: right;
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    white-space: nowrap;
}

.badge.success {
    background: #dcfce7;
    color: var(--success);
}

.badge.warning {
    background: #fef3c7;
    color: var(--warning);
}

.badge.danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge.info {
    background: #dbeafe;
    color: var(--info);
}

.badge.neutral {
    background: #e5e7eb;
    color: #374151;
}

.flash {
    border-radius: var(--radius);
    font-weight: 700;
    margin-bottom: 12px;
    padding: 10px 12px;
}

.flash.success {
    background: #dcfce7;
    color: var(--success);
}

.flash.danger {
    background: #fee2e2;
    color: var(--danger);
}

.flash.warning {
    background: #fef3c7;
    color: var(--warning);
}

.empty {
    color: var(--muted);
    padding: 14px 0;
}

pre.audit {
    background: #0f172a;
    border-radius: 6px;
    color: #e2e8f0;
    max-height: 160px;
    overflow: auto;
    padding: 9px;
    white-space: pre-wrap;
}

@media (max-width: 980px) {
    .grid.two,
    .grid.three,
    .grid.four,
    .split {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .userbox {
        align-items: flex-start;
        text-align: left;
    }

    .filters {
        grid-template-columns: 1fr;
    }

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

    .actions button {
        width: 100%;
    }
}

