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

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f5f5f5;
  --border: #e0e0e0;
  --border-dark: #cccccc;
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #888888;
  --accent: #000000;
  --accent-light: #333333;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

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

.logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.logo svg {
  width: 20px;
  height: 20px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header h1 span {
  color: var(--text-muted);
  font-weight: 400;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.btn:hover {
  border-color: var(--border-dark);
  background: var(--bg-tertiary);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.main {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

@media (max-width: 1024px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

.sidebar {
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

@media (max-width: 1024px) {
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 0;
}

.column-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.column-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.15s ease, box-shadow 0.15s ease, margin 0.2s ease;
}

.column-card:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow);
}

.column-card.dragging {
  opacity: 0.4;
  transform: scale(0.98);
  pointer-events: none;
}

.column-card.drag-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.column-card.drop-target-above {
  margin-top: calc(var(--dragged-card-height, 52px) + 10px);
}

.drop-indicator-end {
  height: var(--dragged-card-height, 42px);
  margin-top: 10px;
}

.column-card-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.column-card-header:active {
  cursor: grabbing;
}

.drag-handle {
  color: var(--text-muted);
  display: flex;
  flex-shrink: 0;
  cursor: grab;
  padding: 4px;
  margin: -4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.drag-handle:hover {
  color: var(--text-secondary);
  background: var(--bg-primary);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 12px;
  height: 12px;
}

.column-name-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  min-width: 0;
}

.column-name-input::placeholder {
  color: var(--text-muted);
}

.column-type-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.delete-column-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  display: flex;
  transition: all 0.15s ease;
}

.delete-column-btn:hover {
  color: #dc2626;
  background: #fef2f2;
}

.delete-column-btn svg {
  width: 12px;
  height: 12px;
}

.column-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.form-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-width: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.form-select {
  cursor: pointer;
  padding-right: 32px;
  background: var(--bg-primary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%234a4a4a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.form-select:hover {
  border-color: var(--border-dark);
  background: var(--bg-tertiary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%234a4a4a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}

.form-select:focus {
  background: var(--bg-primary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%231a1a1a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}

.form-textarea {
  resize: vertical;
  min-height: 50px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.form-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 13px;
}

.content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
  min-height: 0;
  height: 100%;
}

.toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-primary);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.toolbar-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.row-count-input {
  width: 80px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

.row-count-input:focus {
  border-color: var(--accent);
}

.preset-select {
  min-width: 140px;
  padding-right: 32px;
  background: var(--bg-primary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%234a4a4a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-select:hover {
  border-color: var(--border-dark);
  background: var(--bg-tertiary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%234a4a4a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}

.preset-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
  background: var(--bg-primary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5L6 8L9.5 4.5' stroke='%231a1a1a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}

.preview-container {
  flex: 1;
  overflow: auto;
  padding: 20px;
  min-height: 120px;
}

.preview-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  box-shadow: var(--shadow);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-table tr:last-child td {
  border-bottom: none;
}

.preview-table tr:hover td {
  background: var(--bg-tertiary);
}

.resize-divider {
  height: 6px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.resize-divider::after {
  content: '';
  width: 32px;
  height: 3px;
  background: var(--border-dark);
  border-radius: 2px;
}

.resize-divider:hover,
.resize-divider.dragging {
  background: var(--border);
}

.resize-divider:hover::after,
.resize-divider.dragging::after {
  background: var(--text-muted);
}

.stats-panel {
  padding: 16px 20px;
  background: var(--bg-primary);
  overflow-y: auto;
  flex-shrink: 0;
  min-height: 80px;
  height: 150px;
}

.stats-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat-column-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

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

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 500;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.type-option {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.type-option:hover {
  border-color: var(--border-dark);
  background: var(--bg-tertiary);
}

.type-option.selected {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.type-option-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 3px;
}

.type-option-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1001;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left: 3px solid var(--accent);
}

.toast-icon {
  display: flex;
}

.toast-icon svg {
  width: 18px;
  height: 18px;
}

.toast-message {
  font-size: 13px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}

.sidebar-content,
.preview-container,
.stats-panel,
.preview-table-wrapper {
  scrollbar-color: transparent transparent;
}

.sidebar-content:hover,
.preview-container:hover,
.stats-panel:hover,
.preview-table-wrapper:hover {
  scrollbar-color: var(--border-dark) transparent;
}

.sidebar-content:hover::-webkit-scrollbar-thumb,
.preview-container:hover::-webkit-scrollbar-thumb,
.stats-panel:hover::-webkit-scrollbar-thumb,
.preview-table-wrapper:hover::-webkit-scrollbar-thumb {
  background: var(--border-dark);
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.preview-container::-webkit-scrollbar-thumb:hover,
.stats-panel::-webkit-scrollbar-thumb:hover,
.preview-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }

  .header h1 {
    font-size: 15px;
  }

  .toolbar {
    padding: 10px 16px;
  }

  .preview-container {
    padding: 16px;
  }

  .stats-panel {
    padding: 12px 16px;
  }

  .type-grid {
    grid-template-columns: 1fr;
  }
}