:root {
  --bg: #f1f1f1;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #556174;
  --line: #ccd0d4;
  --primary: #3d5afe;
  --success-bg: #d8f3dc;
  --success: #087f3f;
  --warn-bg: #fff4ce;
  --warn: #8a5a00;
}

* {
  box-sizing: border-box;
}

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

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 180px;
  background: #0f0f10;
  color: #fff;
  padding: 14px 0;
}

.sidebar-brand {
  padding: 0 14px 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.app-sidebar nav {
  display: grid;
  gap: 2px;
}

.app-sidebar a,
.menu-label {
  display: flex;
  min-height: 36px;
  align-items: center;
  padding: 0 14px;
  color: #c9c9d1;
  font-size: 14px;
  text-decoration: none;
}

.app-sidebar a.active {
  color: #fff;
  background: #3d5afe;
  font-weight: 800;
}

.app-sidebar a.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.menu-label {
  min-height: 28px;
  margin-top: 8px;
  color: #fff;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

.settings-shell {
  width: min(1240px, calc(100% - 204px));
  margin-left: 180px;
  padding: 18px 0 44px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 12px;
  margin-bottom: 28px;
  font-size: 20px;
}

p,
.section-help {
  color: var(--muted);
  line-height: 1.6;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.top-actions a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--primary);
  background: white;
  padding: 0 13px;
  font-weight: 700;
  text-decoration: none;
}

.settings-card,
.notice-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  padding: 22px;
  margin-bottom: 20px;
}

.setting-row {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}

label {
  padding-top: 8px;
  font-weight: 700;
}

input,
select {
  width: min(420px, 100%);
  min-height: 40px;
  border: 1px solid #8c8f94;
  border-radius: 0;
  background: #fff;
  padding: 8px 12px;
}

.key-line input {
  width: min(520px, 100%);
}

.show-key,
.primary-btn,
.test-actions button {
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 2px;
  color: var(--primary);
  background: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  min-width: 130px;
  color: #fff;
  background: var(--primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 3px;
  background: var(--warn-bg);
  color: var(--warn);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.status-badge.configured {
  background: var(--success-bg);
  color: var(--success);
}

.button-row {
  margin: 14px 0 26px;
}

.test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

pre {
  min-height: 90px;
  overflow: auto;
  border: 1px solid #d7dbe2;
  border-radius: 4px;
  background: #f8fafc;
  padding: 14px;
  white-space: pre-wrap;
}

.notice-card {
  display: flex;
  gap: 10px;
  background: #fff8e6;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  border-radius: 4px;
  color: white;
  background: var(--ink);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .app-sidebar {
    position: static;
    width: 100%;
  }

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

  .settings-shell {
    width: calc(100% - 20px);
    margin: 0 auto;
  }

  .topbar,
  .setting-row,
  .notice-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions,
  .test-actions {
    display: grid;
  }

  .top-actions a,
  .test-actions button,
  .primary-btn,
  .show-key {
    width: 100%;
  }
}
