:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-sidebar: rgba(13, 19, 33, 0.96);
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-subtle: rgba(22, 31, 50, 0.6);
  --bg-input: rgba(15, 23, 42, 0.95);
  --bg-table-header: #131b2e;
  --bg-table-row-even: rgba(255, 255, 255, 0.015);
  --bg-table-row-hover: rgba(99, 102, 241, 0.08);
  --bg-table-cell-active: rgba(99, 102, 241, 0.18);
  --bg-table-cell-dirty: rgba(245, 158, 11, 0.18);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-light: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.12);

  --color-success: #10b981;
  --color-success-hover: #059669;
  --color-success-bg: rgba(16, 185, 129, 0.14);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.14);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --sidebar-width: 280px;
  --header-height: 58px;
  --statusbar-height: 32px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-sidebar: rgba(255, 255, 255, 0.96);
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-subtle: rgba(241, 245, 249, 0.9);
  --bg-input: #ffffff;
  --bg-table-header: #e2e8f0;
  --bg-table-row-even: rgba(0, 0, 0, 0.015);
  --bg-table-row-hover: rgba(99, 102, 241, 0.07);
  --bg-table-cell-active: rgba(99, 102, 241, 0.14);
  --bg-table-cell-dirty: rgba(245, 158, 11, 0.2);

  --border-color: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.25);
  --accent-light: #6366f1;
  --accent-bg: rgba(79, 70, 229, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Background Glowing Orbs */
.bg-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb-1 {
  position: absolute;
  top: -10%;
  right: 15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  filter: blur(80px);
}

.aurora-orb-2 {
  position: absolute;
  bottom: 5%;
  left: 10%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
  filter: blur(80px);
}

/* Header */
.portal-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  flex-shrink: 0;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 22px;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-tag {
  background: var(--accent-bg);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.back-home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.back-home-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-success {
  background: var(--color-success);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--color-success-hover);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.badge-dirty {
  background: var(--color-warning);
  color: #000;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  display: inline-block;
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Layout Body */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-info-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.db-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.db-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-badge-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
}

.db-badge-local {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.db-badge-memory {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.sidebar-search-box {
  position: relative;
}

.sidebar-search-input {
  width: 100%;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 0 10px;
  outline: none;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: var(--border-focus);
}

.sidebar-nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}

.tree-section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 6px 8px 4px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
}

.tree-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.tree-item.active {
  background: var(--accent-bg);
  color: var(--accent-light);
  font-weight: 600;
}

.tree-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.tree-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

/* Main Content Workspace */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Tabs Bar */
.workspace-tabs {
  height: 42px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  flex-shrink: 0;
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--accent-light);
  background: var(--bg-card);
  border-bottom: 2px solid var(--accent-primary);
  font-weight: 600;
}

/* Tab Panes */
.tab-content-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
}

/* Data Grid Toolbar */
.grid-toolbar {
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.grid-toolbar-left, .grid-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-search-input {
  height: 32px;
  width: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 0 10px;
  outline: none;
}

.grid-search-input:focus {
  border-color: var(--border-focus);
}

/* Table Grid Wrapper */
.grid-table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-primary);
}

.navicat-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-family: var(--font-sans);
}

.navicat-table th {
  position: sticky;
  top: 0;
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  z-index: 2;
}

.navicat-table th:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.navicat-table th.sort-asc::after {
  content: " ▲";
  font-size: 10px;
  color: var(--accent-light);
}

.navicat-table th.sort-desc::after {
  content: " ▼";
  font-size: 10px;
  color: var(--accent-light);
}

.navicat-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  color: var(--text-primary);
  transition: background-color 0.1s;
}

.navicat-table tr:nth-child(even) td {
  background: var(--bg-table-row-even);
}

.navicat-table tr:hover td {
  background: var(--bg-table-row-hover);
}

.navicat-table td.col-pk {
  font-weight: 600;
  color: var(--accent-light);
}

.navicat-table td.cell-null {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}

.navicat-table td.cell-dirty {
  background: var(--bg-table-cell-dirty) !important;
  box-shadow: inset 0 0 0 1px var(--color-warning);
}

.navicat-table tr.row-new td {
  background: var(--color-success-bg) !important;
}

.navicat-table tr.row-deleted td {
  text-decoration: line-through;
  opacity: 0.5;
  background: var(--color-danger-bg) !important;
}

.navicat-table td.cell-editing {
  padding: 0;
  background: var(--bg-input) !important;
}

.inline-editor-input {
  width: 100%;
  height: 100%;
  padding: 6px 12px;
  border: 2px solid var(--accent-primary);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

/* Pagination Bar */
.grid-pagination-bar {
  height: 40px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* SQL Console */
.sql-console-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sql-editor-wrapper {
  height: 220px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.sql-toolbar {
  height: 38px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sql-textarea {
  flex: 1;
  width: 100%;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg-input);
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: none;
}

.sql-result-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sql-result-header {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Schema Designer */
.schema-designer-container {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.schema-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.schema-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ddl-code-block {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Diff Tab */
.diff-container {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.diff-drop-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px 16px;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-bg);
}

.drop-zone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.drop-zone-title {
  font-size: 14px;
  font-weight: 600;
}

.drop-zone-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Mock & Import Tabs */
.tool-pane-container {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-select, .form-input {
  width: 100%;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.form-select:focus, .form-input:focus {
  border-color: var(--border-focus);
}

/* Status Bar */
.portal-statusbar {
  height: var(--statusbar-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 10;
  flex-shrink: 0;
}

.statusbar-left, .statusbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 42px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.25s ease-out;
}

.toast.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast.toast-warning {
  border-left: 4px solid var(--color-warning);
}

.toast.toast-error {
  border-left: 4px solid var(--color-danger);
}

@keyframes toast-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 540px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
