/* App chrome: topbar, table tabs, sidebar, toolbar */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 900px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-m);
  color: var(--t2);
  flex: 0 0 auto;
  transition: background 90ms ease, color 90ms ease;
}
.icon-btn:hover { background: #ececee; color: var(--t1); }
.icon-btn:active { background: #e2e2e5; }
.icon-btn.sm { width: 22px; height: 22px; }
.icon-btn.danger:hover { background: #fdeceb; color: #d02b20; }

/* ================= top bar ================= */
.topbar {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 14px 0 10px;
  border-bottom: 1px solid var(--b1);
  background: #fff;
  gap: 10px;
  flex: 0 0 auto;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-left { flex: 1; min-width: 0; }
.topbar .spacer { flex: 1; }

.base-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-m);
  color: #fff;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
}

.base-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
}
.base-desc {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 2px;
}
.share-btn { border: 1px solid var(--b1); }
.share-btn:hover { background: #f2f2f4; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #7b61ff;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.avatar:hover { filter: brightness(0.94); }

/* ================= table tabs ================= */
.tabsbar {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
  padding: 6px 10px 0;
  background: #f0f0f2;
  border-bottom: 1px solid var(--b1);
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabsbar::-webkit-scrollbar { display: none; }

.table-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px 0 12px;
  border-radius: 7px 7px 0 0;
  color: var(--t2);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background 90ms ease, color 90ms ease;
  user-select: none;
}
.table-tab:hover { background: rgba(255,255,255,0.55); color: var(--t1); }
.table-tab.active {
  background: #fff;
  color: var(--t1);
  font-weight: 500;
}
.table-tab.dragging { opacity: 0.6; }
.table-tab.drop-left::before, .table-tab.drop-right::after {
  content: '';
  position: absolute;
  top: 6px; bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--blue);
}
.table-tab.drop-left::before { left: -2px; }
.table-tab.drop-right::after { right: -2px; }

.table-tab-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.table-tab-name { max-width: 160px; }
.add-table { margin-bottom: 4px; margin-left: 4px; }

/* ================= layout ================= */
.main-area {
  display: flex;
  flex: 1;
  min-height: 0;
}
.sidebar-holder {
  width: 224px;
  flex: 0 0 auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--b1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.view-holder { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.view-holder-grid { display: block; }

/* ================= sidebar ================= */
.sidebar { display: flex; flex-direction: column; height: 100%; }

.sidebar-head {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--b3);
}
.sidebar-table-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-m);
  color: var(--t1);
  transition: background 90ms ease;
  text-align: left;
}
.sidebar-table-btn:hover { background: #efeff1; }
.sidebar-table-btn .ellipsis { flex: 1; font-size: 13.5px; }
.sidebar-table-btn .chev { color: var(--t3); }

.sidebar-body { flex: 1; overflow-y: auto; padding: 8px 6px 16px; }
.sidebar-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--t4);
  padding: 8px 10px 4px;
  text-transform: uppercase;
}

.view-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 6px 0 10px;
  border-radius: var(--radius-m);
  color: var(--t2);
  cursor: pointer;
  user-select: none;
  transition: background 90ms ease, color 90ms ease;
}
.view-row:hover { background: #efeff1; color: var(--t1); }
.view-row.active {
  background: #e3edff;
  color: #1a5fd0;
}
.view-row.active .view-icon { color: #2d7ff9; }
.view-icon { display: inline-flex; color: var(--t3); }
.view-row.active .view-name { font-weight: 500; }
.view-name { flex: 1; min-width: 0; }
.view-more { opacity: 0; width: 22px; height: 22px; }
.view-row:hover .view-more { opacity: 1; }

.sidebar-add-view {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  margin: 2px 6px 0;
  padding: 0 6px 0 10px;
  border-radius: var(--radius-m);
  color: var(--t3);
  font-size: 13px;
  transition: background 90ms ease, color 90ms ease;
}
.sidebar-add-view:hover { background: #efeff1; color: var(--t1); }

/* ================= toolbar ================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--b2);
  background: #fff;
  flex: 0 0 auto;
}
.toolbar-left { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow: hidden; }
.toolbar-right { display: flex; align-items: center; gap: 6px; position: relative; }

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-m);
  color: var(--t2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 90ms ease, color 90ms ease;
}
.tool-btn:hover { background: #f0f0f2; color: var(--t1); }
.tool-btn.active { color: #1a5fd0; background: #e3edff; }
.tool-btn.active svg { color: #2d7ff9; }

.toolbar-search {
  width: 190px;
  height: 30px;
  padding: 0 10px 0 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: #f0f0f2;
  outline: none;
  font-size: 12.5px;
  color: var(--t1);
  transition: width 160ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.toolbar-search::placeholder { color: var(--t3); }
.toolbar-search:focus {
  width: 240px;
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-ring);
}
.search-icon {
  position: absolute;
  left: 9px;
  top: 8px;
  color: var(--t3);
  pointer-events: none;
  display: inline-flex;
}
.search-clear { position: absolute; right: 8px; top: 4px; width: 22px; height: 22px; }

.toolbar-form-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--t2);
  font-size: 12.5px;
}
.toolbar-form-note svg { color: var(--blue); }
