:root {
  --bg: #eef2f7;
  --sidebar: #101827;
  --sidebar-soft: #172237;
  --panel: #ffffff;
  --text: #111827;
  --muted: #647084;
  --line: #d8dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
}

h1, h2, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 16px; letter-spacing: 0; }
p { margin-top: 4px; color: var(--muted); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #e5e7eb;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 20px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
}

.brand strong { display: block; font-size: 20px; }
.brand small { display: block; color: #9ca3af; font-weight: 700; text-transform: uppercase; font-size: 11px; }

.nav {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px 8px 4px;
  color: #9ca3af;
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.api-link,
button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sidebar .api-link {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--sidebar-soft);
  color: #e5e7eb;
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: minmax(420px, 620px) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.api-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.setup-panel {
  margin-top: 16px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 { margin-bottom: 0; }

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 0 0 16px;
}

legend {
  color: var(--muted);
  font-weight: 700;
  padding: 0 6px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

input[readonly] {
  background: #f8fafc;
  color: #243044;
  font-family: Consolas, monospace;
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--primary);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.lookup-row label {
  margin-bottom: 0;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}

.checks input { width: auto; }

.secondary:hover,
.small-button:hover { border-color: var(--primary); }

.compact-button {
  padding: 8px 10px;
  white-space: nowrap;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary:hover { background: #0b5f59; }

.status {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--muted);
  background: #fbfcfd;
}

.inline-status {
  margin: 0;
  min-width: 220px;
}

.status.error { color: var(--danger); }

.field-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-status.active { color: var(--accent); }

.compact-status {
  margin: 12px 0 0;
}

pre {
  min-height: 420px;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #111827;
  color: #e8eef8;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1060px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

tr:last-child td { border-bottom: 0; }

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fafc;
}

td span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

td code {
  font-family: Consolas, monospace;
  font-size: 12px;
  color: #243044;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok { background: #dff7ed; color: #0b5f59; }
.badge.off { background: #fde8e6; color: var(--danger); }

.page-pill {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 6px;
  border-radius: 6px;
  background: #eef2f7;
  color: #243044;
  font-size: 11px;
  font-weight: 700;
}

.table-actions {
  display: grid;
  gap: 6px;
  align-items: start;
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.table-action:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.table-action:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.table-action-muted {
  color: #475569;
}

.table-action-link {
  color: #0f766e;
}

.table-action-link:hover {
  border-color: rgba(15, 118, 110, .45);
  background: #ecfdf5;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.setup-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.setup-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.setup-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.setup-steps div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.setup-steps span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dff7ed;
  color: #0b5f59;
  font-weight: 900;
}

.setup-steps small {
  color: var(--muted);
  line-height: 1.35;
}

.setup-output {
  min-height: 260px;
}

.setup-link-panel {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  background: #fff;
}

.setup-link-panel span,
.setup-link-panel small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.setup-link-panel a {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 800;
  color: var(--primary);
}

.setup-link-panel img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.local-installations {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.compact-title {
  margin-bottom: 10px;
}

.compact-title h3 {
  margin: 0;
  font-size: 16px;
}

.installations-list {
  display: grid;
  gap: 8px;
}

.installation-card {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.installation-card span,
.installation-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.installation-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.advanced-block {
  margin-top: 8px;
}

.advanced-block summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
}

.table-action-muted:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.table-action-danger {
  color: var(--danger);
}

.table-action-danger:hover {
  border-color: rgba(180, 35, 24, .45);
  background: #fff1f0;
}

.selection-pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.readonly-grid > div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.readonly-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.readonly-grid strong,
.readonly-grid code {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.endpoint-box {
  display: inline-block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-family: Consolas, monospace;
  font-weight: 700;
}

.api-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.api-list div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.api-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.api-list dt { color: var(--muted); font-weight: 700; }
.api-list dd { margin: 0; overflow-wrap: anywhere; }
.api-list a { color: var(--primary); font-weight: 700; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar-footer { grid-template-columns: 1fr 1fr; align-items: center; }
  .grid,
  .api-grid,
  .metrics,
  .setup-grid,
  .setup-steps { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .main { padding: 14px; }
  .topbar,
  .panel-title { align-items: flex-start; flex-direction: column; }
  .row,
  .lookup-row,
  .checks,
  .nav { grid-template-columns: 1fr; }
  .inline-status { width: 100%; min-width: 0; }
  .api-list div { grid-template-columns: 1fr; }
}
