:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d8dee7;
  --line-strong: #b8c2d0;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #202938;
  color: #eef2ff;
  padding: 18px 12px;
}

.brand {
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 14px;
}

.brand strong {
  display: block;
  font-size: 22px;
}

.brand span {
  display: block;
  color: #b6c2d5;
  font-size: 13px;
  margin-top: 4px;
}

.nav {
  width: 100%;
  min-height: 40px;
  margin-bottom: 8px;
  padding: 0 12px;
  text-align: left;
  color: #e5e7eb;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.nav:hover,
.nav.active {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.16);
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.token-input {
  width: 220px;
}

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

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

.metrics div {
  min-height: 86px;
  display: grid;
  align-content: center;
  padding: 14px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 30px;
  line-height: 1.1;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
}

.panel {
  padding: 16px;
}

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

h2 {
  margin: 0;
  font-size: 18px;
}

.table-wrap {
  overflow: auto;
}

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

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

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

tr.selected td {
  background: #eff6ff;
}

code {
  font-family: Consolas, "Cascadia Mono", monospace;
}

.endpoint {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.btn {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--primary);
}

.btn.primary {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary-dark);
  font-weight: 700;
}

.btn.danger {
  color: var(--danger);
  background: #fff7f7;
  border-color: #fecaca;
}

.btn.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.active {
  color: var(--ok);
  background: var(--ok-bg);
}

.pill.paused {
  color: var(--warn);
  background: var(--warn-bg);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  color: #334155;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.alert.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: #bbf7d0;
}

.alert.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecaca;
}

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 16px;
}

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

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

  .brand {
    width: 100%;
    margin-bottom: 4px;
  }

  .nav {
    width: auto;
    margin: 0;
  }

  .content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 12px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .token-input,
  .top-actions .btn {
    width: 100%;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
