:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #dce4ee;
  --nav: #0f172a;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --violet: #7c3aed;
  --shadow: 0 24px 70px rgba(15, 23, 42, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(37, 99, 235, .16), transparent 28%),
    radial-gradient(circle at 100% 20%, rgba(5, 150, 105, .10), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 46%, #eaf0f7 100%);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: rgba(15, 23, 42, .96);
  color: #fff;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #60a5fa, #34d399);
  color: #07111f;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand span,
.privacy-card p,
.source-pill span {
  color: rgba(255, 255, 255, .65);
}

.brand span {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  text-align: left;
  font-weight: 800;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.nav-item.active {
  background: #fff;
  color: var(--nav);
}

.privacy-card {
  align-self: end;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, .06);
}

.privacy-card strong {
  display: block;
  font-size: 14px;
}

.privacy-card p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  padding: 22px clamp(18px, 3vw, 34px) 34px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions input,
.actions select,
.button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .86);
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
}

.actions input {
  width: min(320px, 32vw);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.button.primary {
  background: var(--nav);
  color: #fff;
  border-color: var(--nav);
}

.button.secondary {
  background: #fff;
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.import-strip {
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) repeat(4, minmax(140px, .5fr));
  gap: 12px;
}

.dropzone,
.stat,
.mapping-card,
.empty-state,
.table-card,
.dashboard-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.dropzone {
  min-height: 126px;
  border-style: dashed;
  border-radius: 18px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.dropzone:hover,
.dropzone.drag {
  transform: translateY(-1px);
  border-color: var(--blue);
  background: #fff;
}

.dropzone input {
  display: none;
}

.drop-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #e8f0ff;
  color: var(--blue);
  font-size: 26px;
  font-weight: 800;
  flex: 0 0 auto;
}

.dropzone strong {
  display: block;
  font-size: 16px;
}

.dropzone small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.stat {
  min-height: 126px;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.stat label,
.mini label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stat strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.mapping-card,
.empty-state,
.table-card {
  border-radius: 18px;
  overflow: hidden;
}

.section-head {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.section-head h3 {
  margin: 0;
  font-size: 17px;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.field input,
.field select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0 10px;
}

.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 16px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.chip {
  background: #e8f0ff;
  color: #1d4ed8;
}

.badge {
  background: #edf2f7;
  color: #334155;
}

.badge.green { background: #dcfce7; color: #047857; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.violet { background: #ede9fe; color: #6d28d9; }

.empty-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 38px 20px;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.empty-state p {
  margin: 0 auto;
  color: var(--muted);
  max-width: 540px;
  line-height: 1.5;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(320px, .85fr);
  gap: 14px;
}

.dashboard-card {
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.dashboard-card.wide {
  grid-column: span 2;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}

.card-head h3 {
  margin: 0;
  font-size: 17px;
}

.card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
}

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

.mini {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 13px;
  display: grid;
  gap: 9px;
}

.mini strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.bars,
.rank-list,
.insights {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, .75fr) minmax(160px, 1fr) 110px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.bar-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track {
  height: 11px;
  border-radius: 999px;
  background: #e9eef5;
  overflow: hidden;
}

.fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  min-width: 3px;
}

.fill.green { background: var(--green); }
.fill.red { background: var(--red); }
.fill.blue { background: var(--blue); }
.fill.amber { background: var(--amber); }
.fill.cyan { background: var(--cyan); }
.fill.violet { background: var(--violet); }

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank-item,
.insight {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 12px;
}

.rank-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.rank-item strong,
.insight strong {
  font-size: 14px;
}

.rank-item span,
.insight span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.table-card {
  max-height: 62vh;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

td.primary {
  font-weight: 900;
}

tr:hover td {
  background: #f8fafc;
}

.detail {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.source-pill {
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}

.source-pill span {
  color: var(--muted);
  font-size: 12px;
}

.source-pill.ready { border-color: rgba(5, 150, 105, .25); }
.source-pill.watch { border-color: rgba(217, 119, 6, .30); }
.source-pill.import { border-color: rgba(37, 99, 235, .22); }

@media (max-width: 1250px) {
  .import-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dropzone {
    grid-column: 1 / -1;
  }

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

  .dashboard-card.wide {
    grid-column: span 1;
  }

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

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
  }

  .privacy-card {
    align-self: auto;
  }

  .source-dock {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .actions input,
  .actions select,
  .actions button {
    width: 100%;
  }

  .import-strip,
  .dashboard,
  .mini-grid,
  .mapping-grid,
  .source-dock {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  table {
    min-width: 980px;
  }
}
