:root {
  color-scheme: light;
  --bg: #eef5f2;
  --panel: #ffffff;
  --panel-soft: #f7fbff;
  --ink: #102027;
  --muted: #63717d;
  --line: #d4dfdf;
  --green: #0f8b6f;
  --blue: #246bcb;
  --gold: #d28a19;
  --red: #c2465a;
  --teal: #13a6a1;
  --violet: #7452c7;
  --sky: #dff3ff;
  --mint: #dff7ed;
  --peach: #fff0dc;
  --shadow: 0 18px 45px rgba(22, 45, 54, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #dff3ff 0, #eef5f2 260px, #f8faf8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.eyebrow {
  color: #0b7664;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.98;
  margin-bottom: 0;
}

h2 {
  font-size: 1rem;
  margin-bottom: 14px;
}

.mode-toggle {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.mode-toggle button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

.mode-toggle button.active {
  background: linear-gradient(135deg, #102027, #0f8b6f);
  color: #fff;
}

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

.metric {
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
  padding: 16px;
  position: relative;
}

.metric::before {
  background: var(--teal);
  content: "";
  height: 4px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.metric:nth-child(2)::before {
  background: var(--gold);
}

.metric:nth-child(3)::before {
  background: var(--blue);
}

.metric:nth-child(4)::before {
  background: var(--violet);
}

.metric span,
.metric small {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  font-size: clamp(1.25rem, 2vw, 2rem);
  line-height: 1.05;
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
}

.inputs-panel,
.results-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.inputs-panel {
  max-height: calc(100vh - 24px);
  overflow: auto;
  position: sticky;
  top: 12px;
}

.panel-section {
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.panel-section:last-child {
  border-bottom: 0;
}

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

label span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
}

input {
  background: #fbfdff;
  border: 1px solid #c7d5d8;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 8px 10px;
  width: 100%;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 166, 161, 0.18);
}

.section-heading,
.property-head,
.chart-toolbar,
.legend {
  align-items: center;
  display: flex;
  gap: 10px;
}

.section-heading,
.property-head,
.chart-toolbar {
  justify-content: space-between;
}

.switch-field {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 8px;
}

.switch-field input {
  accent-color: var(--green);
  min-height: 18px;
  padding: 0;
  width: 18px;
}

.switch-field span {
  margin-bottom: 0;
}

.section-switch {
  margin-bottom: 12px;
}

.icon-button,
.remove-property {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.icon-button {
  background: linear-gradient(135deg, var(--teal), var(--green));
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
}

.remove-property {
  background: #fff0f4;
  color: var(--red);
}

.properties-list {
  display: grid;
  gap: 12px;
}

.property-card {
  background: linear-gradient(180deg, #ffffff, #f3faf8);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.property-name {
  font-weight: 800;
}

.property-fields {
  margin-top: 12px;
}

.results-panel {
  min-width: 0;
  padding: 18px;
}

.chart-toolbar {
  margin-bottom: 10px;
}

.chart-toolbar p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0;
}

.legend {
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 0.82rem;
  justify-content: flex-end;
}

.swatch {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  margin-right: 6px;
  width: 10px;
}

.swatch.total {
  background: var(--ink);
}

.swatch.super {
  background: var(--blue);
}

canvas {
  background: linear-gradient(180deg, #ffffff, #f2f9ff);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  max-height: 520px;
  width: 100%;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  max-height: 420px;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: right;
  white-space: nowrap;
}

.text-cell {
  text-align: left;
}

th {
  background: #e6f2f3;
  color: #34515d;
  font-size: 0.78rem;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  font-size: 0.88rem;
}

.sale-row td {
  background: var(--peach);
}

.depleted-row td {
  background: #ffecef;
}

@media (max-width: 1050px) {
  .summary-grid,
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .workspace {
    display: block;
  }

  .inputs-panel {
    margin-bottom: 18px;
    max-height: none;
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .chart-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .mode-toggle button {
    flex: 1;
  }
}
