:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warning: #d97706;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  padding: 24px;
  background: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #60a5fa, #22c55e);
  color: white;
  font-size: 20px;
}
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: #94a3b8; font-size: 13px; margin-top: 2px; }
nav { display: grid; gap: 6px; margin-top: 32px; }
nav a {
  text-decoration: none;
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 12px;
  transition: background 0.15s, color 0.15s;
}
nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.logout-form { margin-top: auto; }
.full { width: 100%; }
.content { flex: 1; padding: 32px; min-width: 0; }
.content-centered { display: grid; place-items: center; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
h1 { margin: 0; font-size: 30px; }
h2 { margin: 0; font-size: 20px; }
.user-pill { padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.card, .login-card, .stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.login-card { width: min(460px, 100%); padding: 32px; }
.login-brand { margin-bottom: 24px; }
.muted { color: var(--muted); line-height: 1.5; }
.alert { border: 1px solid #fecaca; background: #fef2f2; color: #991b1b; padding: 12px 14px; border-radius: 14px; margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 22px; }
.stat-card span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat-card strong { font-size: 34px; }
.grid-two { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { padding: 22px; }
.wide-card { overflow: hidden; }
.narrow-card { max-width: 820px; }
.section-title { margin-bottom: 18px; }
.section-title p { color: var(--muted); margin: 7px 0 0; line-height: 1.45; }
.form-stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 7px; font-weight: 650; color: #374151; }
input, select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  background: white;
}
input:focus, select:focus { outline: 3px solid rgba(37, 99, 235, 0.18); border-color: var(--accent); }
button, .link-button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-block;
}
button:hover, .link-button:hover { background: var(--accent-dark); }
.secondary { background: #e5e7eb; color: #111827; }
.secondary:hover { background: #d1d5db; }
.checkbox-row { display: flex; align-items: center; gap: 10px; grid-column: span 2; }
.checkbox-row input { width: auto; }
.form-actions { grid-column: span 2; display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
code { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 7px; padding: 2px 6px; font-size: 12px; }
.table-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.status { display: inline-block; padding: 4px 9px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.status.online { background: #dcfce7; color: #166534; }
.status.offline { background: #fee2e2; color: #991b1b; }
.status.pending { background: #fef3c7; color: #92400e; }

@media (max-width: 960px) {
  .shell { display: block; }
  .sidebar { width: auto; height: auto; position: static; }
  .stats-grid, .grid-two, .form-grid { grid-template-columns: 1fr; }
  .checkbox-row, .form-actions { grid-column: span 1; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.detail-section { margin-top: 20px; }
.info-list { display: grid; grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr); gap: 10px 14px; margin: 0; }
.info-list dt { color: var(--muted); font-weight: 700; }
.info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.empty-inline { color: var(--muted); background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 14px; padding: 16px; margin: 0; }
.muted-small { color: var(--muted); font-size: 12px; }
.compact-title { margin-top: 8px; margin-bottom: 0; }
.compact-title h2 { font-size: 16px; }
.status.discovered, .status.connected { background: #dcfce7; color: #166534; }
.status.lost { background: #fee2e2; color: #991b1b; }
.status.ignored { background: #e5e7eb; color: #374151; }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { min-width: 160px; }
button.small, .small { padding: 8px 10px; font-size: 0.85rem; }
button.danger, .danger { background: #b42318; color: #fff; border: 1px solid #b42318; }
button.danger:hover, .danger:hover { background: #912018; }
.muted-small { color: #667085; font-size: 0.85rem; }

.token-card { margin-bottom: 20px; border-color: #93c5fd; background: #eff6ff; }
.token-code { display: block; font-size: 15px; padding: 14px; overflow-wrap: anywhere; }
.left-actions { justify-content: flex-start; margin-top: 16px; }
.wrap-form { flex-wrap: wrap; }
.wrap-form select { width: auto; min-width: 150px; }
.mini-check { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.mini-check input { width: auto; }
.one-col { grid-column: span 1; }
.top-gap { margin-top: 8px; }
.danger-zone { border-color: #fecaca; }
.read-only-settings { grid-column: span 2; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }

.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}
.filter-actions {
  grid-column: span 4;
  justify-content: flex-start;
}
.nowrap { white-space: nowrap; }
.json-block {
  max-width: 620px;
  max-height: 220px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
}
details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}
@media (max-width: 960px) {
  .filter-form { grid-template-columns: 1fr; }
  .filter-actions { grid-column: span 1; }
}
.compact-form { min-width: 260px; }
.compact-form input { padding: 8px 10px; }
.small-form { margin-top: 14px; }
.compact-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }
.status.connected { background: #dcfce7; color: #166534; }
