:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #152033;
    --muted: #667085;
    --line: #e5e7eb;
    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --radius: 8px;
    --shadow: 0 12px 35px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

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

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

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

.sidebar {
    background: #111827;
    color: #d1d5db;
    padding: 24px 18px;
}

.brand {
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 28px;
}

.brand span {
    display: block;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    border-radius: var(--radius);
    color: #d1d5db;
    display: block;
    padding: 11px 12px;
}

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

.main {
    min-width: 0;
    padding: 28px;
}

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

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

.topbar p {
    color: var(--muted);
    margin: 6px 0 0;
}

.toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

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

.grid.two {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
}

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

.card {
    padding: 18px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    font-size: 30px;
    font-weight: 750;
    margin-top: 8px;
}

.panel-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
}

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

.panel-body {
    padding: 18px;
}

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

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

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

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

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

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

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

.badge.gray {
    background: #eef2f7;
    color: #344054;
}

.badge.blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.green {
    background: #d1fae5;
    color: #047857;
}

.badge.red {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.orange {
    background: #ffedd5;
    color: #c2410c;
}

.button,
button {
    align-items: center;
    background: var(--brand);
    border: 0;
    border-radius: var(--radius);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    padding: 10px 14px;
}

.button:hover,
button:hover {
    background: var(--brand-strong);
}

.button.secondary {
    background: #eef2f7;
    color: #1f2937;
}

.button.secondary:hover {
    background: #e5e7eb;
}

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

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

input,
select,
textarea {
    background: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    padding: 10px 12px;
    width: 100%;
}

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

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

.form-field {
    display: grid;
    gap: 7px;
}

.form-field.full {
    grid-column: 1 / -1;
}

label {
    color: #344054;
    font-weight: 700;
}

.hint {
    color: var(--muted);
    font-size: 12px;
}

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

.alert.success {
    background: #ecfdf3;
    color: #027a48;
}

.alert.error {
    background: #fef3f2;
    color: #b42318;
}

.error-list {
    margin: 0;
    padding-left: 18px;
}

.code-block {
    background: #0f172a;
    border-radius: var(--radius);
    color: #dbeafe;
    font-family: Consolas, "SFMono-Regular", monospace;
    line-height: 1.6;
    max-height: 520px;
    overflow: auto;
    padding: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

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

.pagination {
    margin-top: 16px;
}

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

    .sidebar {
        position: static;
    }

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

    .main {
        padding: 18px;
    }

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