:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --line: #d8d8d0;
  --text: #20231f;
  --muted: #6c716a;
  --accent: #1e6b78;
  --danger: #9d2f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

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

button,
input {
  font: inherit;
}

button {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 9px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #a8ada4;
}

button:disabled {
  cursor: default;
  opacity: .45;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(30, 107, 120, .35);
  outline-offset: 1px;
}

input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 7px;
  background: #fff;
}

.login-body {
  display: grid;
  place-items: center;
}

.login-box {
  width: 260px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.login-error {
  grid-column: 1 / -1;
  color: var(--danger);
  font-size: 12px;
}

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

.tree-pane {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fbfbf8;
  overflow: hidden;
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr);
}

.tree-head,
.toolbar,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tree-head {
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.tree {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px 0 12px;
}

.tree-node {
  display: block;
}

.tree-row {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 0;
  padding: 0 8px;
  background: transparent;
  text-align: left;
}

.tree-row:hover {
  background: #eeeeea;
}

.tree-row.active {
  background: #dbeaec;
  color: #113d45;
}

.tree-toggle {
  width: 14px;
  flex: 0 0 14px;
  color: var(--muted);
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.table-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 36px auto minmax(0, 1fr);
}

.toolbar {
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-actions form {
  margin: 0;
}

.icon-btn {
  width: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.page {
  min-width: 58px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.message {
  min-height: 28px;
  padding: 6px 8px;
  color: var(--muted);
}

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

.table-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #fff;
  cursor: grab;
  user-select: none;
}

.table-wrap.dragging {
  cursor: grabbing;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  max-width: 360px;
  border: 1px solid #e1e1dc;
  padding: 4px 6px;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f4f0;
  text-align: left;
  font-weight: 600;
}

td.null {
  color: #a0a49c;
  font-style: italic;
}

dialog {
  width: 300px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .16);
}

dialog::backdrop {
  background: rgba(32, 35, 31, .18);
}

#password-form {
  padding: 10px;
  display: grid;
  gap: 9px;
}

#password-form label {
  display: grid;
  gap: 4px;
}

.modal-head {
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.modal-status {
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
}

.modal-status.ok {
  color: var(--accent);
}
