:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2a5fad;
  --danger: #f47174;
  --success: #5bd37a;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); }
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); }
}
aside {
  background: var(--surface);
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
}
.logo {
  display: block;
  max-width: 180px;
  width: 100%;
  height: auto;
  margin: 0 0 1rem;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.tagline { font-size: 0.8rem; color: var(--muted); margin-bottom: 1.25rem; }
nav { display: flex; flex-direction: column; gap: 0.25rem; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
nav a:hover { color: var(--text); background: var(--surface2); }
nav a.active { color: var(--text); background: var(--surface2); font-weight: 600; }
main { padding: 1.25rem 1.5rem 3rem; max-width: 1200px; width: 100%; margin: 0 auto; }
@media (max-width: 900px) {
  main { padding: 1rem; }
}
h1 { font-size: 1.35rem; font-weight: 650; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; color: var(--text); }
.section-lead { color: var(--muted); font-size: 0.88rem; margin-bottom: 1rem; max-width: 56ch; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-bottom: 1rem;
}
button, .btn {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent-dim); background: #2c3c55; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { border-color: #8b3a3c; color: var(--danger); background: rgba(244,113,116,.08); }
button.danger:hover { background: rgba(244,113,116,.15); }
button.ghost { background: transparent; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; min-width: 520px; }
/* OAuth clients: card list */
.client-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.client-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 1rem 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
/* Sessions & tokens: card list */
.security-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.security-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 1.35rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  line-height: 1.45;
}
.sec-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  transition: border-color 0.15s ease;
}
.sec-item:hover { border-color: #3a4a63; }
.sec-item--revoked { opacity: 0.88; }
.sec-item--pending { border-left: 3px solid rgba(61, 139, 253, 0.55); }
.sec-item--code { border-left: 3px solid rgba(245, 180, 90, 0.5); }
.sec-item--token { border-left: 3px solid rgba(91, 211, 122, 0.42); }
.sec-item--admin { border-left: 3px solid rgba(170, 140, 255, 0.45); }
.sec-item--misc { border-left: 3px solid rgba(139, 156, 179, 0.35); }
.sec-item__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
}
.sec-item__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.sec-item__expires {
  font-size: 0.8rem;
  color: var(--muted);
}
.sec-item__id {
  margin: 0.55rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: 0.74rem;
  word-break: break-all;
  color: var(--text);
  line-height: 1.45;
}
.sec-item__id-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-right: 0.35rem;
  font-family: inherit;
}
.sec-item__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.7rem 1.2rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.sec-item__field-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.sec-item__field-val {
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  word-break: break-word;
  line-height: 1.4;
}
.sec-item__jwt {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.sec-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.badge-a {
  background: rgba(170, 140, 255, 0.16);
  color: #baa8ff;
}
.badge-misc {
  background: rgba(139, 156, 179, 0.16);
  color: #9aa8b8;
}
.client-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  transition: border-color 0.15s ease;
}
.client-card:hover { border-color: #3a4a63; }
.client-card--console {
  border-left: 3px solid var(--accent);
  background: rgba(61, 139, 253, 0.06);
}
.client-card__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem 1rem;
}
.client-card__title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: min(100%, 42ch);
}
.client-card__badges { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.badge-type {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-type-pub { background: rgba(91, 211, 122, 0.18); color: var(--success); }
.badge-type-conf { background: rgba(245, 180, 90, 0.18); color: #f5c86a; }
.badge-console {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(61, 139, 253, 0.22);
  color: #7eb6ff;
}
.client-card__id {
  margin: 0.5rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  word-break: break-all;
  color: var(--muted);
  line-height: 1.45;
}
.client-card__id-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-right: 0.35rem;
}
.client-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem 1.25rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.client-card__field-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.client-card__field-val {
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  word-break: break-word;
  line-height: 1.4;
}
.client-card__redirects {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.client-card__redirects .client-card__field-label { margin-bottom: 0.4rem; }
.client-card__redirects ul {
  margin: 0;
  padding-left: 1.15rem;
  font-family: ui-monospace, monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  word-break: break-all;
  color: var(--text);
}
.client-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
button.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: ui-monospace, monospace; font-size: 0.78rem; word-break: break-all; }
.badge {
  display: inline-block; padding: 0.15rem 0.45rem; border-radius: 4px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-p { background: rgba(61,139,253,.2); color: #7eb6ff; }
.badge-c { background: rgba(245,180,90,.2); color: #f5c86a; }
.badge-t { background: rgba(91,211,122,.15); color: var(--success); }
.badge-off { background: rgba(244,113,116,.15); color: var(--danger); }
label { display: block; margin-top: 0.65rem; font-size: 0.8rem; color: var(--muted); }
label.checkbox-lead { max-width: 52ch; line-height: 1.45; }
label.checkbox-lead input { margin-right: 0.35rem; vertical-align: middle; }
label.checkbox-lead code { font-size: 0.78rem; }
input[type=text], input[type=password] {
  width: 100%; max-width: 28rem; margin-top: 0.25rem;
  padding: 0.5rem 0.65rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.err { color: var(--danger); font-size: 0.85rem; margin: 0.35rem 0; }
.ok { color: var(--success); font-size: 0.85rem; }
pre.logs {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.85rem; font-size: 0.72rem; overflow: auto; max-height: 22rem; white-space: pre-wrap;
}
details.jwt-details { margin-top: 0.5rem; }
details.jwt-details summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; user-select: none; }
pre.jwt-pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.6rem; font-size: 0.72rem; margin: 0.25rem 0 0;
  max-height: 12rem; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, monospace;
}
.auth-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.muted { color: var(--muted); font-size: 0.85rem; }
section { scroll-margin-top: 1rem; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55);
  cursor: pointer;
}
.modal-panel {
  position: relative; z-index: 1; max-width: 38rem; width: 100%; max-height: 92vh; overflow-y: auto;
  margin: 0;
}
.modal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.scope-grid { display: flex; flex-wrap: wrap; gap: 0.45rem 1.1rem; margin: 0.35rem 0 0; }
.scope-grid label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.86rem; margin: 0; cursor: pointer; }
textarea.reg-input {
  width: 100%; min-height: 5.5rem; margin-top: 0.25rem; padding: 0.5rem 0.65rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: ui-monospace, monospace; font-size: 0.8rem; resize: vertical;
}
input[readonly].mono { opacity: 0.92; }
.create-success {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.75rem 0.9rem; margin-top: 0.75rem; font-size: 0.82rem;
}
.create-success pre { margin: 0.35rem 0 0; white-space: pre-wrap; word-break: break-all; font-size: 0.78rem; }

.audit-toolbar { align-items: flex-end; }
.audit-filter-label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.78rem; color: var(--muted); margin: 0;
}
.audit-select, .audit-search-input {
  font-family: inherit; font-size: 0.88rem;
  padding: 0.45rem 0.6rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  min-width: 12rem;
}
.audit-search-input { min-width: 14rem; max-width: 22rem; width: 100%; }
.audit-search-label { flex: 1; min-width: 10rem; max-width: 24rem; }
@media (max-width: 900px) {
  .audit-toolbar { flex-direction: column; align-items: stretch; }
  .audit-select, .audit-search-input { max-width: none; }
}
