:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #fdf9ee;
  --ink: #1f2522;
  --muted: #62706a;
  --line: #d9ded6;
  --line-strong: #b9c4bb;
  --accent: #2f6b4f;
  --accent-strong: #214f3b;
  --accent-soft: #dcefe5;
  --amber: #9a6a10;
  --amber-soft: #fff1c9;
  --red: #af3f38;
  --red-soft: #ffe2de;
  --blue: #2d5f88;
  --blue-soft: #dfedf8;
  --eliminated-cell: #f2f4f2;
  --eliminated-ink: #7c8782;
  --shadow: 0 18px 45px rgba(31, 37, 34, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 2.5rem;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0.6rem 0.85rem;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: var(--surface-strong);
  border-color: var(--accent);
}

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

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

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 2.4vw, 2.1rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
}

.toolbar {
  display: grid;
  gap: 0.55rem;
  justify-items: end;
}

.toolbar-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.field {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.field.compact select {
  width: 5.5rem;
}

select,
input[type="number"] {
  min-height: 2.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.55rem;
}

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.metric {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.95rem;
  background: #fff;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: 1.35rem;
  line-height: 1.1;
}

.status-metric.ok strong {
  color: var(--accent);
}

.status-metric.warn strong {
  color: var(--amber);
}

.status-metric.bad strong {
  color: var(--red);
}

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

.panel {
  border-radius: 8px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.panel-heading p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-heading.tight {
  align-items: center;
}

.table-wrap {
  overflow: auto;
}

.auction-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

.auction-table th,
.auction-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.6rem;
  text-align: left;
  vertical-align: top;
}

.auction-table th:last-child,
.auction-table td:last-child {
  border-right: 0;
}

.auction-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
}

.auction-table th.row-head {
  width: 7rem;
  background: var(--row-bg, #fff);
  font-weight: 800;
}

.bidder-head {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.bidder-chip,
.row-note,
.cell-note,
.cell-footer {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(31, 37, 34, 0.08);
}

.bidder-chip {
  padding: 0.22rem 0.45rem;
}

.property-head {
  display: grid;
  gap: 0.45rem;
}

.property-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.property-title strong {
  overflow-wrap: anywhere;
}

.simple-price-controls {
  display: grid;
  grid-template-columns: 2rem 4.3rem 2rem;
  gap: 0.3rem;
  align-items: center;
}

.price-display {
  display: inline-grid;
  place-items: center;
  min-height: 2.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  padding: 0.18rem 0.3rem;
  overflow-wrap: anywhere;
}

.price-display strong {
  font-size: 0.95rem;
  line-height: 1;
}

.rent-label {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.cell-stack {
  display: grid;
  grid-template-rows: auto auto minmax(2.05rem, auto) 1.45rem;
  gap: 0.36rem;
  height: 100%;
  min-height: 8.15rem;
}

.value-input {
  width: 100%;
  min-width: 0;
  font-weight: 800;
}

.net-line,
.cell-note,
.mini-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.auction-table td {
  --ring-a: transparent;
  --ring-b: transparent;
  --ring-c: transparent;
  background: var(--cell-bg, #fff);
  height: 9.7rem;
  box-shadow:
    inset 0 0 0 2px var(--ring-a),
    inset 0 0 0 4px var(--ring-b),
    inset 0 0 0 6px var(--ring-c);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.auction-table td.is-allocated {
  --ring-b: var(--accent);
}

.auction-table td.is-demand {
  --ring-a: var(--blue);
}

.auction-table td.is-envy {
  --ring-c: var(--red);
}

.auction-table td.is-negative {
  color: var(--eliminated-ink);
}

.auction-table td.is-negative .value-input,
.auction-table td.is-negative .cell-footer,
.auction-table td.is-negative .cell-note {
  border-color: rgba(210, 216, 212, 0.9);
  background: rgba(255, 255, 255, 0.74);
  color: var(--eliminated-ink);
}

.auction-table td.is-negative .value-fill {
  background: rgba(98, 112, 106, 0.2);
}

.auction-table td.is-negative .assign-button {
  border-color: #ccd4cf;
  color: var(--eliminated-ink);
}

.row-note {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.16rem 0.35rem;
}

.cell-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.9rem;
  align-items: center;
  gap: 0.32rem;
  width: 100%;
  padding: 0.26rem;
}

.net-line {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indicator-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.24rem;
  min-height: 1.45rem;
}

.cell-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 1.35rem;
  width: 100%;
  padding: 0.12rem 0.22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-note.is-empty {
  visibility: hidden;
}

.assign-button {
  min-height: 1.8rem;
  width: 100%;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 850;
}

.assign-button:hover {
  border-color: var(--accent);
  background: var(--surface-strong);
  color: var(--ink);
}

.assign-button.is-clear {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.assign-button.is-clear:hover {
  background: var(--accent-strong);
  color: #fff;
}

.badge {
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  padding: 0.16rem 0.45rem;
  white-space: nowrap;
}

.badge.ok {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.warn {
  border-color: #d0a036;
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.bad {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-height: 2.3rem;
  width: 2.3rem;
  padding: 0;
  font-size: 1.05rem;
  touch-action: manipulation;
  user-select: none;
}

.compact-icon {
  min-height: 2rem;
  width: 2rem;
}

.value-bar {
  position: relative;
  height: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  overflow: hidden;
}

.value-fill {
  height: 100%;
  border-radius: inherit;
  background: rgba(31, 37, 34, 0.46);
}

@media (max-width: 1050px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
    justify-items: start;
  }

  .toolbar-row {
    justify-content: flex-start;
  }

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

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

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

  .toolbar,
  .toolbar-row,
  .toolbar button,
  .field.compact {
    width: 100%;
  }

  .field.compact select {
    width: 100%;
  }

  .panel-heading {
    flex-direction: column;
  }
}
