:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --line: #d9dee7;
    --text: #1d2733;
    --muted: #697586;
    --primary: #176f8f;
    --primary-dark: #0e5068;
    --danger: #a33a3a;
    --warning: #986b12;
    --ok: #287348;
    --radius: 8px;
    --space: 16px;
    --shadow: 0 8px 28px rgba(29, 39, 51, 0.08);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space);
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

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

.nav a,
.link-button {
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.nav a:hover,
.link-button:hover {
    background: #eef3f6;
}

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

.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space);
    margin-bottom: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

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

.form-row {
    margin-bottom: 14px;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 9px 14px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary {
    background: #fff;
    color: var(--primary);
}

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

.flash {
    border-left: 4px solid var(--primary);
}

.flash.error {
    border-left-color: var(--danger);
}

.flash.success {
    border-left-color: var(--ok);
}

.muted {
    color: var(--muted);
}

.metric {
    font-size: 1.8rem;
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: #f1f4f7;
    font-size: 0.92rem;
}

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

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef3f6;
    font-size: 0.85rem;
}

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

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

    .page {
        width: min(100% - 20px, 1180px);
    }
}
