:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #212a35;
  --surface-3: #0f151d;
  --text: #edf2f7;
  --muted: #9ba7b4;
  --line: #2b3542;
  --accent: #2fbf8f;
  --accent-strong: #249873;
  --amber: #f0b84b;
  --red: #f06b61;
  --blue: #67a9e8;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
}

button:hover {
  border-color: #4a5969;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

button.primary:hover {
  background: var(--accent-strong);
}

button.danger {
  color: var(--red);
}

button.link {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  padding: 9px 10px;
}

input::placeholder,
textarea::placeholder {
  color: #758293;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

td code {
  overflow-wrap: anywhere;
}

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

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, 0.94);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 14px 20px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tabs button {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
}

.tabs button.active {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.page {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px 20px 48px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.stat b {
  display: block;
  font-size: 24px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.panel-header,
.panel-body {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

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

.form-grid {
  display: grid;
  gap: 12px;
}

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

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar input {
  max-width: 360px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: rgba(47, 191, 143, 0.16);
  color: #73e0bd;
}

.badge.warn {
  background: rgba(240, 184, 75, 0.16);
  color: var(--amber);
}

.badge.bad {
  background: rgba(240, 107, 97, 0.16);
  color: var(--red);
}

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

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  padding: 10px;
}

.list-row.active {
  border-color: var(--accent);
}

.muted {
  color: var(--muted);
}

.status-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

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

.kv {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  padding: 12px;
}

.kv b {
  display: block;
  margin-bottom: 6px;
}

.kv code {
  overflow-wrap: anywhere;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 16px;
}

.qr-box img {
  width: min(260px, 100%);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

@media (max-width: 920px) {
  .header-inner,
  .grid,
  .settings-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .header-inner {
    display: grid;
  }

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