:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1c2330;
    --muted: #667085;
    --line: #e1e4ea;
    --accent: #3b5bdb;
    --accent-ink: #ffffff;
    --ok: #177245;
    --ok-bg: #e7f5ec;
    --err: #b42318;
    --err-bg: #fdecea;
    --warn-bg: #fff6db;
    --warn: #8a5a00;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar { background: #1c2330; color: #cfd5e1; padding: 20px 0; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; font-weight: 650; font-size: 17px; padding: 0 20px 18px; }
.sidebar .brand small { display: block; font-weight: 400; color: #8b94a7; font-size: 12px; }
.sidebar a { display: block; color: inherit; padding: 8px 20px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #262f40; text-decoration: none; }
.sidebar a.active { color: #fff; background: #262f40; border-left-color: #7b93ff; }
.sidebar .section { margin: 18px 20px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8b94a7; }
.sidebar .me { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid #2c3648; font-size: 13px; }
.sidebar .me strong { color: #fff; display: block; }
.sidebar .me button { margin-top: 8px; }

main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 22px; max-width: 760px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; margin-bottom: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 22px 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 22px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
.empty { padding: 22px; color: var(--muted); }

code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { background: #111723; color: #e6e9ef; padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: 10px 0 0; white-space: pre-wrap; word-break: break-word; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; }
pre code { background: none; padding: 0; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef0f4; color: #3d4657; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #f1f1f1; color: #888; }
.badge.accent { background: #e7ebff; color: #2f49b8; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.success { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cd; }
.flash.error { background: var(--err-bg); color: var(--err); border-color: #f5c6c0; }
.flash.notice { background: var(--warn-bg); color: var(--warn); border-color: #f0dfa8; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 4px 0 0; }
input[type=text], input[type=url], input[type=number], input[type=password], input[type=search], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #c9ced8; border-radius: 7px; font: inherit; background: #fff; color: inherit;
}
textarea { font-family: var(--mono); font-size: 13px; min-height: 120px; resize: vertical; }
textarea.patch { min-height: 340px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9c4ff; border-color: var(--accent); }
.field { margin-bottom: 16px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; flex: 1; min-width: 160px; }

button, .button {
    display: inline-block; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    padding: 8px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary, .button.secondary { background: #fff; color: var(--ink); border-color: #c9ced8; }
button.danger { background: #fff; color: var(--err); border-color: #e3b3ad; }
button.small, .button.small { padding: 3px 9px; font-size: 13px; font-weight: 500; }
button.link { background: none; border: 0; color: #aab3c5; padding: 0; font-weight: 400; }
.buttons { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

.login { max-width: 420px; margin: 12vh auto; padding: 0 20px; }
.login .panel { text-align: center; padding: 34px 30px; }
.login h1 { margin-bottom: 8px; }
.login .button { width: 100%; padding: 11px; margin-top: 14px; }
.login form.dev { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); text-align: left; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
details summary { cursor: pointer; padding: 14px 22px; font-weight: 600; }
ul.errors { margin: 0; padding-left: 18px; }

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; flex-wrap: wrap; padding: 10px; }
    .sidebar .section, .sidebar .brand small { display: none; }
    .sidebar .me { margin: 0; border: 0; padding: 8px 20px; }
    main { padding: 20px 16px 40px; }
    .stats { grid-template-columns: 1fr; }
}
