:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5e6b78;
  --line: #d9dee4;
  --accent: #006b5f;
  --accent-strong: #004e46;
  --accent-soft: #e4f3ef;
  --blue: #1f5f8b;
  --blue-soft: #e8f1fb;
  --gold: #b26a00;
  --gold-soft: #fff3d8;
  --warn: #a15400;
  --danger: #b3261e;
  --ok: #1f7a42;
  --code: #101820;
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 76px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
  line-height: 1.1;
}

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

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.nav-links a[aria-current="page"] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.auth-user-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: #f8fafb;
  font-size: 12px;
  font-weight: 800;
}

.auth-logout-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.nav-links a.feature-disabled {
  color: #9aa3ad;
  border-color: #e3e7eb;
  background: #f4f6f7;
  cursor: not-allowed;
}

.nav-links a.feature-disabled[aria-current="page"] {
  color: #6c7680;
  border-color: #d7dce1;
  background: #e9edf0;
}

.state {
  min-width: 72px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  text-align: center;
  color: var(--muted);
  background: #f8fafb;
  font-size: 13px;
  font-weight: 700;
}

.state-ok {
  color: var(--ok);
  border-color: #9fd0b2;
  background: #edf8f1;
}

.state-error {
  color: var(--danger);
  border-color: #efb8b4;
  background: #fff1ef;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.home-workspace {
  flex: 1;
  padding: 30px 24px 44px;
  background:
    linear-gradient(180deg, #edf4f2 0, rgba(237, 244, 242, 0) 310px),
    var(--bg);
}

.home-dashboard {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.home-hero {
  min-height: 230px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  align-items: end;
  gap: 28px;
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

.home-hero h2 {
  max-width: 660px;
  color: #10222d;
  font-size: 46px;
  line-height: 1;
}

.home-hero p:not(.eyebrow) {
  max-width: 640px;
  margin: 14px 0 0;
  color: #41505d;
  font-size: 16px;
}

.home-snapshot {
  display: grid;
  border: 1px solid #cfd9df;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 35px rgba(23, 32, 42, 0.08);
}

.home-snapshot div {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  border-top: 1px solid var(--line);
}

.home-snapshot div:first-child {
  border-top: 0;
}

.home-snapshot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.home-snapshot strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.hub-card {
  position: relative;
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid #cfd9df;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 22px;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(23, 32, 42, 0.06);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.hub-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 8px 0 0 8px;
  background: var(--blue);
}

.hub-card-primary::before {
  background: var(--accent);
}

.hub-card:hover {
  border-color: var(--accent);
  box-shadow: 0 18px 38px rgba(23, 32, 42, 0.11);
  transform: translateY(-2px);
}

.hub-card.feature-disabled {
  color: #7b858f;
  background: #f4f6f7;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.75);
}

.hub-card.feature-disabled:hover {
  border-color: #cfd9df;
  box-shadow: none;
  transform: none;
}

.hub-card.feature-disabled::before {
  background: #9aa3ad;
}

.hub-kicker {
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hub-card-primary .hub-kicker {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.hub-card strong {
  max-width: 420px;
  font-size: 23px;
  line-height: 1.2;
}

.hub-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.hub-card b {
  align-self: end;
  width: fit-content;
  margin-top: 14px;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.feature-status-badge {
  align-self: end;
  width: fit-content;
  border: 1px solid #d7dce1;
  border-radius: 999px;
  background: #fff;
  color: #6c7680;
  padding: 5px 9px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.sidebar,
.main-panel {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel,
.main-panel > section,
.ask-form,
.sql-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.disabled-feature-banner {
  display: grid;
  gap: 4px;
  grid-column: 1 / -1;
  border: 1px solid #d7dce1;
  border-radius: 8px;
  background: #eef1f3;
  color: #46525d;
  padding: 14px 16px;
}

.disabled-feature-banner strong {
  color: #24313c;
}

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

.panel {
  padding: 14px;
}

.panel h2,
.result-header,
.history-panel h2 {
  margin-bottom: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7f9;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.segmented button.selected {
  background: var(--accent);
  color: #fff;
}

.segmented button.feature-disabled,
button.feature-disabled {
  color: #9aa3ad;
  background: #e9edf0;
  cursor: not-allowed;
}

.meta-list {
  display: grid;
  grid-template-columns: minmax(82px, auto) minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

.meta-list dt {
  color: var(--muted);
  font-weight: 700;
}

.meta-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.schema-panel {
  flex: 1;
  min-height: 0;
}

.schema-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-workspace {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.agent-workspace {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.agent-count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.agent-count-grid div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}

.agent-count-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.agent-count-grid strong {
  font-size: 20px;
}

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

.profile-item {
  width: 100%;
  min-height: 54px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.profile-item:hover {
  border-color: var(--accent);
}

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

.table-block {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.table-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 800;
}

.schema-table-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-weight: 800;
}

.schema-table-button:hover {
  color: var(--accent);
}

.columns {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.columns li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ask-form,
.sql-form {
  padding: 16px;
}

.profile-form {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.connection-path-grid {
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr) minmax(160px, auto);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.check-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.form-message {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

#askButton {
  min-width: 96px;
  min-height: 40px;
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-width: 96px;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border: 1px solid #efb8b4;
  background: #fff1ef;
  color: var(--danger);
}

#askButton:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.feature-disabled-page main button:disabled,
.feature-disabled-page main input:disabled,
.feature-disabled-page main select:disabled,
.feature-disabled-page main textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.result-panel,
.history-panel {
  padding: 16px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.result-output {
  min-height: 270px;
  max-height: 54vh;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 8px;
  background: var(--code);
  color: #f1f5f9;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.result-table-wrap {
  min-height: 270px;
  max-height: 58vh;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.result-table-wrap > .muted {
  margin: 14px;
}

.result-summary {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
}

.data-table-scroller {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  max-width: 360px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th {
  position: sticky;
  top: 36px;
  background: #f2f6f8;
  color: #273541;
  font-weight: 900;
}

.data-table td {
  color: #21303d;
}

.history-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.history-button:hover strong {
  color: var(--accent);
}

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

.history-item {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.history-item strong {
  color: var(--ink);
}

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

.warn-text {
  color: var(--warn);
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, #edf4f2 0, rgba(237, 244, 242, 0) 320px),
    var(--bg);
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid #cfd9df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 44px rgba(23, 32, 42, 0.12);
  padding: 24px;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .home-workspace {
    padding: 22px 16px 34px;
  }

  .home-hero {
    min-height: 0;
    grid-template-columns: 1fr;
    align-items: start;
    padding: 18px 0;
  }

  .home-hero h2 {
    font-size: 34px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
  }

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

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

  .button-row {
    width: 100%;
    justify-content: stretch;
  }

  .button-row button {
    flex: 1;
  }
}
