:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #162033;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b42318;
  --success: #047857;
}

* {
  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 {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 36px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 16px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.upload-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.drop-zone {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 154px;
  align-content: center;
  padding: 22px;
  border: 1px dashed #9aa8bd;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-title {
  font-size: 19px;
  font-weight: 800;
}

.drop-copy {
  color: var(--muted);
  line-height: 1.45;
}

.drop-zone input {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  max-width: 100%;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
}

.upload-panel .primary-button {
  width: 100%;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.ghost-button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
}

.message {
  min-height: 22px;
  color: var(--muted);
  line-height: 1.45;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.stats small {
  color: var(--muted);
}

.section-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.section-heading input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-list {
  display: grid;
  gap: 10px;
  max-height: 46vh;
  overflow: auto;
  padding-right: 2px;
}

.table-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.table-summary strong {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.table-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.table-summary ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.canvas {
  min-height: calc(100vh - 220px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.canvas.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.erd-svg {
  display: block;
  min-width: 100%;
}

.table-card rect {
  fill: #ffffff;
  stroke: #cbd5e1;
}

.table-card .header {
  fill: #1e293b;
}

.table-card text {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.table-title {
  fill: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.column-name {
  fill: #1f2937;
  font-size: 13px;
}

.column-meta {
  fill: #64748b;
  font-size: 12px;
}

.relationship-line {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2;
}

@media (max-width: 880px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .table-list {
    max-height: none;
  }
}
