@import url("./studio-tokens.css");
:root {
  --bg: hsl(var(--background-default));
  --surface: hsl(var(--background-surface-75));
  --raised: hsl(var(--background-surface-100));
  --muted-bg: hsl(var(--background-surface-200));
  --fg: hsl(var(--foreground-default));
  --secondary: hsl(var(--foreground-light));
  --muted: hsl(var(--foreground-lighter));
  --line: hsl(var(--border-default));
  --strong-line: hsl(var(--border-strong));
  --accent: hsl(var(--brand-default));
  --accent-link: hsl(var(--brand-link));
  --accent-soft: hsl(var(--brand-200));
  --danger: #db3d42;
  --mono: Consolas, "Liberation Mono", monospace;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    12px/1.7 Tahoma,
    Arial,
    system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea {
  outline-offset: 2px;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  padding: 4px 10px;
  box-shadow: 0 1px 2px #00000008;
  transition: none;
}
button:hover {
  background: var(--muted-bg);
  border-color: hsl(var(--border-stronger));
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent-link);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button svg {
  flex-shrink: 0;
}
.primary {
  background: hsl(var(--brand-button));
  border-color: hsl(var(--brand-button));
  color: white;
  box-shadow: inset 0 1px 0 #ffffff20;
}
.primary:hover {
  background: hsl(var(--brand-button) / 0.9);
  border-color: hsl(var(--brand-button));
}
.danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--line);
}
.danger:hover {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: var(--danger);
}
input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  padding: 6px 9px;
  max-width: 100%;
}
input:not([type="checkbox"]),
select {
  min-height: 32px;
}
input:disabled,
textarea:disabled {
  opacity: 0.55;
}
textarea {
  width: 100%;
  resize: vertical;
}
input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: hsl(var(--brand-button));
  vertical-align: middle;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}
a {
  color: var(--accent-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
p {
  margin: 0 0 12px;
}
h1 {
  font-size: 20px;
  font-weight: 600;
}
h2 {
  font-size: 17px;
  font-weight: 600;
}
h3 {
  font-size: 13px;
  font-weight: 600;
}
small,
.small {
  font-size: 11px;
}
.muted {
  color: var(--muted);
}
.shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: hsl(var(--background-dash-sidebar));
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 14px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  min-width: 0;
}
.brand {
  height: 49px;
  display: flex;
  align-items: center;
  direction: ltr;
  justify-content: flex-end;
  font:
    700 17px/1 system-ui,
    sans-serif;
  letter-spacing: -0.7px;
  border-bottom: 1px solid var(--line);
  margin: 0 -12px;
  padding: 0 14px;
  gap: 3px;
  color: var(--fg);
}
.brand:before {
  content: "";
  display: block;
  width: 13px;
  height: 18px;
  background: var(--accent);
  clip-path: polygon(55% 0, 0 58%, 44% 58%, 39% 100%, 100% 36%, 57% 36%);
  margin-right: 5px;
}
.brand span {
  color: var(--fg);
}
.sidebar-caption {
  color: var(--muted);
  font-size: 10px;
  padding-top: 2px;
}
.sidebar > label {
  margin: 0;
}
.sidebar select {
  width: 100%;
  background: var(--bg);
}
.sidebar > .primary {
  width: 100%;
  margin-bottom: 5px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.nav :is(button, a) {
  justify-content: flex-start;
  text-align: right;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--secondary);
  padding: 7px 8px;
  white-space: nowrap;
}
.nav :is(button, a):hover {
  background: var(--muted-bg);
  color: var(--fg);
}
.nav :is(button, a).active {
  background: hsl(var(--background-selection));
  color: var(--fg);
  border-color: transparent;
}
.nav :is(button, a).active svg {
  color: var(--accent-link);
}
.sidebar footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}
.sidebar footer button {
  margin-top: 8px;
  min-height: 25px;
  padding: 2px 7px;
  font-size: 10px;
}
.sidebar footer button + button {
  margin-right: 5px;
}
.main {
  display: grid;
  grid-template-rows: 49px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  max-width: none;
}
.topbar,
.toolbar,
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 0 20px;
  margin: 0;
  min-width: 0;
  gap: 10px;
}
.topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar h1 {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}
.topbar p {
  font-size: 10px;
  direction: ltr;
  margin: 0;
  line-height: 1.3;
  color: var(--muted);
}
.topbar > div:first-child > p:after {
  content: "/";
  margin: 0 10px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle {
  min-height: 28px;
  font-size: 10px;
  white-space: nowrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--secondary);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.8;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-name:before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-link);
}
#view {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}
.shell[data-section="tables"] #view,
.shell[data-section="storage"] #view {
  padding: 0;
}
.shell[data-section="sql"] #view {
  padding: 0 16px 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 18px;
  min-width: 0;
}
.card:last-child {
  margin-bottom: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.metric {
  font: 500 28px/1.4 system-ui;
  color: var(--fg);
  margin-bottom: 5px;
}
.toolbar {
  margin-bottom: 12px;
}
.spacer {
  flex: 1;
}
.ltr {
  direction: ltr;
  text-align: left;
}
.code {
  font: 12px/1.8 var(--mono);
  direction: ltr;
  text-align: left;
  tab-size: 2;
  white-space: pre;
  min-height: 260px;
  background: var(--bg);
  color: var(--fg);
  padding: 14px 16px;
  outline-offset: -2px;
}
.code.connection-origins {
  min-height: 0;
  padding-block: 8px;
  resize: none;
}
.result {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 480px;
  background: var(--bg);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: 12px/1.7 var(--mono);
}
.table-wrap {
  overflow: auto;
  max-height: 65vh;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  direction: ltr;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
  direction: ltr;
  font-size: 12px;
}
th {
  background: var(--muted-bg);
  color: var(--fg);
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 500;
}
td,
th {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: 0;
}
td:last-child,
th:last-child {
  border-right: 0;
}
tbody tr:hover {
  background: hsl(var(--background-overlay-hover));
}
td button {
  font-size: 10px;
  min-height: 23px;
  padding: 1px 6px;
  margin: 0 3px;
  box-shadow: none;
}
.login {
  max-width: 410px;
  margin: 12vh auto;
  padding: 28px;
  box-shadow: 0 8px 40px #00000008;
}
.login .brand {
  height: 45px;
  border: 0;
  margin: 0 0 16px;
  padding: 0;
  justify-content: flex-start;
}
.login input,
.login .primary {
  width: 100%;
}
.login .primary {
  margin-top: 10px;
}
.error {
  color: var(--danger);
  white-space: pre-wrap;
}
.empty {
  padding: 38px 20px;
  text-align: center;
  color: var(--muted);
}
.tabs {
  display: flex;
  gap: 4px;
  overflow: auto;
  margin-bottom: 12px;
  direction: ltr;
}
.tabs .active {
  border-color: var(--accent-link);
  color: var(--accent-link);
}
.file-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  direction: ltr;
}
.file-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.file-list button {
  text-align: left;
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-list button.active {
  border-color: var(--accent-link);
  color: var(--accent-link);
  background: var(--accent-soft);
}
.callout {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-right: 3px solid var(--accent-link);
  background: var(--accent-soft);
  color: var(--secondary);
  margin: 14px 0;
  border-radius: 4px;
}
.warning {
  border-right-color: #d9941c;
  background: color-mix(in srgb, #e5a520 7%, var(--surface));
  color: var(--secondary);
}
.key {
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  direction: ltr;
  user-select: all;
  font: 12px/1.8 var(--mono);
}
.project-card h3 {
  margin-bottom: 5px;
}
.project-card .primary {
  margin-top: 12px;
}
#toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--raised);
  color: var(--fg);
  padding: 12px 18px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  box-shadow: 0 6px 25px #0002;
  z-index: 600;
  display: none;
  white-space: pre-wrap;
}
#toast.error {
  border-color: var(--danger);
  color: var(--danger);
}
dialog {
  background: hsl(var(--background-dialog-default));
  color: var(--fg);
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 24px;
  width: min(740px, 95vw);
  max-height: 90vh;
  box-shadow: 0 20px 80px #0003;
}
dialog::backdrop {
  background: #0006;
  backdrop-filter: blur(2px);
}
dialog.confirmation {
  width: min(540px, 95vw);
}
.close {
  float: left;
  min-height: 24px;
  padding: 0 7px;
  font-size: 20px;
  line-height: 1.1;
  background: transparent;
  border: 0;
  color: var(--muted);
  box-shadow: none;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.dialog-feedback {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.9;
  outline-offset: 2px;
}
.dialog-feedback.error {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.dialog-feedback[hidden] {
  display: none;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}
.filter-chip {
  background: var(--muted-bg);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
}
.wide {
  width: 100%;
}
.loading {
  opacity: 0.55;
  pointer-events: none;
}
.logs pre {
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
}
.check {
  display: flex;
  align-items: center;
  gap: 7px;
}
.inline {
  display: inline-flex;
  margin: 0;
}
.nowrap {
  white-space: nowrap;
}
/* Flat workspaces mirror Studio's explorer / tabs / toolbar / canvas structure. */
.resource-layout {
  display: grid;
  grid-template-columns: 215px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: 100%;
  min-width: 0;
}
.resource-explorer {
  position: sticky;
  top: 0;
  align-self: start;
  height: calc(100vh - 49px);
  background: hsl(var(--background-dash-sidebar));
  border-left: 1px solid var(--line);
  padding: 0 12px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.resource-explorer h3 {
  font-size: 13px;
  margin: 0 -12px 2px;
  padding: 13px 16px;
  height: 44px;
  border-bottom: 1px solid var(--line);
}
.resource-explorer input {
  width: 100%;
  min-width: 0;
  font-size: 11px;
}
.resource-explorer > .primary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--line);
  justify-content: flex-start;
}
.resource-explorer > .primary:hover {
  background: var(--muted-bg);
}
.explorer-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 50px;
  margin: 0 -5px;
}
.explorer-list :is(button, a) {
  text-align: left;
  justify-content: flex-start;
  direction: ltr;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  border-radius: 3px;
  min-height: 31px;
  padding: 4px 10px;
  font-size: 12px;
}
.explorer-list :is(button, a):before {
  content: "";
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  flex-shrink: 0;
  background:
    linear-gradient(
      to bottom,
      transparent 30%,
      currentColor 30%,
      currentColor 38%,
      transparent 38%
    ),
    linear-gradient(
      to right,
      transparent 32%,
      currentColor 32%,
      currentColor 40%,
      transparent 40%
    );
  color: var(--muted);
  margin-right: 6px;
}
.explorer-list :is(button, a).active,
.storage-entry.active {
  background: hsl(var(--background-selection));
  border-color: transparent;
  color: var(--fg);
}
.explorer-list :is(button, a).active:before {
  color: var(--accent-link);
}
.resource-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 49px);
}
.resource-content > .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
  background: var(--bg);
}
.resource-content > .card > .toolbar {
  margin: 0;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  gap: 6px;
}
.resource-content > .card > .toolbar:empty {
  display: none;
}
.resource-content .toolbar button,
.resource-content .toolbar input,
.resource-content .toolbar select {
  min-height: 28px;
  font-size: 11px;
  padding: 3px 8px;
}
.resource-content .toolbar > strong {
  font-size: 11px;
  font-weight: 500;
}
.resource-content .toolbar .check {
  margin: 0;
}
.workspace-tabs {
  display: flex;
  gap: 0;
  overflow: auto;
  direction: ltr;
  margin: 0;
  min-width: 0;
  padding: 0;
  min-height: 42px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.workspace-tab {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  position: relative;
}
.workspace-tab.active {
  background: var(--bg);
}
.workspace-tab.active:before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent-link);
}
.workspace-tab :is(button, a) {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  white-space: nowrap;
  min-height: 41px;
  padding: 8px 13px;
  font-size: 11px;
  color: var(--secondary);
}
.workspace-tab .tab-close {
  color: var(--muted);
  padding: 5px 9px;
}
.workspace-tab.active .table-tab,
.workspace-tab.active .query-tab {
  color: var(--fg);
}
.workspace-tabs > button {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 11px;
  background: transparent;
  color: var(--secondary);
}
.data-grid {
  max-height: calc(100vh - 270px);
  min-height: 220px;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  flex: 1;
}
.data-grid table {
  min-width: 100%;
  width: max-content;
}
.data-grid th {
  min-width: 155px;
  height: 43px;
  background: var(--muted-bg);
  padding: 5px 12px;
}
.data-grid th small {
  display: inline;
  font-size: 10px;
  font-weight: 400;
  margin-left: 6px;
}
.data-grid th > div {
  display: inline;
}
.data-grid td {
  height: 35px;
  padding: 4px 12px;
  max-width: 360px;
}
.data-grid .row-actions {
  white-space: nowrap;
  min-width: 82px;
  width: 82px;
  padding: 4px 6px;
  color: var(--muted);
}
.data-grid .row-actions-heading {
  width: 82px;
  min-width: 82px;
}
.row-actions-content {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  width: max-content;
}
.row-actions-content .row-number,
.row-actions-content .row-icon {
  flex: none;
}
.row-actions .row-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  margin-inline-start: 3px;
  font-size: 18px;
  line-height: 1;
  border-color: transparent;
  background: transparent;
}
.row-actions .row-delete {
  color: #dc2626;
}
.editable-cell {
  cursor: pointer;
  min-width: 155px;
  max-width: 360px;
}
.editable-cell:hover,
.editable-cell:focus {
  background: var(--accent-soft);
  outline: 1px solid var(--accent-link);
  outline-offset: -1px;
}
.generated-cell {
  color: var(--secondary);
}
.null-value {
  font-style: italic;
  color: var(--muted);
  font-size: 10px;
}
.table-definition {
  margin: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.table-definition summary {
  cursor: pointer;
  color: var(--secondary);
  padding: 8px 14px;
  font-size: 11px;
}
.table-definition .table-wrap {
  margin: 0 12px 12px;
}
.cell-menu {
  position: fixed;
  z-index: 500;
  background: var(--raised);
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  box-shadow: 0 6px 30px #0002;
  display: flex;
  flex-direction: column;
  padding: 4px;
  min-width: 215px;
  max-width: 95vw;
}
.cell-menu button {
  border: 0;
  box-shadow: none;
  background: transparent;
  text-align: right;
  justify-content: flex-start;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 3px;
}
.cell-menu button:hover {
  background: var(--muted-bg);
}
.pagination {
  border-top: 1px solid var(--line);
  background: var(--surface);
  margin-top: auto !important;
}
.resource-content > .card > .empty {
  flex: 1;
  min-height: 130px;
}
.resource-content > .card > label {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.resource-content > .card > .breadcrumbs {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 43px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  direction: ltr;
  gap: 2px;
}
.breadcrumbs button {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 3px 7px;
  min-height: 26px;
  font-size: 11px;
}
.breadcrumbs button + button:before {
  content: "/";
  margin-right: 9px;
  color: var(--muted);
}
.storage-browser {
  display: grid;
  grid-template-columns: minmax(180px, 0.85fr) minmax(280px, 1.15fr);
  gap: 0;
  min-height: 490px;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  direction: ltr;
  flex: 1;
}
.storage-browser > section {
  min-width: 0;
  padding: 10px;
  direction: rtl;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.storage-browser > section > input {
  width: 100%;
  min-height: 29px;
  font-size: 11px;
}
.storage-files {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
  overflow: auto;
  gap: 0;
  margin-top: 8px;
}
.storage-entry {
  flex-shrink: 0;
  text-align: left;
  justify-content: flex-start;
  direction: ltr;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  min-height: 35px;
  font-size: 12px;
}
.folder-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.folder-entry button:first-child {
  flex: 1;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.folder-entry > .danger {
  opacity: 0.4;
  min-height: 24px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.folder-entry:hover > .danger {
  opacity: 1;
}
.file-details {
  direction: rtl;
  padding: 20px;
  min-width: 0;
  background: var(--bg);
  overflow-wrap: anywhere;
}
.file-preview {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: contain;
  background: repeating-conic-gradient(
      var(--surface) 0% 25%,
      var(--muted-bg) 0% 50%
    )
    50%/20px 20px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 0;
}
.file-details audio {
  width: 100%;
}
.file-icon {
  font-size: 60px;
  text-align: center;
  padding: 45px;
}
.file-details h3 {
  word-break: break-word;
  font-size: 14px;
}
.file-details .toolbar {
  margin-top: 16px;
}
.file-url {
  font: 11px/1.8 var(--mono);
  user-select: all;
  min-width: 0;
  background: var(--surface);
}
.result-tabs {
  min-height: 34px;
  margin: -20px -20px 12px;
}
.result-tabs button {
  min-height: 33px;
  font-size: 11px;
  border-right: 1px solid var(--line);
}
.result-tabs .active {
  color: var(--accent-link);
  box-shadow: inset 0 -2px var(--accent-link);
}
.sql-error {
  white-space: pre-wrap;
}
.shell[data-section="sql"] #view > .workspace-tabs {
  margin: 0 -16px 0;
}
.shell[data-section="sql"] #view > .card {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0 -16px;
  padding: 12px 16px;
}
.shell[data-section="sql"] .code {
  border: 0;
  min-height: 360px;
  max-height: 60vh;
  background: var(--bg);
  padding: 12px 16px;
}
.shell[data-section="sql"] .result-tabs {
  margin: -12px -16px 12px;
}
.shell[data-section="sql"] #view > .card > .toolbar {
  margin: 0;
  padding: 0 0 10px;
}
.shell[data-section="sql"] #view > .card > .small {
  margin: 0;
  font-size: 10px;
}
.loading {
  pointer-events: none;
}
.drop-overlay {
  display: none;
}
.storage-browser.drop-active {
  outline: 2px dashed var(--accent-link);
  outline-offset: -4px;
  background: var(--accent-soft);
}
.storage-browser.drop-active .drop-overlay {
  display: flex;
}
.storage-entry.drop-target {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent-link);
  outline-offset: -2px;
}
.breadcrumbs .drop-target {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent-link);
  outline-offset: -2px;
}
.storage-entry.is-dragging {
  opacity: 0.45;
}
.upload-status {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  color: var(--secondary);
  font-size: 11px;
}
.upload-status progress {
  width: 100%;
  height: 5px;
  accent-color: var(--accent-link);
}
.drop-hint {
  font-size: 10px;
  color: var(--muted);
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.upload-drop-zone {
  position: relative;
}
.drop-overlay {
  position: absolute;
  inset: 4px;
  z-index: 4;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
  color: var(--accent-link);
  border: 1px dashed var(--accent-link);
  pointer-events: none;
  font-size: 14px;
}
.drop-overlay strong {
  max-width: 95%;
  overflow-wrap: anywhere;
  font: 12px var(--mono);
}
@media (min-width: 1600px) {
  .shell {
    grid-template-columns: 205px minmax(0, 1fr);
  }
  .resource-layout {
    grid-template-columns: 245px minmax(0, 1fr);
  }
}
@media (max-width: 1050px) {
  .shell {
    grid-template-columns: 170px minmax(0, 1fr);
  }
  .resource-layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }
  .topbar {
    padding: 0 12px;
  }
  .topbar p {
    display: none;
  }
  .header-actions {
    gap: 6px;
  }
  .storage-browser {
    grid-template-columns: minmax(0, 1fr);
  }
  .storage-browser > section {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .storage-files {
    max-height: 300px;
  }
  .file-preview {
    height: 230px;
  }
  .file-details {
    padding: 16px;
  }
  .file-layout {
    grid-template-columns: 150px minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    height: auto;
    position: static;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 12px 8px;
    gap: 8px;
    overflow: visible;
  }
  .brand {
    height: 40px;
    font-size: 16px;
  }
  .sidebar-caption,
  .sidebar footer {
    display: none;
  }
  .sidebar > label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
  }
  .sidebar select {
    width: 65%;
    max-width: 300px;
  }
  .sidebar > .primary {
    align-self: flex-start;
    width: auto;
    position: absolute;
    top: 7px;
    left: 12px;
    min-height: 25px;
    font-size: 10px;
    margin: 0;
  }
  .nav {
    flex-direction: row;
    overflow: auto;
    gap: 3px;
  }
  .nav :is(button, a) {
    flex-shrink: 0;
    padding: 5px 8px;
    font-size: 11px;
  }
  .nav :is(button, a) svg {
    width: 14px;
    height: 14px;
  }
  .main {
    height: auto;
    min-height: calc(100vh - 150px);
    overflow: visible;
    grid-template-rows: 44px minmax(0, 1fr);
  }
  .topbar {
    padding: 0 12px;
    gap: 5px;
  }
  .topbar h1 {
    font-size: 12px;
  }
  .project-name {
    max-width: 100px;
    font-size: 9px;
  }
  .theme-toggle {
    font-size: 9px;
    min-height: 26px;
    padding: 3px 6px;
  }
  .theme-toggle svg {
    width: 13px;
  }
  #view {
    padding: 14px;
    overflow: visible;
  }
  .resource-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .resource-explorer {
    position: static;
    height: auto;
    max-height: 210px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 12px 10px;
    gap: 7px;
  }
  .resource-explorer h3 {
    height: 35px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .resource-explorer > .primary {
    position: absolute;
    left: 12px;
    margin-top: 5px;
    min-height: 24px;
    font-size: 10px;
  }
  .explorer-list {
    max-height: 100px;
    min-height: 0;
  }
  .explorer-list :is(button, a) {
    min-height: 28px;
    padding: 3px 8px;
    font-size: 11px;
  }
  .resource-content {
    min-height: 0;
  }
  .data-grid {
    max-height: 65vh;
    min-height: 180px;
  }
  .workspace-tabs {
    min-height: 37px;
    max-width: 100%;
  }
  .workspace-tab :is(button, a) {
    min-height: 36px;
    padding: 5px 10px;
  }
  .resource-content .toolbar {
    flex-wrap: wrap;
  }
  .resource-content .toolbar input {
    max-width: 150px;
  }
  .resource-content .toolbar .spacer {
    display: none;
  }
  .file-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .file-list {
    flex-direction: row;
    overflow: auto;
  }
  .file-list button {
    flex-shrink: 0;
  }
  .file-preview {
    height: 220px;
  }
  .storage-browser {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .storage-files {
    max-height: 280px;
  }
  .file-details {
    padding: 16px;
  }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .grid .card {
    padding: 12px;
  }
  .grid .muted {
    font-size: 10px;
  }
  .metric {
    font-size: 23px;
  }
  .card {
    padding: 14px;
  }
  .login {
    margin: 8vh 16px;
    max-width: none;
    padding: 24px;
  }
  .login .brand {
    height: 40px;
  }
  .code {
    font-size: 11px;
    min-height: 230px;
  }
  .result-tabs {
    margin: -14px -14px 12px;
  }
  .shell[data-section="sql"] .code {
    min-height: 280px;
  }
  .cell-menu {
    min-width: 200px;
  }
  .sidebar:has(+ .main) {
  }
  .file-details .toolbar {
    gap: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.function-list button[hidden] {
  display: none !important;
}
.function-list button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
}

.row-column-form {
  display: grid;
  gap: 8px;
  max-height: 62vh;
  overflow: auto;
  padding: 8px 3px;
}
.row-column-field {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 125px minmax(0, 2.3fr);
  align-items: start;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.row-column-label,
.row-column-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.row-column-control textarea {
  min-height: 34px;
  height: 34px;
  width: 100%;
  resize: vertical;
}
.row-column-control textarea.row-string-input {
  height: auto;
  min-height: 84px;
  field-sizing: content;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.row-column-label strong {
  overflow-wrap: anywhere;
}
.row-column-form[hidden],
.row-editor-tabs ~ div > textarea[hidden] {
  display: none !important;
}
.row-column-control small {
  overflow-wrap: anywhere;
}
.row-editor-tabs button.active {
  background: #30946b;
  color: white;
}
@media (max-width: 600px) {
  .row-column-field {
    grid-template-columns: minmax(70px, 1fr) 90px minmax(0, 1.5fr);
    gap: 6px;
  }
  .row-column-form {
    max-height: 60vh;
  }
}

.editable-cell.cell-editing {
  padding: 0 !important;
  outline: 2px solid #409cff;
  outline-offset: -2px;
  overflow: visible;
}
.inline-cell-input {
  width: 100%;
  min-width: 90px;
  min-height: 32px;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 6px !important;
  box-shadow: none !important;
  font: inherit !important;
  background: hsl(var(--background-default));
  color: inherit;
  box-sizing: border-box;
}
.editable-cell.cell-invalid {
  outline-color: #e5484d;
}

.sql-completion {
  position: fixed;
  z-index: 1500;
  width: min(480px, calc(100vw - 16px));
  max-height: 240px;
  overflow: auto;
  background: hsl(var(--background-default));
  color: hsl(var(--foreground-default));
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px #0003;
  border-radius: 6px;
  direction: ltr;
  font: 12px monospace;
}
.sql-completion[hidden] {
  display: none !important;
}
.sql-completion [role="option"] {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 7px 10px;
  cursor: pointer;
}
.sql-completion [role="option"] > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sql-completion small {
  white-space: nowrap;
  opacity: 0.65;
}
.sql-completion .active {
  background: #2486ff;
  color: white;
}

.table-list-entry {
  display: flex;
  align-items: center;
  gap: 0;
}
.table-list-entry > :is(button, a):first-child {
  flex: 1;
  min-width: 0;
}
.table-list-entry .table-more {
  flex: 0 0 30px;
  padding: 3px !important;
  font-size: 20px !important;
  min-width: 30px;
}
.table-list-entry .table-more:before {
  display: none;
}
.table-column-settings {
  max-height: 50vh;
  overflow: auto;
  display: grid;
  gap: 10px;
}
.table-column-settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.table-column-settings-row .field {
  min-width: 0;
}
@media (max-width: 650px) {
  .table-column-settings-row {
    grid-template-columns: 1fr;
  }
}
.sql-error {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dialog-feedback {
  white-space: pre-wrap;
}

.sql-error {
  direction: ltr;
  text-align: left;
}
.table-comment {
  min-height: 65px !important;
  height: 65px;
  max-height: 150px;
}

.sql-signature {
  position: fixed;
  z-index: 1499;
  max-width: min(650px, calc(100vw - 16px));
  max-height: 220px;
  overflow: auto;
  padding: 6px 10px;
  background: hsl(var(--background-default));
  color: hsl(var(--foreground-default));
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 4px 18px #0002;
  direction: ltr;
  font: 12px monospace;
}
.sql-signature[hidden] {
  display: none !important;
}
.sql-signature-row + .sql-signature-row {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 6px;
}
.sql-signature code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sql-signature strong {
  color: #1976f3;
  background: #1976f31a;
  border-radius: 3px;
  padding: 1px 3px;
}
.sql-signature small {
  display: block;
  margin-top: 5px;
  font:
    11px Tahoma,
    sans-serif;
  color: hsl(var(--foreground-light));
}

.projects-dashboard {
  padding: 24px;
}
.projects-dashboard h2 {
  font-size: 22px;
  margin: 0;
}
.projects-dashboard > .toolbar input {
  max-width: 300px;
}
.project-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 16px;
  margin-top: 24px;
}
.project-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  min-height: 210px;
  padding: 20px !important;
  border: 1px solid var(--line) !important;
  background: hsl(var(--background-default)) !important;
  border-radius: 10px !important;
  color: inherit !important;
  text-align: right;
  box-shadow: 0 1px 3px #00000008;
  cursor: pointer;
}
.project-card:hover {
  border-color: #31966f !important;
  box-shadow: 0 4px 16px #00000010;
}
.project-card[hidden] {
  display: none !important;
}
.project-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.project-card-head > strong {
  font-size: 17px;
  overflow-wrap: anywhere;
}
.project-card-slug {
  font: 12px monospace;
  color: hsl(var(--foreground-light));
  text-align: left;
  overflow-wrap: anywhere;
}
.project-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.project-card-stats > div {
  display: flex;
  align-items: center;
  gap: 7px;
}
.project-card-stats strong {
  font-size: 18px;
}
.project-card-stats span {
  font-size: 11px;
}
.project-card-create {
  border-style: dashed !important;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #31966f !important;
}
.project-create-plus {
  font: 42px sans-serif;
  line-height: 1;
}
.project-card-create > small {
  color: hsl(var(--foreground-light));
}
@media (max-width: 600px) {
  .projects-dashboard {
    padding: 16px;
  }
  .projects-dashboard > .toolbar {
    flex-wrap: wrap;
  }
  .projects-dashboard > .toolbar input {
    max-width: none;
  }
  .project-cards {
    grid-template-columns: 1fr;
  }
}

.grid.overview-stats,
.grid.user-stats {
  gap: clamp(4px, 1vw, 8px);
}
.grid.overview-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}
.grid.user-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-block: 12px;
}
.overview-stats > .card,
.user-stats > .card {
  margin: 0;
  min-width: 0;
  padding: 8px clamp(3px, 1vw, 10px);
}
.stat-group { display: flex; }
.stat-metric {
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
}
.stat-group > .stat-metric { flex: 1; padding-inline: 3px; }
.stat-group > .stat-metric + .stat-metric { border-inline-start: 1px solid var(--line); }
.stat-metric .metric { font-size: clamp(13px, 3.5vw, 18px); }
.stat-metric p { margin: 4px 0 0; font-size: 11px; }

.bulk-user-import {
  margin-block: 20px;
}
.bulk-import-drop {
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  padding: 20px;
  background: var(--muted-bg);
}
.bulk-user-import progress {
  width: 100%;
  height: 16px;
  margin-block: 10px;
}

/* Mobile navigation stays vertical and opens only when requested. */
.mobile-nav-toggle,
.mobile-explorer-toggle {
  display: none;
}
@media (max-width: 760px) {
  .mobile-nav-toggle,
  .mobile-explorer-toggle {
    display: flex;
    width: 100%;
    min-height: 44px;
    justify-content: space-between;
    text-align: right;
    font-size: 12px;
    flex-shrink: 0;
  }
  .sidebar .project-nav {
    display: none;
  }
  .sidebar.mobile-menu-open .project-nav,
  .sidebar .global-nav {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 55dvh;
    width: 100%;
  }
  .sidebar .nav :is(button, a) {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
  }
  .sidebar > .primary {
    position: static;
    width: 100%;
    min-height: 40px;
  }
  .sidebar footer {
    display: block;
    margin: 0;
    padding: 8px 0;
  }
  .sidebar:has(.project-nav):not(.mobile-menu-open) footer {
    display: none;
  }
  .resource-explorer {
    max-height: none;
    padding-top: 8px;
    overflow: visible;
  }
  .resource-explorer[data-mobile-disclosure] > :not(.mobile-explorer-toggle) {
    display: none;
  }
  .resource-explorer.mobile-explorer-open > :not(.mobile-explorer-toggle) {
    display: revert;
  }
  .resource-explorer.mobile-explorer-open > h3 {
    display: none;
  }
  .resource-explorer.mobile-explorer-open > .primary {
    position: static;
    margin: 0;
    min-height: 40px;
  }
  .resource-explorer.mobile-explorer-open .explorer-list {
    display: flex;
    flex-direction: column;
    max-height: 45dvh;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
  }
  .resource-explorer .explorer-list :is(button, a) {
    min-height: 42px;
  }
  .file-list {
    flex-direction: column;
    max-height: 35dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .shell,
  .main,
  #view,
  .resource-content {
    min-width: 0;
    max-width: 100%;
  }
}
@media (max-width: 760px) {
  .resource-explorer[data-mobile-disclosure].mobile-explorer-open > h3 {
    display: none;
  }
}

.csv-preview {
  max-height: 220px;
  overflow: auto;
  max-width: 100%;
}
.csv-import-errors {
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--danger, #c33);
}
#dialog progress {
  width: 100%;
  min-height: 12px;
}

/* Placement is left-to-right; Persian content remains right-to-left. */
.shell,
.resource-layout {
  direction: ltr;
}
.shell > *,
.resource-layout > * {
  direction: rtl;
}
.sidebar {
  border-left: 0;
  border-right: 1px solid var(--line);
}
.resource-explorer {
  border-left: 0;
  border-right: 1px solid var(--line);
}
.main {
  grid-template-rows: 49px auto minmax(0, 1fr);
}
.section-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.section-subnav[hidden] {
  display: none;
}
.section-subnav :is(button, a) {
  min-height: 34px;
}
.section-subnav :is(button, a).active {
  background: var(--muted-bg);
  color: var(--accent-link);
  border-color: var(--accent-link);
}
@media (max-width: 760px) {
  .main {
    grid-template-rows: 44px auto minmax(0, 1fr);
  }
  .sidebar,
  .resource-explorer {
    border-right: 0;
  }
  .section-subnav {
    padding: 8px 12px;
  }
  .section-subnav :is(button, a) {
    flex: 1 1 130px;
    min-height: 42px;
    white-space: normal;
  }
}
@media (min-width: 761px) {
  .main:has(.section-subnav:not([hidden])) .resource-explorer {
    height: calc(100dvh - 104px);
  }
}

.nav a,
.section-subnav a,
.explorer-list a,
.workspace-tab > a {
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  border: 1px solid transparent;
  border-radius: 4px;
}
.workspace-tab > a {
  white-space: nowrap;
  color: var(--fg);
}
.data-grid,
.data-grid table {
  direction: ltr;
}
.sort-label {
  white-space: nowrap;
  color: var(--secondary);
}
@media (max-width: 760px) {
  .sidebar .nav a {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
  }
}
.page-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.page-controls button {
  min-width: 32px;
}
.page-summary {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
  .page-controls {
    width: 100%;
    justify-content: center;
  }
  .page-controls button {
    min-height: 40px;
    min-width: 36px;
  }
  .page-summary {
    text-align: center;
  }
}

.data-grid table.resizable-table {
  table-layout: fixed;
  min-width: 0;
}
.data-grid .resizable-table th {
  min-width: 0;
  overflow: hidden;
  padding-right: 16px;
}
.data-grid .resizable-table td {
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-grid th .column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.column-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-sort {
  flex-shrink: 0;
  padding: 1px 5px;
  min-height: 23px;
  border: 0;
  background: transparent;
  font-size: 15px;
}
.column-sort:hover,
.column-sort[aria-expanded="true"] {
  background: var(--surface);
  color: var(--accent-link);
}
.column-resize {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 9px;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  z-index: 3;
  border-right: 2px solid transparent;
}
.column-resize:hover,
.column-resize:focus {
  background: var(--muted-bg);
  border-right-color: var(--accent-link);
  outline: 0;
}
.column-resize:hover::after,
.column-resize:focus::after {
  content: "↔";
  position: absolute;
  top: 13px;
  right: 0;
  font-size: 12px;
  color: var(--accent-link);
}
.page-number-input {
  width: 54px !important;
  max-width: 60px !important;
  min-width: 0;
  text-align: center;
  direction: ltr;
  padding: 3px 5px;
}
.page-summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.insert-menu-trigger {
  min-width: 78px;
}
@media (min-width: 761px) {
  .shell {
    grid-template-columns: 155px minmax(0, 1fr);
  }
  .sidebar .brand {
    font-size: 16px;
    letter-spacing: -0.5px;
  }
  .sidebar {
    padding-left: 9px;
    padding-right: 9px;
  }
  .sidebar-caption {
    font-size: 9px;
  }
}
@media (min-width: 1600px) {
  .shell {
    grid-template-columns: 165px minmax(0, 1fr);
  }
}
.column-movable {
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.column-pinned {
  cursor: default;
}
.data-grid th.column-dragging {
  opacity: 0.5;
}
.data-grid th.column-drop-before {
  box-shadow: inset 3px 0 var(--accent-link);
}
.data-grid th.column-drop-after {
  box-shadow: inset -3px 0 var(--accent-link);
}
.column-drag-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--accent-link);
  border-radius: 5px;
  padding: 8px 14px;
  box-shadow: 0 4px 18px #0003;
  direction: ltr;
}
@media (max-width: 760px) {
  .page-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(36px, 1fr));
  }
  .page-controls:has(button[aria-label="اولین صفحه"]) {
    grid-template-columns: repeat(4, minmax(36px, 1fr));
  }
  .page-controls .page-summary {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 40px;
  }
}

.data-grid .column-heading {
  flex-wrap: nowrap;
  white-space: nowrap;
  height: 30px;
  justify-content: flex-start;
  gap: 5px;
}
.data-grid .column-title {
  flex: 1 1 auto;
  min-width: 8px;
}
.data-grid .column-key-icon {
  flex: 0 0 auto;
  font-size: 10px;
}
.data-grid th .column-type {
  flex: 0 1 auto;
  min-width: 5px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
.main > #view {
  grid-row: 3;
}
.shell[data-section="sql"] #view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
  min-height: 0;
  height: 100%;
}
.shell[data-section="sql"] #view > .workspace-tabs {
  margin: 0;
}
.sql-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.sql-split > .card {
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.sql-editor-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
}
.sql-editor-pane > .toolbar {
  margin: 0;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.sql-editor-pane > .toolbar select {
  width: 240px;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 240px;
  text-overflow: ellipsis;
}
.shell[data-section="sql"] .sql-editor-pane .code {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  min-height: 0;
  max-height: none;
  height: 100%;
  resize: none;
  padding: 8px;
}
.sql-editor-pane > .small {
  margin: 0;
  font-size: 10px;
  max-height: 38px;
  overflow: auto;
}
.sql-results-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}
.shell[data-section="sql"] .sql-results-pane .result-tabs {
  margin: -10px -16px 0;
  min-height: 32px;
}
.sql-output {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.sql-output.sql-data-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  gap: 8px;
}
.sql-data-output > .table-wrap {
  min-height: 0;
  max-height: none;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.sql-result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.sql-export-actions.toolbar {
  margin: 0;
  gap: 6px;
}
@media (max-width: 760px) {
  .shell[data-section="sql"] {
    height: 100dvh;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .shell[data-section="sql"] .main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .sql-split > .card {
    padding: 8px 12px;
  }
  .sql-editor-pane > .toolbar select {
    max-width: 100%;
  }
  .shell[data-section="sql"] .sql-results-pane .result-tabs {
    margin: -8px -12px 0;
  }
  .sql-result-toolbar {
    font-size: 10px;
  }
  .sql-export-actions button {
    padding: 4px 7px;
    min-height: 30px;
  }
}

.explorer-list.storage-tree {
  display: block;
  margin: 0;
  overflow: auto;
  min-height: 0;
}
.storage-tree .storage-tree-row {
  display: flex;
  align-items: center;
  min-height: 33px;
  gap: 4px;
  direction: ltr;

  border-radius: 4px;
}
.storage-tree .storage-tree-indent { padding-left: 22px; }
.storage-tree-row:hover {
  background: var(--muted-bg);
}
.storage-tree-row.active {
  background: hsl(var(--background-selection));
}
.storage-tree .storage-tree-row button::before {
  display: none;
}
.storage-tree .storage-tree-row button {
  border: 0;
  box-shadow: none;
  margin: 0;
  min-height: 29px;
  background: transparent;
}
.storage-tree .storage-tree-toggle {
  padding: 0;
  width: 16px;
  min-width: 16px;
  flex: 0 0 16px;
  justify-content: center;
  font-size: 17px;
}
.storage-tree-toggle:disabled {
  visibility: hidden;
}
.storage-tree-icon {
  flex-shrink: 0;
  font-size: 13px;
}
.storage-tree .storage-tree-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 0;
  text-align: left;
  color: var(--fg);
  font-size: 11px;
}
.storage-tree-row.active .storage-tree-label {
  color: var(--accent-link);
  font-weight: 600;
}
.storage-tree-count {
  flex: 0 0 auto;
  min-width: 16px;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  border-radius: 3px;
  background: var(--muted-bg);
  padding: 0 3px;
}
.storage-tree-visibility {
  font-size: 8px;
  color: var(--muted);
  padding-right: 3px;
}
.storage-tree-empty {
  direction: rtl;
  padding: 5px 14px;
  margin: 0;
}
.storage-tree [role="group"] > .error {
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 5px;
}
@media (max-width: 760px) {
  .storage-tree .storage-tree-row {
    min-height: 40px;
  }
}
.sql-split {
  grid-template-rows: minmax(0, calc(var(--sql-split, 50%) - 4px)) 8px minmax(
      0,
      1fr
    );
}
.sql-divider {
  cursor: row-resize;
  touch-action: none;
  user-select: none;
  text-align: center;
  line-height: 8px;
  background: var(--muted-bg);
  color: var(--secondary);
}
.sql-divider:hover,
.sql-divider:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-link);
}
.sql-function-picker {
  position: relative;
  width: 240px;
  max-width: 100%;
  flex: 0 1 240px;
}
.sql-function-picker summary {
  cursor: pointer;
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  padding: 5px 9px;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface);
}
.sql-function-options {
  position: fixed;
  z-index: 500;
  width: min(420px, calc(100vw - 24px));
  max-height: min(50vh, 400px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 18px #0003;
  direction: ltr;
}
.sql-function-options button {
  display: block;
  width: 100%;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  border: 0;
  box-shadow: none;
}

.csv-import-drop {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.csv-import-drop.drag-active {
  border-color: var(--accent-link);
  background: var(--accent-soft);
}
.csv-import-drop input[type="file"] {
  max-width: 100%;
}
/* Functions: clear navigation, adjustable workspace, readable signatures. */
.function-tabs {
  gap: 10px;
  padding: 12px 18px;
}
.function-tabs a {
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 700;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.function-tabs a[data-section="functions"] {
  background: #e8eaff;
  color: #4338a8;
}
.function-tabs a[data-section="sqlfunctions"] {
  background: #d9f5eb;
  color: #11634c;
}
.function-tabs a.active[data-section="functions"] {
  background: linear-gradient(120deg, #6357d5, #4338a8);
  color: #fff;
  box-shadow: 0 4px 12px #6357d533;
}
.function-tabs a.active[data-section="sqlfunctions"] {
  background: linear-gradient(120deg, #169977, #11634c);
  color: #fff;
  box-shadow: 0 4px 12px #16997733;
}
.function-tabs a:hover {
  transform: translateY(-1px);
}
.function-layout {
  grid-template-columns:
    minmax(0, var(--function-list-width, 330px))
    10px minmax(0, 1fr);
}
.function-layout .resource-explorer {
  width: auto;
  border: 0;
}
.function-layout .resource-content {
  min-width: 0;
}
.function-layout h3 {
  overflow-wrap: anywhere;
}
.function-layout .function-list button {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  direction: ltr;
}
.function-divider {
  cursor: col-resize;
  touch-action: none;
  background: var(--muted-bg);
  border-inline: 1px solid var(--line);
  position: relative;
  min-height: 100%;
}
.function-divider::after {
  content: "";
  position: absolute;
  top: 42%;
  left: 3px;
  width: 2px;
  height: 44px;
  border-radius: 3px;
  background: #77968b;
}
.function-divider:hover,
.function-divider:focus-visible,
.is-resizing .function-divider {
  background: #bce9dc;
  outline: none;
}
.is-resizing {
  cursor: col-resize;
  user-select: none;
}
.function-list .sql-function-entry {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
}
.function-entry-name {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.function-entry-args,
.function-entry-return {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.function-entry-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.function-security,
.function-kind {
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  background: var(--muted-bg);
}
.function-security.definer {
  color: #9a4d08;
  background: #fff0d8;
}
.function-security.invoker {
  color: #11634c;
  background: #d9f5eb;
}
.sql-function-metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.function-meta-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.function-meta-item strong {
  overflow-wrap: anywhere;
  text-align: left;
  font-size: 12px;
}
@media (max-width: 760px) {
  .function-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .function-divider {
    display: none;
  }
  .function-tabs a {
    flex: 1;
    text-align: center;
    padding: 10px;
  }
}
/* SQL details remain one compact row; navigation never grows outside its viewport. */
.sql-function-metadata {
  grid-template-columns: 0.7fr 2fr 1.3fr 0.8fr 0.8fr 0.8fr 0.65fr;
  gap: 6px;
  margin: 8px 0;
}
.function-meta-item {
  padding: 6px 8px;
  gap: 3px;
  border-radius: 6px;
}
.function-meta-item > span {
  font-size: 10px;
  white-space: nowrap;
}
.function-meta-item strong {
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
@media (min-width: 761px) {
  .sidebar {
    box-sizing: border-box;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    gap: 9px;
    padding-bottom: 10px;
  }
  .sidebar > * {
    min-width: 0;
    flex-shrink: 0;
  }
  .sidebar .brand {
    flex-shrink: 0;
    font-size: 15px;
  }
  .sidebar .nav {
    gap: 2px;
    min-height: 0;
    overflow: visible;
  }
  .sidebar .nav :is(button, a) {
    padding: 6px 7px;
    min-height: 30px;
  }
  .sidebar footer {
    padding-top: 8px;
  }
}
@media (min-width: 761px) and (max-height: 720px) {
  .sidebar {
    gap: 5px;
  }
  .sidebar .sidebar-caption {
    display: none;
  }
  .sidebar .nav :is(button, a) {
    min-height: 26px;
    padding: 4px 7px;
  }
  .sidebar footer button {
    margin-top: 4px;
  }
}
@media (max-width: 760px) {
  .sql-function-metadata {
    grid-template-columns: repeat(7, minmax(100px, 1fr));
    overflow-x: auto;
    padding-bottom: 5px;
  }
}
@media (min-width: 761px) {
  .sidebar .brand {
    margin-inline: 0;
    padding-inline: 0;
    width: 100%;
    max-width: 100%;
    justify-content: center;
    font-size: 14px;
  }
}
.policy-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.policy-preset {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  min-width: 0;
}
.policy-preset h3 {
  margin-bottom: 8px;
}
.policy-preset label {
  margin: 8px 0;
}
.policy-existing-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin: 8px 0;
}
.policy-existing-row code {
  width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 11px;
}
.policy-existing-row button {
  margin-inline-start: auto;
}
.policy-current {
  max-height: 260px;
  overflow: auto;
}
@media (max-width: 600px) {
  .policy-presets {
    grid-template-columns: minmax(0, 1fr);
  }
}
.policy-preset [hidden] {
  display: none !important;
}
/* Consistent filled tabs for API, connection and logs as well as functions. */
.function-tabs a[data-section="policies"],
.function-tabs a[data-section="logs"],
.function-tabs a[data-section="settings"] {
  background: #e8eaff;
  color: #4338a8;
}
.function-tabs a[data-section="tester"],
.function-tabs a[data-section="audit"],
.function-tabs a[data-section="webhooks"] {
  background: #d9f5eb;
  color: #11634c;
}
.function-tabs a.active[data-section="policies"],
.function-tabs a.active[data-section="logs"],
.function-tabs a.active[data-section="settings"] {
  background: linear-gradient(120deg, #6357d5, #4338a8);
  color: #fff;
  border: 0;
  box-shadow: 0 4px 12px #6357d533;
}
.function-tabs a.active[data-section="tester"],
.function-tabs a.active[data-section="audit"],
.function-tabs a.active[data-section="webhooks"] {
  background: linear-gradient(120deg, #169977, #11634c);
  color: #fff;
  border: 0;
  box-shadow: 0 4px 12px #16997733;
}
.table-refresh {
  font-size: 22px;
  line-height: 1;
  min-width: 36px;
}
#dialog:has(.cell-code-editor) {
  width: 96vw;
  max-width: 1600px;
  height: 94dvh;
  max-height: 96dvh;
}
#dialog:has(.cell-code-editor) #dialog-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cell-code-editor {
  display: flex;
  direction: ltr;
  flex: 1;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.cell-code-lines {
  width: 48px;
  flex-shrink: 0;
  margin: 0;
  padding: 12px 8px;
  text-align: right;
  overflow: hidden;
  background: var(--muted-bg);
  color: var(--muted);
  font: 13px/22px monospace;
}
.cell-code-input {
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 0;
  white-space: pre;
  overflow: auto;
  padding: 12px;
  font: 13px/22px monospace;
  tab-size: 2;
}
.cell-code-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}
.cell-code-input {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
  overflow-x: hidden;
  min-width: 0;
}
.cell-code-lines > div {
  box-sizing: border-box;
}
.table-explorer {
  padding-bottom: 30px;
  max-height: calc(100dvh - 73px);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 125, 120, 0.42) transparent;
}
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(110, 125, 120, 0.42);
  border-radius: 8px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(110, 125, 120, 0.65);
}
.row-selected > td {
  background: rgba(16, 185, 129, 0.1);
}
.row-actions-content input[type="checkbox"],
.row-actions-heading input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0 4px;
  flex-shrink: 0;
  accent-color: var(--primary, #159c75);
}
.row-selection-toolbar {
  padding: 8px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
/* Shared raised button surface across every workspace and dialog. */
:root {
  --button-top: #fbfcfe;
  --button-bottom: #dce3eb;
  --button-edge: #a5b1c1;
  --button-border: #c1ccd8;
  --button-ink: #26374b;
}
html[data-theme="dark"], body[data-theme="dark"], :root.dark {
  --button-top: #465469;
  --button-bottom: #293447;
  --button-edge: #152031;
  --button-border: #596b82;
  --button-ink: #f1f5fb;
}
button, .section-subnav a, input[type="file"]::file-selector-button {
  background: linear-gradient(180deg,var(--button-top),var(--button-bottom)) !important;
  color: var(--button-ink) !important;
  border: 1px solid var(--button-border) !important;
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--button-edge), 0 5px 9px #00000014, inset 0 1px 0 #ffffff40 !important;
  font-weight: 600;
  transition: transform .13s ease, box-shadow .13s ease, filter .13s ease;
}
button.primary, .section-subnav a.active {
  --button-top: #35c78b; --button-bottom: #15815b;
  --button-edge: #095c41; --button-border: #57d8a4; --button-ink: #fff;
}
button.danger, button.danger-3d {
  --button-top: #f65c66; --button-bottom: #b31e39;
  --button-edge: #790e25; --button-border: #fa8890; --button-ink: #fff;
}
button.warning {
  --button-top: #ffb653; --button-bottom: #d57015;
  --button-edge: #99460d; --button-border: #ffd08c; --button-ink: #301900;
}
.section-subnav a {
  --button-top: #a99df3; --button-bottom: #7361c9;
  --button-edge: #4b3c96; --button-border: #c0b6ff; --button-ink: #fff;
  padding: 7px 14px;
}
.section-subnav a.active {
  --button-top: #8875ef; --button-bottom: #5140b2;
  --button-edge: #362677; --button-border: #b3a5ff;
}
button:hover:not(:disabled), .section-subnav a:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
button:active:not(:disabled), .section-subnav a:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--button-edge), inset 0 1px 3px #00000020 !important;
}
button:disabled {
  opacity: .45;
  filter: saturate(.5);
  transform: none;
  cursor: not-allowed;
}
.toolbar.project-danger-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  padding: 3px 2px 10px;
}
.project-danger-actions > button {
  min-width: 0;
  min-height: 40px;
  white-space: normal;
  padding: 8px;
}
@media (max-width: 760px) {
  .toolbar.project-danger-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}
input[type="file"]::file-selector-button { padding: 5px 12px; margin-inline-end: 10px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
  button, .section-subnav a { transition: none; }
}

/* Flat navigation surfaces for storage and table row expansion. */
.storage-tree .storage-tree-row button,
.breadcrumbs button,
.storage-files button,
.row-actions button.row-icon,
.table-list-entry button.table-more,
button.column-sort,
.workspace-tabs button,
.function-list button {
  background: transparent !important;
  color: var(--fg) !important;
  border: 0 !important;
  border-radius: 3px;
  box-shadow: none !important;
  font-weight: inherit;
  transform: none !important;
  filter: none !important;
  transition: background-color .13s ease;
}
.storage-tree .storage-tree-row.active .storage-tree-label {
  color: var(--accent-link) !important;
}
.breadcrumbs button:hover:not(:disabled),
.storage-files button:hover:not(:disabled),
.row-actions button.row-icon:hover:not(:disabled) {
  background: var(--muted-bg) !important;
}
.storage-files button.storage-entry {
  border-radius: 0;
  border-bottom: 1px solid var(--line) !important;
}
.storage-files button.storage-entry.active {
  background: hsl(var(--background-selection)) !important;
  color: var(--accent-link) !important;
}

/* Compact row controls and flat utility/navigation buttons. */
.data-grid .row-actions,
.data-grid .row-actions-heading {
  min-width: 68px;
  width: 68px;
}
.table-list-entry button.table-more:hover:not(:disabled),
button.column-sort:hover:not(:disabled),
button.column-sort[aria-expanded="true"],
.workspace-tabs button:hover:not(:disabled),
.function-list button:hover:not(:disabled) {
  background: var(--muted-bg) !important;
}
.workspace-tabs button {
  border-radius: 0;
}
.function-list button.active {
  background: hsl(var(--background-selection)) !important;
  color: var(--accent-link) !important;
}
.sidebar .global-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-block: 4px 7px;
}
.project-cards .project-card {
  background: linear-gradient(140deg,
    color-mix(in srgb, var(--surface) 92%, #67b9a2 8%),
    color-mix(in srgb, var(--bg) 97%, #789dd2 3%)) !important;
}
@media (max-width: 760px) {
  .sidebar .global-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    overflow: visible;
    max-height: none;
  }
  .sidebar .global-nav button {
    min-width: 0;
    width: 100%;
    justify-content: center;
  }
}

/* Source files are editor navigation, not action buttons. */
.file-list > button {
  background: transparent !important;
  color: var(--fg) !important;
  border: 0 !important;
  border-radius: 0;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  justify-content: flex-start;
  text-align: left;
  padding: 7px 10px;
  font-weight: 400;
}
.file-list > button:hover { background: var(--muted-bg) !important; }
.file-list > button.active {
  background: var(--accent-soft) !important;
  color: var(--accent-link) !important;
  border-inline-start: 3px solid var(--accent-link) !important;
  font-weight: 600;
}
.typescript-editor {
  min-width: 0;
  height: 450px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  direction: ltr;
  text-align: left;
}
.typescript-editor:focus-within { border-color: var(--accent-link); }
.typescript-editor .cm-editor { height: 100%; }
.typescript-editor .cm-scroller { overflow: auto; }
.typescript-editor .cm-gutters { border-right: 1px solid var(--line); }
.typescript-editor .cm-editor:not(.cm-focused) { outline: none; }

.table-workspace-content > .card > .toolbar {
  direction: rtl;
  justify-content: flex-start;
}
.table-workspace-content > .card > .pagination {
  direction: ltr;
  justify-content: space-between;
}
.table-workspace-content .pagination > .muted { direction: rtl; }
.table-workspace-content .pagination .page-controls { justify-content: flex-start; }

.table-workspace-content > .card > .toolbar:not(.row-selection-toolbar):not(.pagination) {
  justify-content: flex-end;
}
.shell[data-section="tables"] #view { overflow: hidden; }
.shell[data-section="tables"] #view > .resource-layout {
  height: 100%;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}
.table-workspace-content {
  min-height: 0;
  overflow: hidden;
}
.table-workspace-content > .card > :not(.data-grid),
.table-workspace-content > .workspace-tabs { flex-shrink: 0; }
.table-workspace-content > .card > .data-grid {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow: auto;
}
.table-workspace-content .table-definition .table-wrap { max-height: 24dvh; }
.flat-context-menu button {
  background: transparent !important;
  color: var(--fg) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  font-weight: 400;
}
.flat-context-menu button:hover,
.flat-context-menu button:focus-visible { background: var(--muted-bg) !important; }
@media (max-width: 760px) {
  .shell[data-section="tables"] .main {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .shell[data-section="tables"] #view > .resource-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }
  .shell[data-section="tables"] .resource-explorer {
    max-height: none;
    overflow: visible;
  }
  .shell[data-section="tables"] .resource-explorer.mobile-explorer-open .table-explorer-list {
    flex: 0 0 auto;
    max-height: 30dvh;
  }
  .shell[data-section="tables"] #view {
    overflow-y: auto;
  }
  .shell[data-section="tables"] #view > .resource-layout {
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto;
  }
  .table-workspace-content > .card > .data-grid {
    min-height: 24dvh;
  }
}

.overview-stat-link {
  display: block;
  color: var(--fg);
}
.overview-stat-link:hover,
.overview-stat-link:focus-visible {
  background: var(--muted-bg);
  border-color: var(--accent-link);
  text-decoration: none;
}

.table-workspace-content > .card > .table-insert-toolbar:not(.pagination):not(.row-selection-toolbar) { direction: ltr; justify-content: flex-start; }

.cell-menu.flat-context-menu {
  padding: 5px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px #0003, 0 2px 6px #0001;
}
.flat-context-menu button {
  border: 0 !important;
  border-radius: 5px;
  text-align: right;
  padding: 6px 10px;
}
.flat-context-menu .context-menu-danger {
  border-top: 1px solid var(--line) !important;
  margin-top: 4px;
  color: var(--danger) !important;
}

.data-grid th .column-restore { display: none; }
.data-grid .resizable-table th.column-collapsed { padding-inline: 3px; }
.data-grid th.column-collapsed > :not(.column-restore) { display: none; }
.data-grid th.column-collapsed .column-restore {
  display: block;
  width: 100%;
  padding-inline: 0;
  text-align: center;
}

.brand:hover { text-decoration: none; }
.project-nav-tooltip { display: none; }
@media (min-width: 761px) {
  .shell.project-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .project-shell .brand { justify-content: center; }
  .project-shell .brand:before { margin: 0; }
  .project-shell :is(.brand-name, .sidebar-caption, .project-nav-label) { display: none; }
  .project-shell .project-nav a {
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-inline: auto;
    padding: 0;
  }
  .project-nav-tooltip {
    display: block;
    position: fixed;
    z-index: 20;
    pointer-events: none;
    background: var(--fg);
    color: var(--surface);
    padding: 6px 10px;
    border-radius: 8px;
    opacity: 0;
    transform: translate(-4px, -50%);
    transition: opacity 140ms ease, transform 140ms ease;
  }
  .project-nav-tooltip.visible {
    opacity: 1;
    transform: translate(0, -50%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .project-nav-tooltip { transition: none; }
}

.topbar button.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 50%;
  font-size: 15px;
  background: var(--surface) !important;
  box-shadow: none !important;
  transform: none !important;
}
.topbar button.theme-toggle:hover { background: var(--muted-bg) !important; }
@media (max-width: 760px) {
  .sidebar .home-account-actions { display: flex; }
}

.identity-tabs { gap: 8px; margin-block-end: 10px; }
.identity-tabs > button[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sql-chart-panel { min-height: 0; overflow: auto; padding: 8px 12px; }
.sql-chart-card { max-width: 850px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.sql-chart-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sql-chart-summary { display: flex; gap: 14px; }
.sql-chart-card > p { margin: 8px 14px 0; }
.sql-chart-plot { position: relative; direction: ltr; }
.sql-chart-plot canvas { display: block; width: 100%; height: auto; }
.sql-chart-tooltip { position: absolute; z-index: 1; pointer-events: none; max-width: 100%; overflow-wrap: anywhere; background: var(--fg); color: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.result-tabs button[aria-pressed="true"] { color: var(--accent-link); }
