:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #69758a;
    --line: #dfe5ef;
    --primary: #116466;
    --primary-dark: #0b494b;
    --accent: #c49a3a;
    --danger: #b42318;
    --warning: #9a6700;
    --ok: #147d4f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Tahoma, Arial, sans-serif;
    line-height: 1.55;
}

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

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

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

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: var(--text);
    font-weight: 700;
}

label input,
label select,
label textarea {
    font-weight: 400;
}

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

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

th {
    color: var(--muted);
    font-weight: 700;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #162238;
    color: #fff;
    padding: 22px;
}

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

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent);
    color: #111827;
    font-weight: 900;
}

.brand small {
    display: block;
    color: #bdc7d8;
    margin-top: 2px;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 28px;
}

.nav a {
    color: #dce4f2;
    padding: 10px 12px;
    border-radius: 8px;
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.main {
    padding: 28px;
    display: grid;
    gap: 20px;
    align-content: start;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.admin-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

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

.panel-header h2,
.panel h2 {
    margin: 0;
    font-size: 18px;
}

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

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

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

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

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

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

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

.form-actions {
    align-self: end;
}

.row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 14px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

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

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

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

.button.small {
    min-height: 32px;
    padding: 5px 10px;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    background: #eef2f7;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

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

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

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

.notice {
    border: 1px solid #d7eadf;
    background: #eef8f2;
    color: #245c3c;
    border-radius: 8px;
    padding: 12px;
}

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

.flash.success {
    border-color: #bde5ca;
    background: #eef8f2;
    color: #245c3c;
}

.flash.error {
    border-color: #f3b3ad;
    background: #fff1f0;
    color: var(--danger);
}

.inline-form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

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

.switch-row input {
    width: auto;
}

.short-input {
    max-width: 90px;
}

.wide {
    max-width: 520px;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

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

.auth-panel {
    width: min(460px, 100%);
}

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

.error-details {
    white-space: pre-wrap;
    direction: ltr;
    text-align: left;
    background: #111827;
    color: #fff;
    border-radius: 8px;
    padding: 12px;
    overflow: auto;
}

@media (max-width: 980px) {
    .app-shell,
    .stats-grid,
    .two-columns,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .topbar,
    .admin-menu {
        align-items: flex-start;
        flex-direction: column;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
