:root {
  --bg: #0b1020;
  --bg-soft: #131a2e;
  --surface: #161f36;
  --surface-2: #1d2947;
  --line: #2c3a61;
  --text: #eaf0ff;
  --muted: #9badcf;
  --accent: #38bdf8;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 8%, rgba(56, 189, 248, 0.16), transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(52, 211, 153, 0.12), transparent 24%),
    linear-gradient(180deg, #0a0f1d 0%, #0b1020 55%, #0e1529 100%);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.bg-shape {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(70px);
  z-index: -1;
  opacity: 0.35;
}

.shape-a {
  width: 300px;
  height: 300px;
  left: -80px;
  top: 140px;
  background: rgba(56, 189, 248, 0.24);
}

.shape-b {
  width: 280px;
  height: 280px;
  right: -90px;
  top: 40px;
  background: rgba(52, 211, 153, 0.22);
}

.shell {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
  display: grid;
  gap: 14px;
}

.card {
  background: linear-gradient(180deg, rgba(31, 44, 76, 0.86) 0%, rgba(22, 31, 54, 0.88) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1.1;
}

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

.lede {
  margin: 8px 0 0;
  color: var(--muted);
}

.hero-actions,
.analysis-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

.tab.is-active {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(56, 189, 248, 0.06));
}

.view {
  display: none;
  gap: 14px;
}

.view.is-active {
  display: grid;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.stack {
  display: grid;
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.form-grid,
.analysis-grid,
.kpi-grid,
.items,
.analysis-result {
  display: grid;
  gap: 10px;
}

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

.form-grid .full,
.analysis-grid .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
}

label > span {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #3a4b77;
  border-radius: 12px;
  padding: 10px 11px;
  background: #0f1730;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 13px;
  color: #041225;
  background: linear-gradient(135deg, #67e8f9 0%, #38bdf8 100%);
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: #1c2743;
  color: var(--text);
  border-color: #3a4b77;
}

button.small {
  padding: 7px 10px;
  font-size: 0.85rem;
}

.muted,
.analysis-help,
.meta,
.note,
.empty,
.analysis-row span {
  color: var(--muted);
}

.items {
  gap: 12px;
}

.item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(19, 26, 46, 0.85);
  padding: 10px;
}

.item h3 {
  margin: 0;
  font-size: 1rem;
}

.item img,
.item-placeholder {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
}

.item-placeholder {
  display: grid;
  place-items: center;
  background: #111931;
  border: 1px dashed #3a4b77;
  font-size: 0.85rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 6px;
  font-size: 0.85rem;
}

.note {
  margin-top: 8px;
  font-size: 0.9rem;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 23, 48, 0.75);
  padding: 12px;
  display: grid;
  gap: 4px;
}

.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat strong {
  font-size: 1.1rem;
}

.stat-accent {
  border-color: rgba(56, 189, 248, 0.7);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.18), rgba(15, 23, 48, 0.8));
}

.category-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.category-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 48, 0.7);
}

.category-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.analysis-chart {
  display: grid;
  gap: 10px;
}

.chart-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-legend-item i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.chart-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: rgba(15, 23, 48, 0.68);
}

.analysis-group,
.list-box > .analysis-row,
#analysis-outliers .analysis-row,
#analysis-top-categories .analysis-row,
#analysis-top-merchants .analysis-row,
#analysis-trend .analysis-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 23, 48, 0.68);
}

.analysis-group,
.list-box > .analysis-row,
#analysis-outliers .analysis-row,
#analysis-top-categories .analysis-row,
#analysis-top-merchants .analysis-row,
#analysis-trend .analysis-row {
  padding: 10px;
}

.analysis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.analysis-row > div {
  display: grid;
  gap: 2px;
}

.analysis-row.top strong:first-child {
  color: var(--accent);
}

.error-text {
  color: var(--danger);
  min-height: 1.2em;
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 24, 0.72);
  display: grid;
  place-items: center;
  z-index: 10;
}

.auth-card {
  width: min(420px, calc(100% - 20px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #121b33;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 8px;
}

.auth-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero,
  .two-up,
  .form-grid,
  .analysis-grid,
  .kpi-grid,
  .item {
    grid-template-columns: 1fr;
  }

  .workspace-switch {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .analysis-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .item img,
  .item-placeholder {
    width: 100%;
    height: 180px;
  }
}
