:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #10201a;
  --muted: #5a6a64;
  --line: #dce5e1;
  --brand: #0d8a64;
  --brand-soft: #d9f5eb;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 5%, #d5efe4 0%, transparent 30%),
    radial-gradient(circle at 95% 0%, #ffe9d6 0%, transparent 25%),
    var(--bg);
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 800; margin-right: 1rem; }
.nav a { text-decoration: none; color: var(--ink); font-weight: 600; }
.logout-form { margin-left: auto; }

.container {
  width: min(1200px, 94vw);
  margin: 1.5rem auto 3rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(14, 56, 41, 0.07);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.card {
  background: linear-gradient(145deg, #fff, #f1faf6);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.card strong { font-size: 1.5rem; }
.muted { color: var(--muted); }

.form-grid {
  display: grid;
  gap: 0.55rem;
}

input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.6rem 0.75rem;
}

.btn {
  border: 1px solid var(--line);
  cursor: pointer;
  background: #fff;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
}

.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.86rem; }
.btn-danger { background: #fee4e2; color: var(--danger); border-color: #f7c8c1; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 0.4rem;
  text-align: left;
}

.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.success { background: var(--brand-soft); color: var(--brand); }
.badge.failed { background: #fde3df; color: var(--danger); }
.badge.running { background: #fff3cd; color: #7d5b00; }

.alert {
  border-radius: 10px;
  padding: 0.7rem;
  margin: 0.7rem 0;
}

.alert-error { background: #fee4e2; color: var(--danger); }
.alert-success { background: var(--brand-soft); color: var(--brand); }

.hidden { display: none; }

.progress-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfa;
  padding: 0.8rem;
  margin-bottom: 0.9rem;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #e6efeb;
  border-radius: 999px;
  overflow: hidden;
}

#progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0d8a64, #26b181);
  transition: width 0.2s ease;
}

.progress-log {
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 170px;
  overflow: auto;
  padding: 0.6rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.progress-log div + div { margin-top: 0.4rem; }

.jobs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.explorer-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}

.crumbs-wrap {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  background: #fff;
}

.crumbs {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.crumb-link {
  color: #0d8a64;
  text-decoration: none;
  font-weight: 600;
}

.crumb-link:hover {
  text-decoration: underline;
}

.version-list {
  display: grid;
  gap: 0.45rem;
}

.version-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #fff;
}

.version-item a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.version-item.active {
  border-color: #8cd5bd;
  background: #effbf5;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.65rem;
  background: #fff;
}

.file-item:last-child { border-bottom: none; }
.file-item.active { background: #effbf5; }
.file-item small { color: var(--muted); }

.center-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fff;
}

.preview-wide {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fff;
}

.preview-tools {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0.8rem 0;
}

.sql-preview {
  margin: 0;
  background: #0f1d18;
  color: #c9f6e3;
  border-radius: 12px;
  padding: 0.9rem;
  width: 100%;
  min-height: 62vh;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid #29463c;
  font-size: 0.83rem;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(430px, 95vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.3rem;
  box-shadow: 0 14px 32px rgba(14, 56, 41, 0.08);
}

@media (max-width: 900px) {
  .grid-2,
  .cards,
  .explorer-grid {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
