:root {
  --bg: #0f1113; --panel: #171a1d; --panel2: #1e2226; --line: #2a2f35; --text: #e8eaed; --muted: #8b939c;
  --accent: #d4ff3a; --accent-ink: #111; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa;
  --radius: 10px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; display: flex; gap: .6rem; align-items: center; }
small { display: block; color: var(--muted); font-size: .8rem; }
h2 small, label small, legend small { display: inline; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.muted { color: var(--muted); }
.err { color: var(--bad); display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #0a0b0c; border-right: 1px solid var(--line); padding: 1.2rem .9rem; display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; }
.brand small { font-weight: 400; }
.logo { background: var(--accent); color: var(--accent-ink); border-radius: 8px; width: 38px; height: 38px; display: grid; place-items: center; font-weight: 800; }
.side nav { display: flex; flex-direction: column; gap: .2rem; }
.side nav a { color: var(--text); padding: .55rem .75rem; border-radius: 8px; }
.side nav a:hover { background: var(--panel2); text-decoration: none; }
.side nav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.logout { margin-top: auto; }
.main { padding: 1.4rem 1.8rem 4rem; max-width: 1400px; width: 100%; }
.top { margin-bottom: 1.2rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.2rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.tile b { display: block; font-size: 1.8rem; }
.tile span { color: var(--muted); }
.tile.ok b { color: var(--ok); } .tile.warn b { color: var(--warn); } .tile.bad b { color: var(--bad); }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 8px; padding: .45rem .9rem; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: #5b2a2a; }
.btn.ghost { background: transparent; }
form.inline { display: inline; }
.acts { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); } .badge.info { color: var(--info); } .badge.muted { color: var(--muted); }
.role { font-weight: 600; }
.note { margin-top: .3rem; font-size: .82rem; }
.note > * { display: block; }

.toast { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.toast.ok { color: var(--ok); background: #0f2a1a; }
.toast.bad { color: var(--bad); background: #2a1212; }

.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }
tr:hover td { background: #1b1f23; }
.empty { color: var(--muted); }
.hint { color: var(--muted); margin-top: -.3rem; }

input, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; font: inherit; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
label { display: block; color: var(--muted); font-size: .88rem; }
label input, label select { margin-top: .3rem; color: var(--text); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: .8rem; align-items: end; margin-top: .8rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .8rem; } .facts dd { margin: 0; word-break: break-all; }

.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; margin-bottom: 1.2rem; }
.radio { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; color: var(--text); cursor: pointer; }
.radio:has(input:checked) { border-color: var(--accent); }
.radio small { display: block; }
.subgroup { border: 1px solid var(--line); border-radius: 8px; margin: .8rem 0; padding: .4rem .8rem .8rem; }
.subgroup legend label { color: var(--text); font-weight: 600; }
label.sub { color: var(--text); padding: .35rem 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
label.sub small { display: inline; margin-left: .4rem; }
#sub-filter { margin-bottom: .4rem; }
.sticky { position: sticky; bottom: 0; background: var(--panel); padding-top: .8rem; }

.signin .code { display: flex; gap: .8rem; align-items: center; margin: .5rem 0 1rem; }
#user-code { font: 700 2rem ui-monospace, Consolas, monospace; letter-spacing: .15em; color: var(--accent); }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { width: min(380px, 100%); display: grid; gap: 1rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0 0 0 auto; }
  .main { padding: 1rem; }
  .grid-form { grid-template-columns: 1fr; }
  thead { display: none; }
  tr, td { display: block; }
  tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  td { border: 0; padding: .25rem 0; }
  td[data-l]:not([data-l=""])::before { content: attr(data-l); display: block; color: var(--muted); font-size: .75rem; }
  .acts { justify-content: flex-start; }
}
