html {
  min-height: 100%;
  font-size: 16px;
}

body {
  min-height: 100%;
  margin: 0;
  background: #f2f2f2;
  color: #111111;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 18px 14px;
  background: #ececec;
  border-right: 1px solid #dedede;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 12px;
  font-size: 1.1rem;
  font-weight: 760;
}

.connection-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid #d7d7d7;
  border-radius: 999px;
  background: #f7f7f7;
  color: #4f545c;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 650;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ef4444;
}

.connection-pill.ok .status-dot {
  background: #22c55e;
}

.connection-pill.danger .status-dot {
  background: #ef4444;
}

.app-brand svg,
.nav-item svg,
.sidebar-query svg,
.header-actions svg,
.toolbar-row svg,
.alert-panel svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #343434;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.9rem;
  text-decoration: none;
}

.nav-item:hover,
.nav-item:focus {
  color: #111111;
  background: #e2e2e2;
}

.nav-item.active {
  background: #dcdcdc;
}

.sidebar-section h2 {
  margin: 0 8px 9px;
  color: #888888;
  font-size: 0.78rem;
  font-weight: 650;
}

.report-page .app-sidebar > .sidebar-section:first-of-type {
  display: none;
}

.sidebar-list {
  display: grid;
  gap: 5px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: stretch;
  gap: 3px;
}

.sidebar-query {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #2c2c2c;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.84rem;
  line-height: 1.35;
  text-decoration: none;
}

.sidebar-query svg {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  margin-top: 2px;
  color: #5f6670;
}

.sidebar-query:hover,
.sidebar-query:focus {
  background: #dedede;
}

.sidebar-more-link {
  display: inline-block;
  margin: 8px 10px 0;
  color: #424850;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-more-link:hover,
.sidebar-more-link:focus {
  color: #111111;
  text-decoration: underline;
}

.sidebar-query.recent {
  color: #4d4d4d;
}

.sidebar-query.recent svg {
  color: #7a8089;
}

.delete-query-form {
  margin: 0;
}

.delete-query-button {
  display: grid;
  width: 22px;
  height: 100%;
  min-height: 28px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8a8f98;
}

.delete-query-button:hover,
.delete-query-button:focus {
  background: #dedede;
  color: #b42318;
}

.delete-query-button svg {
  width: 12px;
  height: 12px;
}

.sidebar-empty,
.privacy-note {
  margin: 0 8px;
  color: #8a8f98;
  font-size: 0.82rem;
  line-height: 1.45;
}

.privacy-note {
  padding-top: 18px;
}

.logout-form {
  margin: -10px 0 0;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  border: 1px solid #d7d7d7;
  border-radius: 7px;
  background: #f7f7f7;
  color: #4f545c;
  padding: 7px 10px;
  font-size: 0.84rem;
  font-weight: 650;
}

.logout-button:hover,
.logout-button:focus {
  background: #dedede;
  color: #111111;
  outline: none;
}

.logout-button svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

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

.has-results .app-main {
  padding-top: 28px;
}

.workspace-panel {
  min-width: 0;
  min-height: calc(100vh - 86px);
  overflow: hidden;
  border: 1px solid #dedede;
  border-radius: 8px;
  background: #ffffff;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid #eeeeee;
}

.workspace-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 760;
}

.workspace-header p {
  margin: 5px 0 0;
  color: #6b6f76;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.primary-button {
  border: 0;
  background: #1f1f1f;
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus {
  background: #111111;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid #d8d8d8;
  background: #ffffff;
  color: #222222;
}

.secondary-button:hover,
.secondary-button:focus {
  border-color: #c9c9c9;
  background: #f7f7f7;
  color: #111111;
  text-decoration: none;
  transform: translateY(-1px);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: #b42318;
  color: #ffffff;
  padding: 8px 13px;
  font-size: 0.88rem;
  font-weight: 700;
}

.setup-warning {
  margin: 18px 24px 0;
  border: 1px solid #ead4a7;
  border-radius: 7px;
  background: #fff9ec;
  color: #7a4a0d;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.prompt-panel {
  padding: 18px 24px 22px;
}

.prompt-panel label,
.panel-heading span {
  color: #4e535a;
  font-size: 0.78rem;
  font-weight: 650;
}

.prompt-panel label {
  display: block;
  margin-bottom: 8px;
}

.prompt-panel textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border: 1px solid #d5d5d5;
  border-radius: 7px;
  background: #ffffff;
  color: #111111;
  outline: none;
  padding: 14px;
  line-height: 1.45;
}

.has-results .prompt-panel textarea {
  min-height: 68px;
}

.prompt-panel textarea:focus {
  border-color: #1f1f1f;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.prompt-options {
  display: inline-grid;
  gap: 7px;
  margin-top: 12px;
}

.prompt-options label {
  margin: 0;
}

.prompt-options select {
  min-width: 180px;
  min-height: 36px;
  border: 1px solid #d5d5d5;
  border-radius: 7px;
  background: #ffffff;
  color: #111111;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.88rem;
}

.prompt-options select:focus {
  border-color: #1f1f1f;
  outline: none;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.alert-panel {
  display: flex;
  gap: 10px;
  margin: 0 24px 18px;
  border: 1px solid #e5c3bc;
  border-radius: 7px;
  background: #fff7f5;
  color: #7f3124;
  padding: 13px 14px;
  font-size: 0.9rem;
}

.alert-panel strong,
.alert-panel span {
  display: block;
}

.alert-panel span {
  margin-top: 3px;
}

.results-shell {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 0 24px 24px;
}

.chart-panel,
.table-panel,
.sql-details {
  min-width: 0;
  border: 1px solid #dedede;
  border-radius: 7px;
  background: #ffffff;
}

.chart-panel,
.table-panel {
  padding: 15px 16px;
}

.chart-canvas-wrap {
  position: relative;
  height: 300px;
  max-height: 300px;
  overflow: hidden;
}

.chart-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 300px !important;
  max-height: 300px !important;
}

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

.panel-heading strong {
  display: block;
  margin-top: 2px;
  color: #111111;
  font-size: 0.92rem;
}

.table-responsive {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  border: 1px solid #eeeeee;
  border-radius: 7px;
}

.table-responsive.is-scrollable {
  max-height: 70vh;
  overflow-y: auto;
}

.report-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.76rem;
  table-layout: auto;
}

.report-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f7f7;
  color: #272a2f;
  font-weight: 700;
}

.sort-table-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  padding: 0;
  text-align: left;
}

.sort-table-button:hover,
.sort-table-button:focus {
  color: #111111;
  outline: none;
}

.sort-table-button svg {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  color: #8a8f98;
  stroke-width: 2;
}

.sort-table-button.active svg {
  color: #1f1f1f;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid #eeeeee;
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  min-width: 92px;
}

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

.report-table tbody tr:hover td {
  background: #f0f0f0;
}

.report-table td {
  color: #202226;
}

.report-table .row-number {
  width: 44px;
  min-width: 44px;
  color: #777b82;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: 30px;
  border: 1px dashed #d5d5d5;
  border-radius: 7px;
  color: #777b82;
  text-align: center;
}

.sql-details {
  padding: 14px 18px;
}

.sql-details summary {
  cursor: pointer;
  font-weight: 600;
}

.sql-details pre {
  margin: 12px 0 0;
  white-space: pre-wrap;
}

.schema-toolbar {
  display: grid;
  gap: 8px;
  padding: 22px 24px 16px;
  border-top: 1px solid #eeeeee;
}

.schema-toolbar label {
  color: #30343a;
  font-size: 0.78rem;
  font-weight: 700;
}

.schema-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  background: #ffffff;
  padding: 9px 13px;
}

.schema-search svg {
  width: 17px;
  height: 17px;
  color: #6f7680;
}

.schema-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
}

.schema-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 24px 16px;
}

.schema-overview div {
  border: 1px solid #dedede;
  border-radius: 7px;
  background: #fbfbfb;
  padding: 13px 15px;
}

.schema-overview span,
.schema-table-heading span {
  display: block;
  color: #767b83;
  font-size: 0.76rem;
  font-weight: 700;
}

.schema-overview strong {
  display: block;
  margin-top: 3px;
  font-size: 1.25rem;
}

.schema-content {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 0 24px 24px;
}

.schema-section-card,
.schema-table-card {
  min-width: 0;
  border: 1px solid #dedede;
  border-radius: 7px;
  background: #ffffff;
  padding: 15px 16px;
}

.schema-rule-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #30343a;
  font-size: 0.86rem;
  line-height: 1.55;
}

.schema-relations {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.schema-relation {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid #eeeeee;
  border-radius: 7px;
  background: #fbfbfb;
  padding: 9px 11px;
  font-size: 0.82rem;
}

.schema-relation svg {
  width: 14px;
  height: 14px;
  color: #7a8089;
}

.schema-relation span {
  color: #5d636c;
}

.schema-table-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.schema-table-heading strong {
  display: block;
  margin-top: 3px;
  font-size: 0.95rem;
  font-weight: 650;
}

.schema-table-heading em {
  flex: 0 0 auto;
  color: #6f7680;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 700;
}

.schema-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.schema-table th {
  background: #f7f7f7;
  color: #272a2f;
  font-weight: 700;
}

.schema-table th,
.schema-table td {
  border-bottom: 1px solid #eeeeee;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

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

.schema-table td:first-child {
  width: 220px;
}

.schema-table code,
.schema-relation code {
  color: #202226;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
}

.saved-report-list {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 0 24px 24px;
}

.saved-report-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  border: 1px solid #dedede;
  border-radius: 7px;
  background: #ffffff;
  padding: 14px 16px;
}

.saved-report-card:hover {
  background: #fbfbfb;
}

.saved-report-id {
  display: inline-block;
  margin-bottom: 5px;
  color: #747982;
  font-size: 0.76rem;
  font-weight: 800;
}

.saved-report-card h2 {
  margin: 0;
  color: #111111;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.saved-report-card p {
  margin: 6px 0 0;
  color: #6f7680;
  font-size: 0.78rem;
}

.saved-report-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.favorite-form {
  margin: 0;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #d8d8d8;
  border-radius: 7px;
  background: #ffffff;
  color: #5f6670;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.icon-button:hover,
.icon-button:focus {
  border-color: #c9c9c9;
  background: #f7f7f7;
  color: #111111;
  text-decoration: none;
  transform: translateY(-1px);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.favorite-button.active {
  border-color: #f2c94c;
  background: #fff8dd;
  color: #b58105;
}

.favorite-button.active svg {
  fill: currentColor;
}

.delete-report-button:hover,
.delete-report-button:focus {
  border-color: #ffd1cc;
  background: #fff8f7;
  color: #b42318;
}

.confirm-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(17, 17, 17, 0.28);
  padding: 20px;
}

.confirm-modal-backdrop[hidden] {
  display: none;
}

.confirm-modal {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  width: min(100%, 440px);
  border: 1px solid #dedede;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  padding: 18px;
}

.confirm-modal-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  background: #fff1f0;
  color: #b42318;
}

.confirm-modal-icon svg {
  width: 17px;
  height: 17px;
}

.confirm-modal h2 {
  margin: 0;
  font-size: 1rem;
}

.confirm-modal p {
  max-height: 84px;
  overflow: auto;
  margin: 8px 0 16px;
  color: #5f6670;
  font-size: 0.88rem;
  line-height: 1.45;
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.login-panel {
  width: min(100%, 420px);
  border: 1px solid #dedede;
  border-radius: 8px;
  background: #ffffff;
  padding: 26px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  font-size: 1.05rem;
  font-weight: 760;
}

.login-brand svg {
  width: 18px;
  height: 18px;
}

.login-heading h1 {
  margin: 0;
  font-size: 1.45rem;
}

.login-heading p {
  margin: 6px 0 0;
  color: #5f6670;
  font-size: 0.9rem;
}

.login-alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  border: 1px solid #ffd1cc;
  border-radius: 7px;
  background: #fff8f7;
  color: #9f2f24;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.login-alert svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.login-form {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.login-form label {
  margin-top: 8px;
  color: #272a2f;
  font-size: 0.82rem;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d5d5d5;
  border-radius: 7px;
  background: #ffffff;
  color: #111111;
  padding: 8px 10px;
  outline: none;
}

.login-form input:focus {
  border-color: #1f1f1f;
}

.login-form span {
  color: #b42318;
  font-size: 0.78rem;
}

.login-form .primary-button {
  justify-content: center;
  margin-top: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    min-height: auto;
  }

  .app-main {
    padding: 18px;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

}
