:root {
  color-scheme: light;
  --bg: #f6f2ec;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --text: #1d2420;
  --muted: #657069;
  --line: #ded6c9;
  --primary: #176f5d;
  --primary-hover: #105d4e;
  --accent: #b85236;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(45, 38, 28, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121512;
  --surface: #1b201c;
  --surface-strong: #232a25;
  --text: #eef3ed;
  --muted: #a8b2aa;
  --line: #394238;
  --primary: #58b99f;
  --primary-hover: #75c9b3;
  --accent: #e09a67;
  --danger: #ff8b7d;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  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 {
  cursor: pointer;
}

a {
  color: var(--primary);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(440px, 100%);
}

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

.auth-panel {
  padding: 28px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.brand-row,
.panel-heading,
.topbar-actions,
.tabs,
.profile-actions {
  display: flex;
  align-items: center;
}

.topbar,
.brand-row,
.panel-heading {
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar-actions,
.profile-actions {
  flex-wrap: wrap;
  gap: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  margin-bottom: -1px;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
}

.tab.active {
  background: var(--surface);
  border-color: var(--line);
  border-bottom-color: var(--surface);
  color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

.dense {
  gap: 12px;
}

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

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

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.danger-button {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

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

.secondary-button {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button,
.icon-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
}

.user-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.profile-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.profile-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.profile-meta,
.run-output,
.form-message {
  color: var(--muted);
  font-size: 13px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.run-output {
  white-space: pre-wrap;
}

.table-wrap {
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

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

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--danger);
}

.success {
  color: var(--primary);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .brand-row,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .tabs {
    overflow-x: auto;
  }

  h1 {
    font-size: 24px;
  }
}
