:root {
  --bg-0: #f7f3eb;
  --bg-1: #fffdf8;
  --ink-0: #182129;
  --ink-1: #41505d;
  --line: #d8d9d2;
  --accent-0: #0d8a8f;
  --accent-1: #f17c3a;
  --accent-2: #1e405c;
  --good: #0f6b3b;
  --bad: #a33d2b;
  --card-shadow: 0 20px 40px rgba(20, 30, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", sans-serif;
  color: var(--ink-0);
  background: linear-gradient(170deg, var(--bg-0), var(--bg-1) 55%, #f2f7f8);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.18;
  z-index: 0;
}

.shape-1 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, var(--accent-0), transparent 70%);
  top: -130px;
  right: -160px;
}

.shape-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--accent-1), transparent 70%);
  left: -170px;
  bottom: -170px;
}

.container {
  width: min(1180px, 92vw);
  margin: 26px auto 40px;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
}

.hero {
  padding: 18px 6px 4px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  font-family: "Azeret Mono", monospace;
  font-size: 0.8rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent-0);
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 800;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.6rem, 3.5vw, 2.8rem);
  line-height: 1.03;
}

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

.sub,
.helper {
  margin: 8px 0 0;
  color: var(--ink-1);
  font-size: 0.93rem;
}

.card {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  border-radius: 16px;
  padding: 16px;
}

#dashboard-shell {
  display: grid;
  gap: 16px;
}

.filters h2 {
  margin-bottom: 12px;
}

.auth-card {
  max-width: 560px;
}

.auth-tabs {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: #edf3f1;
  color: var(--ink-0);
  border: 1px solid #c5d5d0;
  width: auto;
  padding: 8px 12px;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent-0), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

.auth-form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.upload-card h2 {
  margin-bottom: 8px;
}

.upload-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.5fr auto;
  gap: 10px;
  align-items: end;
}

.upload-status {
  margin-top: 10px;
  border: 1px solid #d3ddd7;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.82rem;
  background: #f6fbf8;
  color: #25423a;
}

.upload-status.warning {
  border-color: #e9c187;
  background: #fff8e8;
  color: #674f17;
}

.upload-status.error {
  border-color: #e8a49a;
  background: #fff1ee;
  color: #6d2c1f;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-1);
  font-weight: 600;
}

input,
select,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #c7cfcf;
  padding: 10px 11px;
  font-family: "Azeret Mono", monospace;
  font-size: 0.82rem;
}

button {
  align-self: end;
  background: linear-gradient(135deg, var(--accent-0), var(--accent-2));
  color: #fff;
  cursor: pointer;
  border: none;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.04);
}

.outline-btn {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid #9bb7c8;
  min-width: 80px;
  font-family: "Sora", sans-serif;
  padding: 8px 12px;
}

.outline-btn:hover {
  background: #f0f8ff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: linear-gradient(150deg, #ffffff, #f4faf9);
}

.kpi-label {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.8rem;
  font-weight: 700;
}

.kpi-value {
  margin: 8px 0 0;
  font-family: "Azeret Mono", monospace;
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
}

.chart {
  margin-top: 10px;
  width: 100%;
  min-height: 230px;
}

.chart svg {
  width: 100%;
  height: 240px;
}

.bar-chart {
  margin-top: 12px;
  display: grid;
  gap: 7px;
}

.bar-row {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  align-items: center;
  gap: 10px;
  font-family: "Azeret Mono", monospace;
  font-size: 0.75rem;
}

.bar {
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-0), var(--accent-1));
  transform-origin: left center;
  animation: grow 540ms ease-out both;
}

.bar-empty {
  background: #d8dfdc;
}

@keyframes grow {
  from {
    transform: scaleX(0.12);
    opacity: 0.4;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

.compare-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#compare-table {
  margin-top: 12px;
}

#compare-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

#compare-table th,
#compare-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px 4px;
  font-family: "Azeret Mono", monospace;
}

.delta-pos {
  color: var(--good);
}

.delta-neg {
  color: var(--bad);
}

.table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

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

thead th {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 4px;
  color: var(--ink-1);
  font-family: "Azeret Mono", monospace;
}

tbody td {
  border-bottom: 1px solid #eceee8;
  padding: 9px 4px;
}

tbody tr:hover {
  background: #f4fbfa;
}

.error {
  border-color: #e8a49a;
  background: #fff1ee;
  color: #6d2c1f;
}

.hidden {
  display: none;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 420ms ease forwards;
}

.reveal:nth-child(2) {
  animation-delay: 60ms;
}
.reveal:nth-child(3) {
  animation-delay: 110ms;
}
.reveal:nth-child(4) {
  animation-delay: 150ms;
}
.reveal:nth-child(5) {
  animation-delay: 180ms;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .hero-top {
    flex-direction: column;
    align-items: stretch;
  }
  .user-panel {
    justify-content: space-between;
  }
  .upload-controls {
    grid-template-columns: 1fr;
  }
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(1180px, 95vw);
  }
  .filter-grid,
  .compare-controls {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: 58px 1fr auto;
  }
}
