:root {
  color-scheme: dark;
  --bg: #11100e;
  --panel: #1a1815;
  --panel-strong: #25211c;
  --card: #201d19;
  --input: #12110f;
  --text: #f3eee7;
  --muted: #aaa197;
  --line: #373129;
  --line-strong: #4d4439;
  --accent: #2fb984;
  --accent-dark: #24946b;
  --warn: #f5b74f;
  --error: #ff746c;
  --ok: #59d994;
  --info: #7cc7ff;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #171511;
  padding: 20px 16px;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

.brand h1,
.brand p,
.topbar h2,
.section-heading h3,
.section-heading p,
.strip-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 15px;
  line-height: 1.2;
}

.brand p,
.section-heading p,
.action-meta span {
  color: var(--muted);
  font-size: 12px;
}

.section-nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active {
  background: var(--panel-strong);
  border-color: var(--line);
}

.nav-link.active {
  border-color: rgba(89, 217, 148, 0.34);
  color: #ffffff;
}

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

.topbar {
  margin-bottom: 20px;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.15;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--ok);
  background: rgba(47, 185, 132, 0.13);
  border-color: rgba(89, 217, 148, 0.36);
}

.status-pill.warn {
  color: var(--warn);
  background: rgba(245, 183, 79, 0.13);
  border-color: rgba(245, 183, 79, 0.38);
}

.status-pill.error {
  color: var(--error);
  background: rgba(255, 116, 108, 0.12);
  border-color: rgba(255, 116, 108, 0.36);
}

.admin-views,
.admin-view {
  display: grid;
  gap: 18px;
}

.admin-view[hidden] {
  display: none;
}

.provider-strip,
.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.provider-strip {
  padding: 16px;
}

.strip-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.strip-header {
  margin-bottom: 12px;
}

.strip-header h3,
.section-heading h3 {
  font-size: 16px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.provider-card {
  display: grid;
  gap: 8px;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--card);
}

.provider-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.provider-title strong {
  font-size: 14px;
}

.provider-meta {
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.test-button,
.ghost-button,
.secondary-button,
.primary-button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 700;
}

.ghost-button,
.secondary-button,
.test-button {
  background: var(--panel-strong);
  color: var(--text);
}

.ghost-button:hover,
.secondary-button:hover,
.test-button:hover {
  border-color: var(--accent);
}

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

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

.primary-button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: #34302a;
  color: #797067;
}

.form-sections {
  display: grid;
  gap: 18px;
}

.settings-section {
  padding: 18px;
  scroll-margin-top: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  align-content: start;
}

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.field-source {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  padding: 8px 10px;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: #26231f;
  color: #82796f;
}

.field-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.field.advanced-field {
  display: none;
}

.settings-section.show-advanced .advanced-field {
  display: grid;
}

.advanced-toggle {
  justify-self: start;
  margin-top: 14px;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 268px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto) auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  border-top: 1px solid var(--line);
  background: rgba(26, 24, 21, 0.94);
  padding: 12px 28px;
  backdrop-filter: blur(12px);
}

.action-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.action-meta strong,
.action-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-area {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.message-area.error {
  color: var(--error);
}

.message-area.ok {
  color: var(--ok);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    padding-bottom: 122px;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-nav {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .main {
    padding: 18px;
  }

  .action-bar {
    left: 0;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 12px 18px;
  }

  .action-buttons {
    justify-content: stretch;
  }

  .action-buttons button {
    flex: 1;
  }
}
