:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #20231f;
  --muted: #667066;
  --line: #dfe5da;
  --surface: #ffffff;
  --soft: #eef3ed;
  --accent: #2f7d64;
  --accent-strong: #1f5f4a;
  --accent-hover: #256b55;
  --button-ink: #ffffff;
  --topbar-bg: rgba(246, 247, 244, 0.94);
  --input-bg: #ffffff;
  --table-head: #fbfcfa;
  --danger-soft: #fff6ef;
  --warn: #9b4a2e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101411;
    --ink: #edf2eb;
    --muted: #a2afa3;
    --line: #29342c;
    --surface: #161d18;
    --soft: #1d2a22;
    --accent: #64b895;
    --accent-strong: #8bd4b4;
    --accent-hover: #78c9a8;
    --button-ink: #0d1711;
    --topbar-bg: rgba(16, 20, 17, 0.92);
    --input-bg: #111813;
    --table-head: #121914;
    --danger-soft: #2a1b15;
    --warn: #e49a76;
  }
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

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

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  border-radius: 6px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted,
.empty {
  color: var(--muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.user-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.user-chip a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 38px 24px 70px;
}

.workspace.wide {
  max-width: 1480px;
}

.login-shell {
  min-height: calc(100svh - 140px);
  display: grid;
  grid-template-columns: minmax(300px, 560px) minmax(260px, 1fr);
  gap: 48px;
  align-items: stretch;
}

.login-panel {
  align-self: center;
  max-width: 560px;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 23px;
}

h3 {
  margin-top: 22px;
  font-size: 16px;
}

.lead {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
  max-width: 520px;
  margin: 22px 0 28px;
}

.primary-action,
.secondary-action,
button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: var(--button-ink);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.primary-action:hover,
.secondary-action:hover,
button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(20, 35, 28, 0.12);
}

.secondary-action {
  background: var(--ink);
  color: var(--surface);
}

.secondary-action:hover {
  background: var(--accent-strong);
  color: var(--button-ink);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--ink);
}

.table-link {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.table-link:hover {
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  transform: none;
}

.alert,
.setup-box {
  border-left: 4px solid var(--warn);
  background: var(--danger-soft);
  padding: 14px 16px;
  margin: 18px 0;
}

.login-context {
  min-height: 420px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(160deg, rgba(32, 35, 31, 0.12), rgba(47, 125, 100, 0.2)),
    repeating-linear-gradient(90deg, rgba(32, 35, 31, 0.08) 0 1px, transparent 1px 82px),
    repeating-linear-gradient(0deg, rgba(32, 35, 31, 0.06) 0 1px, transparent 1px 52px),
    #e6ece3;
  border-radius: 8px;
}

.login-context span {
  color: var(--accent-strong);
  font-weight: 800;
}

.login-context strong {
  max-width: 420px;
  margin-top: 8px;
  font-size: 38px;
  line-height: 1;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
}

.page-head.compact h1 {
  font-size: 44px;
}

.head-actions,
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.tab {
  min-height: 46px;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: 3px solid transparent;
  padding: 6px 10px 7px;
}

.tab:hover {
  background: var(--soft);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}

.tab.active {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--surface);
}

.tab small {
  min-width: 26px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.metrics div {
  padding: 16px 20px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

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

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.tool-row {
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.split-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(390px, 0.9fr);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.list-column {
  min-width: 0;
  min-height: 0;
}

.table-surface,
.inspector {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-surface {
  max-height: calc(100svh - 250px);
  overflow: auto;
}

.inspector {
  padding: 20px;
  position: sticky;
  top: 86px;
  max-height: calc(100svh - 106px);
  overflow: auto;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: var(--table-head);
  position: sticky;
  top: 0;
  z-index: 1;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

tr[data-select-kind] {
  cursor: pointer;
}

tr[data-select-kind]:hover {
  background: var(--soft);
}

dl {
  margin: 14px 0 0;
}

dl div {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.plain-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.modal {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100svh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
}

.modal::backdrop {
  background: rgba(32, 35, 31, 0.35);
}

.modal form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 22px;
}

.modal-head,
.full {
  grid-column: 1 / -1;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.field-grid {
  display: contents;
}

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

label input,
label select,
label textarea {
  margin-top: 7px;
}

@media (max-width: 980px) {
  .topbar {
    padding: 0 16px;
  }

  .workspace {
    padding-inline: 16px;
  }

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

  .inspector {
    position: static;
    max-height: none;
  }

  .table-surface {
    max-height: none;
  }

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

  .metrics div:nth-child(2) {
    border-right: 0;
  }

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

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
