:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1e2526;
  --muted: #6d7472;
  --line: #dfe4df;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b45309;
  --select: #e0f2f1;
  --shadow: 0 16px 40px rgba(32, 45, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

.sidebar,
.inspector {
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 15px;
}

.brand p,
.muted,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

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

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

.file-picker {
  display: block;
  margin: 12px 0 10px;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-picker span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  color: var(--accent-strong);
  cursor: pointer;
}

.database-select {
  width: 100%;
  min-height: 38px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 10px;
}

.bridge-state {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #eef6f3;
  color: var(--accent-strong);
  font-size: 13px;
}

.table-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.table-tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.table-tab.active {
  border-color: var(--accent);
  background: var(--select);
  color: var(--accent-strong);
}

.icon-btn {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(280px, 1fr) 190px;
  min-width: 0;
  padding: 20px;
  gap: 14px;
}

.topbar,
.query-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar h2 {
  margin-top: 2px;
  font-size: 28px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar button:last-child,
#saveBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.query-bar input {
  width: min(420px, 100%);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: white;
}

.grid-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3ef;
  font-size: 13px;
}

td[contenteditable="true"] {
  outline: 0;
}

td[contenteditable="true"]:focus {
  background: #fff7ed;
  box-shadow: inset 0 0 0 2px var(--warn);
}

tr.selected {
  background: var(--select);
}

.sql-log {
  min-height: 0;
  background: #17211f;
  color: #d9f4ef;
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
}

.sql-log h2 {
  color: white;
}

.text-btn {
  min-height: 30px;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.25);
  color: #d9f4ef;
}

pre {
  height: 130px;
  overflow: auto;
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.record-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.field select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 10px;
}

.note p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .workspace,
  .sidebar,
  .inspector {
    padding: 14px;
  }

  .topbar,
  .query-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .query-bar input,
  #saveBtn {
    width: 100%;
  }

  .toolbar button {
    flex: 1 1 92px;
  }
}
