[hidden] { display: none !important; }
:root {
  --bg: #0b0b0b;
  --panel: #131313;
  --panel-2: #1a1a1a;
  --line: #262626;
  --line-2: #333333;
  --text: #f2f2f0;
  --muted: #a3a3a3;
  --dim: #6f6f6f;
  --ok: #4ade80;
  --alert: #e5484d;
  --amber: #f2a33a;
  --head: "Barlow Condensed", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.label { font-family: var(--head); font-weight: 600; letter-spacing: .18em; text-transform: uppercase; font-size: 13px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ───────── Login ───────── */
.login-wrap { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.classbar { background: var(--alert); color: #fff; text-align: center; font-family: var(--head); font-weight: 700; letter-spacing: .3em; font-size: 13px; padding: 6px 12px; text-transform: uppercase; }
.login-main { display: grid; place-items: center; padding: 48px 20px; background:
  radial-gradient(circle at 50% 30%, rgba(255,255,255,.04), transparent 55%),
  repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 4px); }
.login-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-top: 4px solid var(--text); padding: 40px 36px 32px; text-align: center; }
.login-card img { width: 128px; height: 128px; object-fit: contain; }
.login-card .agency { margin: 18px 0 2px; }
.login-card h1 { font-family: var(--head); font-size: 38px; line-height: 1; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .02em; }
.login-card .sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.restricted { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: rgba(229,72,77,.08); border: 1px solid rgba(229,72,77,.35); padding: 12px 14px; margin-bottom: 24px; font-size: 13px; color: #f3c9ca; }
.restricted b { color: #fff; }
.btn-discord { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; background: #5865f2; color: #fff; text-decoration: none; font-weight: 600; padding: 14px 18px; border: 0; cursor: pointer; font-size: 15px; }
.btn-discord:hover { background: #4752c4; }
.msg { margin: 18px 0 0; font-size: 13px; padding: 10px 12px; border: 1px solid var(--line-2); text-align: left; }
.msg.error { border-color: rgba(229,72,77,.5); color: #f3c9ca; }
.msg.ok { border-color: rgba(74,222,128,.4); color: #c9f3d8; }
.login-meta { margin-top: 22px; display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; font-family: var(--mono); }
.disclaimer { text-align: center; color: var(--dim); font-size: 12px; padding: 16px 20px 22px; border-top: 1px solid var(--line); }

/* ───────── App shell ───────── */
.app { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: auto auto 1fr auto; min-height: 100vh; }
.app > .classbar { grid-column: 1 / -1; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand .t1 { font-family: var(--head); font-weight: 700; font-size: 20px; letter-spacing: .04em; text-transform: uppercase; line-height: 1; }
.brand .t2 { font-size: 11px; letter-spacing: .2em; color: var(--muted); text-transform: uppercase; }
.status { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line-2); padding: 4px 10px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 12px; }
.user img, .user .ph { width: 36px; height: 36px; border-radius: 50%; background: var(--line-2); object-fit: cover; }
.user .name { font-weight: 600; line-height: 1.1; }
.badge { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 2px 8px; border: 1px solid var(--line-2); color: var(--muted); margin-top: 2px; }
.badge.command { border-color: var(--amber); color: var(--amber); }
.btn { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border: 1px solid var(--line-2); background: transparent; color: var(--text); padding: 8px 14px; text-decoration: none; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #fff; }

.sidebar { border-right: 1px solid var(--line); padding: 20px 14px; background: var(--panel); }
.sidebar .label { padding: 0 10px 8px; display: block; }
.nav { list-style: none; margin: 0 0 22px; padding: 0; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; text-decoration: none; color: var(--muted); border-left: 3px solid transparent; }
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); border-left-color: var(--text); }
.nav .count { font-family: var(--mono); font-size: 12px; color: var(--dim); }

main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--head); font-size: 40px; line-height: 1; margin: 4px 0 0; text-transform: uppercase; letter-spacing: .02em; }
.view[hidden] { display: none; }

.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 20px; }
.panel h2 { font-family: var(--head); font-size: 22px; text-transform: uppercase; margin: 0 0 12px; letter-spacing: .03em; }
.tile { display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--text); padding: 18px; text-decoration: none; transition: border-color .15s, background .15s; }
.tile:hover { background: var(--panel-2); border-color: var(--line-2); }
.tile .k { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tile .t { font-family: var(--head); font-size: 22px; font-weight: 700; text-transform: uppercase; line-height: 1.05; }
.tile .d { color: var(--muted); font-size: 13px; }
.tile.cmd { border-top-color: var(--amber); }
.stat .v { font-family: var(--head); font-weight: 700; font-size: 44px; line-height: 1; }
.stat .v small { font-size: 22px; color: var(--muted); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 6px; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line-2); padding: 0 14px; }
.search input { flex: 1; background: transparent; border: 0; color: var(--text); padding: 12px 0; font: inherit; outline: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--muted); padding: 7px 12px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

table.records { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.records th { text-align: left; font-family: var(--head); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line-2); background: var(--panel-2); }
.records td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.records tr:last-child td { border-bottom: 0; }
.records tr:hover td { background: #161616; }
.records .rid { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.records .ttl { font-weight: 600; }
.records .desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.type { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); padding: 2px 7px; color: var(--muted); white-space: nowrap; }
.restricted-tag { font-family: var(--mono); font-size: 11px; border: 1px solid var(--amber); color: var(--amber); padding: 2px 7px; margin-left: 8px; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

table.plain { width: 100%; border-collapse: collapse; }
.plain th, .plain td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.plain th { font-family: var(--head); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--muted); }
.plain td.mono { color: var(--muted); }

.cert { border-top: 3px solid var(--text); }
.cert .num { font-family: var(--head); font-size: 15px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.cert h3 { font-family: var(--head); font-size: 26px; text-transform: uppercase; margin: 4px 0 8px; }
.cert dl { margin: 12px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.cert dt { color: var(--muted); }
.cert dd { margin: 0; }

footer.foot { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 14px 24px; color: var(--dim); font-size: 12px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.loading { display: grid; place-items: center; min-height: 100vh; color: var(--muted); font-family: var(--mono); }

@media (max-width: 1100px) { .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.k3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 10px 14px; gap: 10px; }
  .user .name, .user #avatar { display: none; }
  .user .badge { font-size: 10px; }
  .brand .t1 { font-size: 17px; }
  .classbar { letter-spacing: .14em; font-size: 11px; }
  .page-head h1 { font-size: 32px; }
  .records th:nth-child(1), .records td:nth-child(1), .records th:nth-child(4), .records td:nth-child(4) { display: none; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .sidebar .label { display: none; }
  .nav { display: flex; gap: 4px; overflow-x: auto; margin: 0; }
  .nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .nav a.active { border-bottom-color: var(--text); }
  .nav .count { display: none; }
  .status, .brand .t2 { display: none; }
  main { padding: 20px 16px 40px; }
  .grid.k2 { grid-template-columns: 1fr; }
  .records th:nth-child(3), .records td:nth-child(3) { display: none; }
}

.table-wrap { overflow-x: auto; }

.add-form { display: grid; grid-template-columns: 1.3fr 1.3fr .8fr auto; gap: 12px; align-items: end; }
.add-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.add-form input, .add-form select { background: var(--bg); color: var(--text); border: 1px solid var(--line-2); padding: 10px 12px; font: inherit; }
.add-form input:focus, .add-form select:focus { border-color: var(--text); outline: none; }
.plain .actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger:hover { border-color: var(--alert); color: #f3c9ca; }
.locked { font-family: var(--mono); font-size: 11px; color: var(--dim); }
@media (max-width: 860px) { .add-form { grid-template-columns: 1fr; } }
