:root {
  --bg: #f3f8ff;
  --panel: #ffffff;
  --ink: #0f2342;
  --muted: #4f6689;
  --line: #d9e4f4;
  --accent: #005f99;
  --accent-soft: #d9f0ff;
  --danger: #9d2f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, #eaf5ff 0%, #f7fbff 50%, #eef2ff 100%);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 164, 255, 0.12), transparent 34%),
    radial-gradient(circle at 88% 2%, rgba(45, 130, 255, 0.12), transparent 28%);
  z-index: 0;
}

.atlas-shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 2rem));
  margin: 1.2rem auto 2.2rem;
  display: grid;
  gap: 0.95rem;
}

.atlas-top {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(125deg, #ffffff, #f3faff);
  padding: 1rem 1.1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-size: 0.73rem;
}

h1 {
  margin: 0.25rem 0 0.35rem;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

h2 {
  margin: 0;
  font-size: 1.07rem;
}

h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.top-actions {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 0.95rem;
  display: grid;
  gap: 0.7rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

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

.kpi {
  border: 1px solid #e4edf9;
  border-radius: 13px;
  padding: 0.6rem;
  background: linear-gradient(145deg, #ffffff, #f7fbff);
}

.kpi-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.kpi-value {
  margin-top: 0.15rem;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

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

.chart-card {
  border: 1px solid #e6eef8;
  border-radius: 12px;
  padding: 0.6rem;
  display: grid;
  gap: 0.5rem;
}

.bar-stack {
  display: grid;
  gap: 0.38rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.bar-main {
  min-width: 0;
}

.bar-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  width: 100%;
  margin-top: 0.2rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #edf3fb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0082d0, #00a2c7);
}

.bar-value {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: right;
  min-width: 5.5rem;
}

button,
.ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 0.44rem 0.74rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.ghost:hover {
  border-color: #b8cae4;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  background: #fff;
  color: var(--ink);
  min-width: 180px;
}

.pager {
  margin-left: auto;
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

#pageLabel {
  font-size: 0.84rem;
  color: var(--muted);
  min-width: 8ch;
  text-align: center;
}

.table-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #e4edf9;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid #edf2fa;
  text-align: left;
  padding: 0.5rem 0.55rem;
  vertical-align: top;
  font-size: 0.8rem;
}

th {
  position: sticky;
  top: 0;
  background: #f8fbff;
  z-index: 1;
  color: #2a4a74;
  font-weight: 700;
}

tbody tr:nth-child(2n) td {
  background: #fbfdff;
}

td {
  white-space: pre-wrap;
  word-break: break-word;
}

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

.metadata-item {
  border: 1px solid #e4edf8;
  border-radius: 11px;
  padding: 0.52rem;
  background: #fbfdff;
}

.metadata-key {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.metadata-value {
  margin-top: 0.2rem;
  font-size: 0.84rem;
  line-height: 1.4;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.empty {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metadata-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .atlas-shell {
    width: calc(100% - 1rem);
  }

  .atlas-top {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .pager {
    margin-left: 0;
  }
}
