.dbworkspace {
  display: flex;
  flex: 1;
  min-height: 0;
}
.dbsidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 26px 14px;
  background: #fafcfb;
  border-right: 1px solid var(--line);
  overflow: auto;
}
.dbsidebar h2 {
  font-size: 16px;
  margin: 0 10px 18px;
}
.dbsidebar .eyebrow {
  margin-left: 10px;
}
.dbsidebar button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  margin: 3px 0;
  padding: 10px 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.dbsidebar button[aria-current='true'] {
  background: #e0eee5;
  color: #236b59;
  font-weight: 600;
}
.dbsidebar small {
  display: block;
  font-size: 10px;
  color: #87978b;
  margin-top: 4px;
}
.dbworkspace main {
  width: 0;
}
#dataview,
#schemaview,
#sqlview {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#grid {
  flex: 1;
  min-height: 100px;
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
}
#grid:has(.empty) {
  min-height: 200px;
}
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 9px 12px;
  font-size: 12px;
  color: #718478;
}
#schema {
  flex: 1;
  min-height: 150px;
  resize: none;
  white-space: pre;
  overflow: auto;
  font:
    13px/1.7 Consolas,
    monospace;
  padding: 16px;
}
#schemaview p {
  margin: 0 0 10px;
}
td[data-type='null'] {
  color: #9b8071;
  font-style: italic;
}
td[data-type='blob'] {
  color: #8567a0;
  font-family: Consolas, monospace;
}
td[data-type='integer'],
td[data-type='real'] {
  font-family: Consolas, monospace;
}
th small {
  font-size: 10px;
  color: #8a9b8f;
  font-weight: 400;
  margin-left: 6px;
}
th:first-child,
td:first-child {
  min-width: 68px;
  width: 68px;
  max-width: 68px;
  padding: 6px 8px;
}
td:first-child input {
  cursor: pointer;
  vertical-align: middle;
  margin: 0 4px 0 0;
}
.rownum-index {
  display: inline-block;
  vertical-align: middle;
  font-family: Consolas, monospace;
  font-weight: 600;
  color: #23614d;
}
.insert-field {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.insert-field div {
  display: flex;
  gap: 8px;
}
.insert-field select {
  max-width: 120px;
}
.insert-field textarea {
  min-height: 50px !important;
}
.local a {
  margin-left: 18px;
  color: #4f7b65;
  text-decoration: none;
}
@media (max-width: 900px) {
  .dbsidebar {
    width: 160px;
    padding: 20px 8px;
  }
  .dbworkspace .intro {
    align-items: flex-start;
    flex-direction: column;
  }
  .dbworkspace h1 {
    max-width: 65vw;
    font-size: 19px;
  }
}

.dbsidebar {
  width: 195px;
  padding: 10px;
}
.dbsidebar .eyebrow {
  display: none;
}
.dbsidebar h2 {
  font-size: 13px;
  margin: 0 6px 8px;
}
.dbsidebar button {
  padding: 7px 10px;
  font-size: 12px;
}
.pagination {
  padding: 5px 10px;
}

/* FR-080 multi-condition filter */
.filtertools #conditions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.condition {
  display: flex;
  align-items: center;
  gap: 6px;
}
.condition select[data-role='op'] {
  max-width: 110px;
}
.condition input[data-role='value'][hidden] {
  display: none;
}
.condition .removecondition {
  padding: 4px 8px;
}
th .sortbtn {
  border: 0;
  background: transparent;
  padding: 0 4px;
  margin-left: 4px;
  font-size: 11px;
  color: #8a9b8f;
  cursor: pointer;
}
th .sortbtn[data-active='true'] {
  color: #236b59;
  font-weight: 700;
}
/* FR-081 SQL page */
#sqltext {
  min-height: 120px;
  height: 28%;
  resize: vertical;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  font:
    13px/1.6 Consolas,
    monospace;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
}
.sqlhint {
  font-size: 12px;
}
.sqlresulthead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-top: 0;
  font-size: 12px;
}
#sqlstale {
  color: #9a6a1f;
}
#sqlresult {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
  outline: none;
}
#sqlresult td {
  user-select: text;
}
#sqlresult td:first-child {
  user-select: none;
}
#sqlmessages {
  margin: 0;
  list-style: none;
  padding: 6px 12px;
  max-height: 120px;
  overflow: auto;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  font:
    12px/1.6 Consolas,
    monospace;
  color: #4d5f55;
}
#sqlmessages li[data-error='true'] {
  color: #b23b2e;
}
#sqlmessages:empty {
  display: none;
}
/* FR-082 CSV import modal */
#dialog.wide-dialog {
  width: min(920px, 95vw);
}
#dialog.wide-dialog #dialogbody {
  max-height: 70vh;
}
#dialogbody .imp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
#dialogbody .imp-row label,
#dialogbody .impcol-item label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}
#dialogbody input[type='radio'] {
  width: auto;
}
#dialogbody .imp-row input:not([type='checkbox']):not([type='radio']) {
  width: 170px;
}
#dialogbody .imp-row select {
  width: auto;
  max-width: 180px;
}
.imp-colhead {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-size: 12px;
}
.imp-colhead button {
  padding: 4px 8px;
  font-size: 12px;
}
.impcolumns {
  max-height: 145px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fafcfb;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.impcol-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.impcol-src {
  min-width: 110px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #5c7165;
  font-family: Consolas, monospace;
}
#dialogbody .impcol-item input:not([type='checkbox']) {
  width: 180px;
  padding: 4px 8px;
  font-size: 12px;
}
#dialogbody .impcol-item select {
  width: auto;
  max-width: 160px;
  padding: 4px 8px;
  font-size: 12px;
}
.impnotes {
  margin: 6px 0 0;
  padding: 6px 10px;
  background: #f3f7f4;
  border-radius: 6px;
  font-size: 12px;
  color: #3d5a4b;
}
.impproblems {
  margin: 6px 0 0;
  padding: 6px 12px 6px 26px;
  max-height: 90px;
  overflow: auto;
  background: #fdf2f0;
  border: 1px solid #ecc6c0;
  border-radius: 6px;
  font-size: 12px;
  color: #a12c20;
}
.imppreview {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 6px;
}
.imppreview th,
.imppreview td {
  min-width: 90px;
  max-width: 220px;
  width: auto;
  height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}
.imppreview td[data-bad='true'] {
  background: #fde8e5;
  color: #a12c20;
  font-weight: 600;
}
/* FR-083 / FR-084 Schema & index management */
.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}
.dbsidebar .sidebar-actions button {
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
  padding: 5px 6px;
  font-size: 11px;
  margin: 0;
  border-radius: 6px;
}
.schemaobjects {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}
.schemaobjects th,
.schemaobjects td {
  height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  user-select: text;
}
.schemaobjects td button {
  padding: 3px 8px;
  font-size: 11px;
  margin-right: 4px;
}
#schemaview #schema {
  flex: 0 0 38%;
  min-height: 110px;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}
.schcolumns {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #fafcfb;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.schcol-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: #fff;
  border: 1px solid #e5ebe7;
  border-radius: 6px;
  font-size: 12px;
}
#dialogbody .schcol-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  white-space: nowrap;
}
#dialogbody .schcol-row input:not([type='checkbox']) {
  width: 110px;
  padding: 4px 6px;
  font-size: 12px;
}
#dialogbody .schcol-row input[data-sch-default],
#dialogbody .schcol-row input[data-sch-check] {
  width: 120px;
}
#dialogbody .schcol-row select {
  width: auto;
  max-width: 125px;
  padding: 4px 6px;
  font-size: 12px;
}
.schcol-row button {
  padding: 3px 7px;
  font-size: 11px;
}
.schconstraints {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 6px;
}
.schtc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
#dialogbody .schtc-row select {
  width: auto;
  max-width: 130px;
  padding: 4px 6px;
  font-size: 12px;
}
#dialogbody .schtc-row input {
  width: 150px;
  padding: 4px 6px;
  font-size: 12px;
}
.schtc-row button {
  padding: 3px 8px;
  font-size: 11px;
}
