:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #17211f;
  --muted: #68736e;
  --line: #dce1dc;
  --green: #26715d;
  --green-2: #dff2ea;
  --blue: #2f5f9d;
  --blue-2: #e6eefc;
  --red: #a84b3d;
  --shadow: 0 14px 34px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

body.locked {
  overflow: hidden;
}

body.locked .app-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(2px);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--bg);
}

body.locked .login-screen {
  display: flex;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(100%, 380px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-copy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 750;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 84px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.55rem;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.icon-button,
.primary-button,
.tab {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 1.25rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.tab {
  min-height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar,
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 86px;
  padding: 13px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.22rem;
  letter-spacing: 0;
}

.metric-grid .metric:last-child {
  grid-column: 1 / -1;
}

.panel {
  margin-bottom: 12px;
  padding: 14px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.date-chart {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
}

.y-axis {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  height: 260px;
  padding-bottom: 34px;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
}

.chart-area {
  position: relative;
  min-width: 0;
}

.plot {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  align-items: end;
  height: 260px;
  overflow-x: auto;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(to bottom, rgba(220, 225, 220, 0.8) 1px, transparent 1px) 0 0 / 100% 25%;
}

.date-group {
  display: grid;
  grid-template-rows: 1fr 30px;
  align-items: end;
  min-width: 42px;
  height: 100%;
  padding: 0 4px;
}

.bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 3px;
  height: 100%;
}

.date-bar {
  position: relative;
  min-height: 2px;
  height: var(--h);
  border-radius: 4px 4px 0 0;
}

.date-bar.sales {
  background: var(--green);
}

.date-bar.spend {
  background: var(--red);
}

.date-bar::after {
  content: attr(data-value);
  position: absolute;
  right: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(50%);
  color: var(--ink);
  font-size: 0.64rem;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.date-bar:hover::after {
  opacity: 1;
}

.date-label {
  align-self: center;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot.sales {
  background: var(--green);
}

.legend-dot.spend {
  background: var(--red);
}

.table-list,
.source-list,
.source-form,
.mapping-grid {
  display: grid;
  gap: 10px;
}

.table-row,
.source-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.table-row strong,
.source-card strong {
  font-size: 0.9rem;
}

.row-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.row-stats span {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.primary-button {
  min-height: 46px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  border-radius: 999px;
  background: var(--blue-2);
  color: var(--blue);
  padding: 7px 10px;
  font-size: 0.76rem;
  font-weight: 750;
}

.hidden {
  display: none;
}

.notice {
  border-left: 3px solid var(--blue);
  padding: 10px 12px;
  background: var(--blue-2);
  color: #24416f;
  font-size: 0.82rem;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 28px;
  }

  h1 {
    font-size: 2rem;
  }

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

  .metric-grid .metric:last-child {
    grid-column: auto;
  }

  .toolbar {
    grid-template-columns: minmax(220px, 360px) 160px;
  }
}
