:root {
  --accent: #d21d30;
  --accent-strong: #a91423;
  --ink: #162027;
  --muted: #62717b;
  --line: #d9e1e6;
  --surface: #ffffff;
  --soft-red: #fff1f2;
  --won: #138a52;
  --won-bg: #e7f7ee;
  --tendered: #b86500;
  --tendered-bg: #fff2df;
  --lost: #c92033;
  --lost-bg: #ffe7ea;
  --radius: 8px;
  --shadow: 0 18px 45px rgba(19, 31, 38, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #fff5f6 0%, #eef3f5 55%, #ffffff 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { padding: 24px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto 18px;
  padding: 20px 24px;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 850; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 42px); }
h2 { margin-bottom: 4px; font-size: 20px; }
.topbar button, .topbar-button, .button-row button, .table-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 850;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topbar button,
.topbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: #fff;
  text-decoration: none;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(540px, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
}
.side-stack {
  display: grid;
  gap: 18px;
}
.panel {
  background: var(--surface);
  border: 1px solid rgba(216, 224, 229, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  color: var(--accent);
  background: #ffe8eb;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.pill.muted { color: var(--muted); background: #eef2f4; }
.table-wrap { overflow-x: auto; padding: 0 18px 18px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td { font-size: 14px; }
.status-select {
  min-width: 116px;
  font-weight: 850;
}
.status-won {
  color: var(--won);
  background: var(--won-bg);
  border-color: rgba(19, 138, 82, 0.35);
}
.status-tendered {
  color: var(--tendered);
  background: var(--tendered-bg);
  border-color: rgba(184, 101, 0, 0.35);
}
.status-lost {
  color: var(--lost);
  background: var(--lost-bg);
  border-color: rgba(201, 32, 51, 0.35);
}
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-button { color: var(--accent); background: #fff; border-color: #ffcbd2; font-size: 12px; }
.table-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.table-button:hover { background: var(--soft-red); }
.detail-form { display: grid; gap: 14px; padding: 18px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 7px; }
label span { color: #40505a; font-size: 12px; font-weight: 850; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid #cfd9df;
  border-radius: 6px;
}
textarea {
  min-height: 230px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row button { color: #fff; background: var(--accent); }
.button-row button.danger { background: #5f1f2a; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.report-controls {
  display: grid;
  gap: 10px;
  padding: 18px 18px 0;
}
.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  background: #f3f6f8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.segmented-control[aria-label="Summary metric"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.segmented-control button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 850;
}
.segmented-control button.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 14px rgba(210, 29, 48, 0.22);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}
.summary-card {
  min-height: 112px;
  padding: 16px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.summary-card span,
.chart-label span,
.status-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}
.summary-card small,
.status-chip small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.chart-bars {
  display: grid;
  gap: 14px;
  padding: 18px 18px 8px;
}
.chart-row {
  display: grid;
  gap: 8px;
}
.chart-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.chart-label strong {
  font-size: 14px;
}
.bar-track {
  width: 100%;
  height: 14px;
  overflow: hidden;
  background: #edf2f5;
  border-radius: 999px;
}
.bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: inherit;
}
.bar-track.status-won span { background: var(--won); }
.bar-track.status-tendered span { background: var(--tendered); }
.bar-track.status-lost span { background: var(--lost); }
.status-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 8px 18px 18px;
}
.status-chip {
  padding: 12px;
  border: 1px solid;
  border-radius: var(--radius);
}
.status-chip strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}
@media (max-width: 980px) { .workspace { grid-template-columns: 1fr; } }
@media (max-width: 680px) {
  .app-shell { padding: 12px; }
  .topbar, .field-grid { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .summary-grid, .status-breakdown { grid-template-columns: 1fr; }
}
