:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #18202a;
    --muted: #687384;
    --line: #dfe4ea;
    --primary: #1f6f5b;
    --primary-dark: #185848;
    --danger: #a43d3d;
    --success-bg: #e8f5ef;
    --error-bg: #faeeee;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

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

.nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.nav a {
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.nav a:hover {
    background: var(--bg);
    text-decoration: none;
}

.page,
.auth-page {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 20px;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.auth-card {
    width: min(420px, 100%);
}

.auth-card h1,
.page-heading h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
}

.auth-card p,
.page-heading p {
    margin: 8px 0 0;
    color: var(--muted);
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.section-heading h2,
.panel h2 {
    margin: 0;
    font-size: 19px;
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    color: #394454;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cdd5df;
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

input[type="color"] {
    padding: 4px;
}

.checkbox {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: 10px;
}

.checkbox input {
    width: 18px;
    min-height: 18px;
}

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

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

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

.button.full {
    width: 100%;
}

.actions {
    display: flex;
    justify-content: flex-end;
}

.alert {
    margin-bottom: 16px;
    border-radius: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
}

.alert.success {
    background: var(--success-bg);
    border-color: #b9dfcc;
}

.alert.error,
.field-error {
    color: var(--danger);
}

.alert.error {
    background: var(--error-bg);
    border-color: #edc8c8;
}

.field-error {
    font-size: 13px;
    font-weight: 600;
}

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

.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat strong {
    display: block;
    margin-top: 4px;
    font-size: 28px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
    gap: 12px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

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

tr:last-child td {
    border-bottom: 0;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border: 1px solid #9aa5b1;
    border-radius: 4px;
    vertical-align: -3px;
}

.swatch.large {
    width: 24px;
    height: 24px;
    vertical-align: -4px;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #334155;
    font-size: 13px;
}

.details dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 0;
}

.details dl div {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.details dt {
    color: var(--muted);
    font-size: 13px;
}

.details dd {
    margin: 4px 0 0;
    font-weight: 700;
}

@media (max-width: 760px) {
    .topbar,
    .page-heading,
    .search-bar,
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-form {
        display: flex;
    }

    .page,
    .auth-page {
        padding: 14px;
    }

    .form-grid,
    .stats-grid,
    .details dl {
        grid-template-columns: 1fr;
    }

    .auth-card h1,
    .page-heading h1 {
        font-size: 25px;
    }

    .button {
        width: 100%;
    }
}
