:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #60706c;
  --line: #d8e1dc;
  --panel: #ffffff;
  --page: #f5f3ec;
  --accent: #146b63;
  --accent-2: #9c6b22;
  --danger: #9f2f2f;
  --soft: #e8efe9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(29, 38, 35, 0.08);
}

.input-panel {
  position: sticky;
  top: 24px;
  padding: 20px;
}

.panel-title,
.result-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.7rem;
}

h2 {
  font-size: 1.25rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--soft);
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: normal;
}

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

label {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  line-height: 1.25;
}

.field-label span:first-child {
  color: var(--ink);
}

.field-label span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.help-button {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--line);
  color: var(--accent);
  background: #f7faf7;
  font-size: 0.78rem;
  line-height: 18px;
}

.tooltip {
  position: absolute;
  z-index: 20;
  top: 24px;
  left: 0;
  width: min(320px, calc(100vw - 64px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 14px 32px rgba(29, 38, 35, 0.18);
  color: var(--ink);
  background: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.label-row:hover .tooltip,
.label-row:focus-within .tooltip {
  opacity: 1;
  transform: translateY(0);
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfa;
  text-overflow: ellipsis;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 107, 99, 0.22);
  outline-offset: 1px;
}

.actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 650;
}

.result-panel {
  min-height: calc(100vh - 48px);
  padding: 20px;
}

.report {
  display: grid;
  gap: 18px;
}

.section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.section:first-child {
  border-top: 0;
  padding-top: 0;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 1.02rem;
}

.fact-list,
.weight-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
}

.fact-list div,
.weight-list div {
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
  text-align: left;
}

th {
  background: #eef4f1;
  font-size: 0.82rem;
}

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

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

.tips {
  display: grid;
  gap: 8px;
  margin: 0;
}

.tips div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.muted {
  color: var(--muted);
}

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

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

  .input-panel {
    position: static;
  }

  .result-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .field-grid,
  .fact-list,
  .weight-list,
  .actions {
    grid-template-columns: 1fr;
  }

  .panel-title,
  .result-toolbar {
    flex-direction: column;
  }

  table {
    min-width: 620px;
  }
}

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

  .input-panel,
  .result-panel {
    padding: 14px;
  }

  h1 {
    font-size: 1.42rem;
  }

  h2 {
    font-size: 1.12rem;
  }

  .field-label {
    flex-wrap: wrap;
    gap: 2px 6px;
  }

  .tooltip {
    width: min(300px, calc(100vw - 40px));
  }
}

@media print {
  body {
    background: #fff;
  }

  .input-panel,
  .result-toolbar .status-pill,
  .actions,
  .error {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .workspace {
    display: block;
    max-width: none;
  }

  .result-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 9pt;
  }
}
