:root {
  --bg: #eef2f6;
  --surface: #fff;
  --ink: #152033;
  --muted: #657184;
  --line: #d5dce7;
  --blue: #1463d9;
  --green: #16834a;
  --red: #bd3434;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.primary {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.admin-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.nav {
  padding: 22px 16px;
  color: #fff;
  background: #101827;
}

.brand {
  margin-bottom: 26px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aeb8c8;
  margin-top: 3px;
  font-size: 13px;
}

.nav-item {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  color: #cad4e3;
  border-color: transparent;
  background: transparent;
}

.nav-item.active {
  color: #fff;
  border-color: #33435d;
  background: #1e2a3d;
}

.workspace {
  padding: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

.topbar p,
label span,
.metrics span,
.facts dt {
  color: var(--muted);
}

.connection {
  display: grid;
  grid-template-columns: 220px 180px auto auto;
  gap: 8px;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.module-title {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
}

.module-title h2 {
  margin-bottom: 5px;
  font-size: 18px;
}

.module-title p {
  color: var(--muted);
  line-height: 1.55;
}

.metrics div,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metrics div {
  padding: 14px;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  gap: 14px;
}

.layout:has(.module:not(.hidden):only-child) {
  grid-template-columns: 1fr;
}

.panel {
  padding: 16px;
}

.wide {
  grid-column: 1 / -1;
}

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

.panel h2 {
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: #334155;
  background: #e8edf4;
  font-size: 12px;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 5px;
}

.code-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.code-list li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f8fafc;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-weight: 700;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.detail-box {
  min-height: 220px;
  max-height: 420px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: #263244;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.62);
  z-index: 20;
}

.manual-dialog {
  width: min(980px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.manual-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.manual-header p,
.manual-grid li {
  color: var(--muted);
  line-height: 1.65;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.manual-grid h3 {
  margin: 0 0 10px;
}

.manual-grid ol {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 920px) {
  .admin-shell,
  .layout {
    grid-template-columns: 1fr;
  }

  .nav {
    display: none;
  }

  .topbar,
  .connection {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .connection,
  .metrics,
  .split-panel,
  .manual-grid {
    grid-template-columns: 1fr;
  }

  .manual-header {
    flex-direction: column;
  }
}
