:root {
    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-strong: #eef3f1;
    --text: #17201d;
    --muted: #61706a;
    --line: #d9e0dd;
    --accent: #176b5f;
    --accent-strong: #0f4e45;
    --warn: #9f5c13;
    --danger: #aa2d2d;
    --shadow: 0 12px 28px rgba(16, 24, 32, 0.08);
}

* {
    box-sizing: border-box;
}

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

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

a:hover {
    color: var(--accent-strong);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 64px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.brand {
    color: var(--text);
    font-weight: 760;
    letter-spacing: 0;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar nav a {
    color: #34443e;
    font-size: 14px;
    font-weight: 560;
}

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

.page-head,
.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 22px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 34px;
    line-height: 1.1;
}

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

h3 {
    margin: 20px 0 8px;
    font-size: 15px;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 720;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

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

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

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

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

.action-card {
    display: block;
    min-height: 132px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
}

.action-card:hover {
    border-color: #b8cdc7;
    color: var(--text);
}

.action-card span {
    display: block;
    margin-bottom: 10px;
    color: var(--accent-strong);
    font-size: 24px;
    font-weight: 760;
}

.action-card p {
    margin-bottom: 0;
    color: var(--muted);
}

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

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

.stat {
    padding: 18px;
}

.stat span {
    display: block;
    min-height: 30px;
    color: var(--accent-strong);
    font-size: 24px;
    font-weight: 760;
    overflow-wrap: anywhere;
}

.stat p {
    margin: 8px 0 0;
    color: var(--muted);
}

.panel,
.narrow {
    padding: 22px;
}

.narrow {
    width: min(620px, 100%);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.button:hover,
button:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: #fff;
}

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

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

.button.secondary:hover {
    border-color: var(--accent);
    background: var(--surface-strong);
    color: var(--accent-strong);
}

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

.form,
.filters {
    display: grid;
    gap: 14px;
}

.form.compact {
    gap: 10px;
}

.filters {
    grid-template-columns: minmax(220px, 1fr) 180px auto;
    align-items: end;
    margin-bottom: 18px;
}

.filters.wide {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(140px, 0.8fr) auto auto auto;
}

label {
    display: grid;
    gap: 6px;
    color: #33433e;
    font-size: 13px;
    font-weight: 650;
}

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 560;
}

label.inline {
    min-height: 40px;
}

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

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(23, 107, 95, 0.18);
    border-color: var(--accent);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

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

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

th {
    background: var(--surface-strong);
    color: #40504a;
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e4efec;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
}

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

.small {
    font-size: 12px;
}

.tool-list {
    display: grid;
    gap: 12px;
}

.tool-row {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
}

dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 12px;
    margin: 0;
}

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

dd {
    margin: 0;
}

.brief {
    color: #293630;
    white-space: normal;
}

pre,
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre {
    overflow-x: auto;
    margin: 0;
    padding: 14px;
    border-radius: 6px;
    background: #111815;
    color: #d9f4eb;
}

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

.flash,
.token-box {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.flash-success {
    border-color: #aad5ca;
    background: #edf8f5;
}

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

.token-box {
    display: grid;
    gap: 8px;
    border-color: #dac08e;
    background: #fff7e8;
}

.token-box code {
    overflow-wrap: anywhere;
}

@media (max-width: 780px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 18px;
    }

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

    .page-head,
    .section-title {
        align-items: start;
        flex-direction: column;
    }

    .grid.stats,
    .grid.compact-stats,
    .actions-grid,
    .grid.two,
    .filters {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 28px;
    }

    dl {
        grid-template-columns: 1fr;
    }
}
