:root {
    --bg: #f5f7f9;
    --surface: #ffffff;
    --line: #d8dee5;
    --text: #17202a;
    --muted: #667085;
    --accent: #126b5f;
    --accent-dark: #0d4d45;
    --danger: #b42318;
    --ok: #0f7a45;
}

* {
    box-sizing: border-box;
}

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

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

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 18px;
    background: #17202a;
    color: #fff;
}

.brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.sidebar nav {
    display: grid;
    gap: 4px;
}

.sidebar nav a,
.text-button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #d0d5dd;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sidebar nav a.active,
.sidebar nav a:hover,
.text-button:hover {
    background: #243241;
    color: #fff;
    text-decoration: none;
}

.content {
    padding: 28px;
    overflow-x: auto;
}

.page-header {
    margin-bottom: 20px;
}

.page-header.split {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 24px;
}

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

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

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

.metric,
.table-section,
.detail-grid,
.form-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.metric {
    padding: 16px;
}

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

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.table-section {
    margin-bottom: 18px;
    padding: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

td.wide {
    min-width: 280px;
}

.number {
    text-align: right;
}

.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 120px 100px auto;
    gap: 8px;
    margin-bottom: 16px;
}

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

textarea {
    resize: vertical;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}

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

.primary-button:hover {
    background: var(--accent-dark);
    text-decoration: none;
}

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

.status {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.status.ok {
    background: #e7f6ee;
    color: var(--ok);
}

.status.off {
    background: #f5e7e7;
    color: var(--danger);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    padding: 12px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    min-width: 34px;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.pagination a.current {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.schema-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.schema-toc a {
    display: inline-flex;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.schema-section {
    scroll-margin-top: 18px;
}

.schema-role {
    margin: 0 0 12px;
    color: var(--muted);
}

.detail-grid {
    margin-bottom: 18px;
    padding: 16px;
}

dl {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0;
}

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

dd {
    margin: 0;
    word-break: break-word;
}

.summary-text {
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
}

.raw-json {
    max-height: 420px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border-radius: 6px;
    background: #111827;
    color: #e5e7eb;
    font-size: 12px;
}

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

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

.form-section h2 {
    grid-column: 1 / -1;
}

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

label.full {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.form-error,
.form-success {
    padding: 10px 12px;
    border-radius: 6px;
}

.form-error {
    background: #fef3f2;
    color: var(--danger);
}

.form-success {
    background: #ecfdf3;
    color: var(--ok);
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background: #17202a;
}

.login-panel {
    width: min(420px, calc(100vw - 32px));
    padding: 28px;
    border-radius: 8px;
    background: #fff;
}

.login-panel h1 {
    margin-bottom: 20px;
}

.login-form {
    display: grid;
    gap: 14px;
}

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

    .sidebar {
        position: static;
        height: auto;
    }

    .filter-bar,
    .metric-grid,
    .form-section {
        grid-template-columns: 1fr;
    }
}
