:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --brand: #c8102e;
  --brand-dark: #9e0c24;
  --ok-bg: #e8f6ee; --ok: #19663b;
  --err-bg: #fdecee; --err: #9e1b2d;
  --info-bg: #eaf2fd; --info: #1d4f91;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; background: #111; color: #fff; padding: .75rem 1.25rem; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand span { color: var(--brand); }
.brand small { color: #aaa; font-weight: 400; font-size: .85rem; margin-left: .35rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar nav a, .topbar .link { color: #ddd; text-decoration: none; }
.topbar nav a:hover, .topbar .link:hover { color: #fff; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 .75rem; }
.page-head h1, .page-head h2 { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; margin: 2rem auto; }
.card h2:first-of-type { margin-top: .5rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .85rem; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; padding: .55rem .65rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; font-weight: 400; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.grid2, .grid3 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: repeat(3, 1fr); } }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid #cfd4dc; }
.btn.secondary:hover { background: #f0f1f3; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
form.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
input.small { width: 9rem; margin: 0; padding: .3rem .5rem; font-size: .85rem; }

.search { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.search input { flex: 1 1 240px; margin: 0; }

.flash { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash ul { margin: .35rem 0 0 1.1rem; padding: 0; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }
.flash-info { background: var(--info-bg); color: var(--info); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { background: #fafbfc; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { color: var(--muted); }
td.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
table.metrics td:not(:first-child), table.metrics thead th:not(:first-child) { text-align: right; }
table.metrics thead small { display: block; color: var(--muted); font-weight: 400; }
table.metrics tr.section th { background: #f6f7f9; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem 1.25rem; margin: 0; }
.details .wide { grid-column: 1 / -1; }
.details dt { font-size: .8rem; color: var(--muted); }
.details dd { margin: 0; font-weight: 600; }
.pre { white-space: pre-wrap; font-weight: 400 !important; }

.ref { font-size: .9rem; color: var(--muted); font-weight: 400; margin-left: .35rem; }
.badge { font-size: .75rem; background: #eee; color: #555; padding: .15rem .5rem; border-radius: 99px; vertical-align: middle; }
.unit { color: var(--muted); font-weight: 400; font-size: .8rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin-top: -.25rem; }
.danger-zone { margin-top: 2rem; }
