:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8faff;
  --text: #1f2a44;
  --muted: #6b7894;
  --primary: #5f8cff;
  --primary-2: #7ea2ff;
  --border: rgba(31, 42, 68, 0.12);
  --shadow: 0 10px 28px rgba(25, 40, 72, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #e7efff 0%, var(--bg) 48%);
}

button {
  font: inherit;
  color: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--surface) 0%, #f5f8ff 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.brand__logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c4dff);
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand__text h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.brand__text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar__nav {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 1px solid transparent;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.nav-item.active {
  background: linear-gradient(
    180deg,
    rgba(95, 140, 255, 0.2),
    rgba(95, 140, 255, 0.08)
  );
  border-color: rgba(126, 162, 255, 0.5);
}

.nav-item__icon {
  width: 20px;
  text-align: center;
}

.nav-item__label {
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar__footer {
  margin-top: auto;
  padding: 12px 10px 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.main {
  display: grid;
  grid-template-rows: 74px 1fr;
  min-width: 0;
}

.header {
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__left h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.user-chip {
  margin-left: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
}

.user-chip__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5f8cff, #38d4d9);
  font-weight: 700;
  font-size: 0.76rem;
}

.user-chip__meta {
  display: grid;
  line-height: 1.1;
}

.user-chip__meta strong {
  font-size: 0.82rem;
}

.user-chip__meta small {
  color: var(--muted);
  font-size: 0.72rem;
}

.content {
  padding: 20px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.card {
  background: linear-gradient(180deg, var(--surface-2), #ffffff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
}

.card .value {
  font-size: 1.5rem;
  font-weight: 800;
}

.card .hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.two-col {
  margin-top: 16px;
  grid-template-columns: 2fr 1fr;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.success {
  background: rgba(53, 211, 154, 0.18);
  color: #1f8f67;
}

.badge.warning {
  background: rgba(255, 181, 71, 0.18);
  color: #a96a0f;
}

.badge.danger {
  background: rgba(255, 107, 129, 0.18);
  color: #b9334a;
}

.progress-list {
  display: grid;
  gap: 12px;
}

.progress-item .top {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #dce6fa;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.kicker {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.settings-layout {
  grid-template-columns: 1fr 1fr;
}

.integrations-grid {
  margin-top: 16px;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.integration-card {
  display: grid;
  gap: 10px;
}

.integration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.82rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: rgba(95, 140, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(95, 140, 255, 0.15);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  border-color: rgba(95, 140, 255, 0.45);
  background: linear-gradient(180deg, #f2f6ff, #e8efff);
}

.btn-danger {
  border-color: rgba(185, 51, 74, 0.25);
  color: #b9334a;
}

.status-line {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pill.connected {
  background: rgba(53, 211, 154, 0.16);
  color: #1f8f67;
}

.status-pill.pending {
  background: rgba(255, 181, 71, 0.18);
  color: #a96a0f;
}

.etl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.etl-connect-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.etl-log-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.etl-log-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: #ffffff;
  font-size: 0.82rem;
  color: var(--text);
}

.modeling-layout {
  grid-template-columns: 1.2fr 1fr;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.76rem;
  background: #ffffff;
  color: var(--text);
}

.mapping-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.json-box {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px;
  overflow: auto;
  max-height: 280px;
  font-size: 0.78rem;
  line-height: 1.45;
}

.bi-filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 12px;
  align-items: end;
}

.bi-chart-grid {
  margin-top: 16px;
  grid-template-columns: 1.4fr 1fr;
}

.bi-chart-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.bi-chart-wrapper {
  position: relative;
  height: 280px;
  min-height: 280px;
  max-height: 280px;
  overflow: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: 0.2s ease;
  z-index: 20;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1200px) {
  .stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .modeling-layout {
    grid-template-columns: 1fr;
  }

  .bi-chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 30;
    transition: left 0.24s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .user-chip__meta {
    display: none;
  }

  .header {
    padding: 0 14px;
  }

  .content {
    padding: 14px;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .integrations-grid {
    grid-template-columns: 1fr;
  }

  .etl-connect-grid {
    grid-template-columns: 1fr;
  }

  .etl-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .bi-filter-bar {
    grid-template-columns: 1fr;
  }
}
