:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --text: #2c2c2c;
  --muted: #777;
  --line: #dedede;
  --soft: #f7f7f5;
  --selected: #dceef0;
  --accent: #316aa5;
  --danger: #b42318;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; min-width: 1000px; height: 100%; margin: 0; }
body { overflow: hidden; background: #fff; color: var(--text); font-size: 16px; }
button, input { font: inherit; color: inherit; }

.boot { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 100vh; color: var(--muted); }
.boot-mark, .brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 4px; background: var(--accent); color: white; font-size: 12px; font-weight: 700; }

.login-shell { display: grid; min-height: 100vh; place-items: center; background: #f5f5f5; }
.login-card { width: 360px; padding: 28px; border: 1px solid var(--line); border-radius: 5px; background: white; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.login-title { display: flex; align-items: center; gap: 11px; }
.login-title h1 { margin: 0; font-size: 20px; }
.login-note { margin: 14px 0 24px; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 15px; }
.field span { font-size: 14px; }
.field input { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #c9c9c9; border-radius: 4px; outline: none; background: white; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(49,106,165,.12); }
.primary-button { width: 100%; height: 40px; border: 0; border-radius: 4px; background: var(--accent); color: white; font-weight: 600; cursor: pointer; }
.primary-button:disabled { opacity: .6; cursor: wait; }
.form-error { margin: 0 0 12px; color: var(--danger); font-size: 14px; }

.workspace {
  display: grid;
  grid-template-columns: 450px minmax(0, 1fr);
  grid-template-rows: 50px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
}
.sidebar-header {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.sidebar-header strong { font-size: 18px; font-weight: 600; }
.main-header {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.breadcrumbs { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs strong { font-size: 17px; font-weight: 600; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-button, .icon-button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid #d2d2d2;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.toolbar-button:hover:not(:disabled), .icon-button:hover { background: #f3f3f3; }
.toolbar-button:disabled { color: #aaa; cursor: default; }
.toolbar-button.icon-only, .icon-button { width: 42px; padding: 0; font-size: 18px; }
.page-range { min-width: 68px; color: #6b6b6b; text-align: center; }

.sidebar { grid-column: 1; grid-row: 2; min-width: 0; overflow: hidden; border-right: 1px solid var(--line); background: #fff; }
.tree { height: 100%; overflow-y: auto; overflow-x: hidden; padding: 8px 0 24px; scrollbar-gutter: stable; }
.tree-loading { padding: 16px 12px; color: var(--muted); }
.tree-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  gap: 6px;
  padding: 5px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #333;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.tree-row:hover { background: #f1f1ee; }
.tree-row.selected { background: var(--selected); }
.tree-row.database { font-weight: 400; }
.tree-row.group { color: #555; font-size: 14px; font-weight: 400; text-transform: none; }
.tree-row .chevron { width: 12px; color: #777; font-size: 10px; }
.tree-row .node-icon { width: 16px; color: #777; text-align: center; }
.tree-row .name { overflow: hidden; flex: 1; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .count { color: #737373; font-variant-numeric: tabular-nums; }
.tree-children { margin: 0; padding: 0; border: 0; }

.main { grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; overflow: hidden; background: white; }
.content { width: 100%; height: 100%; overflow: hidden; padding: 0; }
.data-view { width: 100%; height: 100%; overflow: hidden; }
.result-summary { display: flex; align-items: center; height: 42px; padding: 0 12px; border-bottom: 1px solid var(--line); color: #696969; }
.table-wrap { width: 100%; height: calc(100% - 42px); overflow: auto; scrollbar-gutter: stable; }
.data-table { width: 100%; min-width: max-content; border-collapse: separate; border-spacing: 0; font-family: Arial, Helvetica, sans-serif; font-size: 15px; }
.data-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  height: 38px;
  padding: 7px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f7f7f7;
  color: #333;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.data-table td { height: 36px; max-width: 520px; padding: 7px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; overflow-wrap: normal; vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:hover td { background: #f1f7f8; }
.null { color: #999; font-style: italic; }
.object-value { color: #5b4f94; }
.table-name-button { border: 0; padding: 0; background: transparent; color: #222; font: inherit; cursor: pointer; }
.table-name-button:hover { text-decoration: underline; }
.empty-row { height: 70px !important; color: var(--muted) !important; text-align: center; }
.overview-table td:nth-child(2), .overview-table td:nth-child(3) { width: 140px; }

.empty-state { display: grid; height: 100%; place-items: center; text-align: center; }
.empty-card { max-width: 380px; }
.empty-symbol { margin-bottom: 10px; color: #999; font-size: 24px; }
.empty-card h1 { margin: 0 0 7px; font-size: 19px; }
.empty-card p { margin: 0; color: var(--muted); font-size: 14px; }
.role-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.role-stat { padding: 18px; background: #fff; }
.role-stat span { display: block; color: var(--muted); font-size: 13px; }
.role-stat strong { display: block; margin-top: 8px; font-size: 16px; }
.error-box { margin: 16px; padding: 14px; border: 1px solid #f0c7c4; border-radius: 4px; background: #fff6f5; color: var(--danger); }

.password-dialog { width: 410px; padding: 0; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 18px 50px rgba(0,0,0,.2); }
.password-dialog::backdrop { background: rgba(20,27,38,.35); }
.password-form { padding: 22px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.page-button, .save-button { padding: 7px 14px; border: 1px solid #ccc; border-radius: 4px; background: #fff; cursor: pointer; }
.save-button { border-color: var(--accent); background: var(--accent); color: #fff; }
.save-button:disabled { opacity: .6; cursor: wait; }
.password-status { min-height: 18px; margin: 4px 0 0; font-size: 13px; }
.password-status.error { color: var(--danger); }
.password-status.success { color: #207245; }

.tree::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.tree::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: #f1f1f1; }
.tree::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { border: 3px solid #f1f1f1; border-radius: 8px; background: #aaa; }
.tree::-webkit-scrollbar-thumb:hover, .table-wrap::-webkit-scrollbar-thumb:hover { background: #888; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 340px minmax(0, 1fr); }
  .tree-row { font-size: 15px; }
}
