:root {
  --ink: #151512;
  --muted: #65645b;
  --paper: #f7f3ea;
  --panel: #fffdf7;
  --line: #d8d0bf;
  --accent: #c5432e;
  --accent-2: #0f766e;
  --blueprint: #23384d;
  --warning: #a86108;
  --good: #20704f;
  --shadow: 0 18px 50px rgba(42, 35, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(35, 56, 77, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 56, 77, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Avenir Next", "Gill Sans", Verdana, sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 24px;
  align-items: end;
  min-height: 250px;
  padding: 34px 0 24px;
  border-bottom: 2px solid var(--ink);
}

.eyebrow,
.panel-label {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  max-width: 900px;
  font-size: clamp(3rem, 7vw, 6.8rem);
  line-height: 0.92;
  overflow-wrap: anywhere;
}

h2 {
  font-size: clamp(1.7rem, 2vw, 2.35rem);
  line-height: 1;
}

.intro {
  max-width: 780px;
  margin: 22px 0 0;
  color: var(--blueprint);
  font-size: 1.08rem;
  line-height: 1.55;
}

.hero-panel {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px;
  color: var(--panel);
  background: var(--blueprint);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.hero-panel strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 4vw, 4rem);
  line-height: 0.95;
}

.hero-panel span:last-child {
  margin-top: 10px;
  color: #eee6d7;
  line-height: 1.4;
}

.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.controls,
.results {
  min-width: 0;
}

.controls {
  display: grid;
  align-content: start;
  gap: 16px;
}

.control-block,
.chart-wrap,
.table-wrap,
.detail-panel {
  background: rgba(255, 253, 247, 0.9);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.control-block {
  padding: 18px;
}

.section-heading,
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-heading {
  margin-bottom: 14px;
  font-weight: 900;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: #efe5d1;
  border: 2px solid var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
}

input:focus {
  outline: 3px solid rgba(197, 67, 46, 0.25);
  border-color: var(--accent);
}

.jurisdiction-form {
  display: grid;
  gap: 12px;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.primary-button {
  min-height: 46px;
  color: #fffdf7;
  background: var(--accent);
  border: 2px solid var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.results {
  display: grid;
  gap: 16px;
  align-content: start;
}

.toolbar {
  padding: 4px 2px 0;
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.metric-strip span {
  padding: 8px 10px;
  color: var(--blueprint);
  background: #efe5d1;
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 800;
}

.chart-wrap {
  position: relative;
  padding: 14px;
}

canvas {
  display: block;
  width: 100%;
  height: min(420px, 43vh);
  min-height: 280px;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 190px;
  padding: 10px;
  color: #fffdf7;
  background: var(--ink);
  border: 1px solid #fffdf7;
  pointer-events: none;
  font-size: 0.85rem;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.table-wrap {
  overflow: hidden;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.col-name { width: 17%; }
.col-status { width: 12%; }
.col-money { width: 10.5%; }
.col-total { width: 14%; }
.col-takehome { width: 15%; }

th,
td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: clamp(0.7rem, 0.74vw, 0.86rem);
  line-height: 1.25;
}

th:last-child,
td:last-child {
  padding-right: 14px;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

.jurisdiction-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.jurisdiction-cell span {
  min-width: 0;
}

th {
  color: var(--muted);
  background: #efe5d1;
  font-size: clamp(0.52rem, 0.56vw, 0.66rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #fff2d7;
}

.status {
  display: inline-flex;
  min-width: 0;
  width: min(100%, 98px);
  justify-content: center;
  padding: 5px 8px;
  border: 1px solid currentColor;
  font-size: clamp(0.62rem, 0.65vw, 0.76rem);
  font-weight: 900;
  white-space: nowrap;
}

.status.ok {
  color: var(--good);
}

.status.short {
  color: var(--warning);
}

.delete-button {
  width: 28px;
  min-height: 28px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 900;
}

.delete-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-panel {
  padding: 16px;
}

.detail-panel h3 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
}

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

.detail-grid div {
  min-height: 82px;
  padding: 12px;
  background: #fffaf0;
  border: 1px solid var(--line);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

.notes {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

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

  .controls {
    grid-template-columns: minmax(300px, 0.8fr) minmax(420px, 1fr);
    align-items: start;
  }
}

@media (max-width: 1080px) {
  .hero,
  .controls {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 150px;
  }
}

@media (max-width: 680px) {
  .shell {
    width: calc(100vw - 24px);
    padding-top: 12px;
  }

  h1 {
    font-size: clamp(2.28rem, 13.4vw, 4.6rem);
  }

  .input-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .controls {
    display: contents;
  }

  .controls .control-block:first-child {
    order: 1;
  }

  .results {
    order: 2;
  }

  .controls .control-block:last-child {
    order: 3;
  }

  .chart-wrap {
    padding: 10px;
  }

  canvas {
    min-height: 250px;
    height: 300px;
  }

  .table-wrap {
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  colgroup,
  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    padding: 12px;
    background: rgba(255, 253, 247, 0.94);
    border: 2px solid var(--ink);
    box-shadow: 4px 4px 0 rgba(21, 21, 18, 0.18);
  }

  tbody tr:hover,
  tbody tr.selected {
    background: #fff2d7;
  }

  td,
  td:first-child,
  td:nth-child(2) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.9rem;
    white-space: normal;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
  }

  td:first-child {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    text-align: left;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.24rem;
    font-weight: 700;
  }

  td:first-child::before {
    display: none;
  }

  td strong {
    font-size: 1rem;
  }

  .status {
    justify-self: start;
  }

  .jurisdiction-cell {
    display: grid;
  }

  .delete-button {
    justify-self: end;
  }
}
