:root {
  --bg: #eff3f6;
  --panel: #ffffff;
  --line: #d6dee4;
  --text: #10252d;
  --muted: #5c6f7b;
  --green: #0f5a34;
  --green-2: #0d7b66;
  --amber: #e7b31d;
  --shadow: 0 12px 28px rgba(15, 30, 40, 0.12);
  --shadow-soft: 0 8px 18px rgba(15, 30, 40, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, select, input { font: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 306px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #dfe7ed;
  border-right: 1px solid var(--line);
  padding: 18px 16px 24px;
  overflow: auto;
}

.sidebar-brand {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 1rem;
}

.sidebar-section + .sidebar-section { margin-top: 1.25rem; }
.sidebar-heading {
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #32424c;
  margin-bottom: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: #4f6370;
  margin: 0.55rem 0 0.3rem;
}

.field-control {
  width: 100%;
  min-height: 42px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.65rem 0.75rem;
}

.file-input { padding: 0.45rem 0.55rem; }
.selected-file {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.nav-list { display: flex; flex-direction: column; }
.nav-item {
  width: 100%;
  text-align: left;
  border: none;
  background: rgba(255,255,255,0.55);
  border-bottom: 1px solid #cad4db;
  padding: 0.95rem 1rem;
  color: #1d3039;
  font-size: 0.95rem;
}
.nav-item.active {
  background: var(--amber);
  font-weight: 700;
}

.main-shell { display: flex; flex-direction: column; min-width: 0; }
.account-bar {
  background: var(--green);
  color: #fff;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-soft);
}
.account-bar-text { font-size: 1rem; font-weight: 600; }

.tab-strip {
  display: flex;
  background: #f4f8fa;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  border: none;
  background: #edf2f5;
  color: #1d313a;
  padding: 1rem 1.2rem;
  min-width: 160px;
  border-right: 1px solid var(--line);
}
.tab.active {
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.empty-state {
  margin: 2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-soft);
}

.page-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
}

.page-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-soft);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.9rem;
}

.subsection-title {
  font-size: 1rem;
  font-weight: 800;
  padding-top: 0.9rem;
  margin-top: 0.9rem;
  border-top: 1px solid #e1e7eb;
  margin-bottom: 0.65rem;
}

.boolean-row {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 0;
}

.row-label { font-size: 1rem; color: #223741; }
.radio-pill-group { display: inline-flex; gap: 0.55rem; flex-wrap: wrap; }
.radio-pill {
  min-width: 82px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4c626f;
  text-align: center;
}
.radio-pill.active {
  background: #e7f4ef;
  border-color: #7bb79f;
  color: var(--green);
  font-weight: 700;
}

.grid-windhail {
  display: grid;
  grid-template-columns: 1.5fr 1.1fr 2.2fr 1.2fr;
  gap: 1rem;
  align-items: center;
}
.table-header {
  padding: 0.7rem 0.2rem 0.85rem;
  border-bottom: 1px solid #e0e6eb;
  font-weight: 800;
  color: #2a3d47;
}
.table-row { padding: 0.95rem 0.2rem 0.3rem; }

.deductible-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.info-button {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #d39d10;
  background: var(--amber);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(231, 179, 29, 0.28);
}

.rules-button {
  background: #fff7dc;
  color: #9a6b07;
}

.select-shell {
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: #fff;
}
.readonly-shell { font-size: 1rem; font-weight: 700; color: #18313d; }
.disabled-shell { color: #5b6a74; background: #f4f7f9; }
.disabled-shell span:first-child { color: #7c8890; font-weight: 700; }
.chevron { color: #627480; }

.deductible-field-shell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deductible-select-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.deductible-select {
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
  background: #fff;
  color: #18313d;
  font-weight: 700;
  appearance: auto;
}

.edited-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 28px;
  border-radius: 999px;
  background: #eceff3;
  color: #4f5f69;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 0.65rem;
}

.deductible-eligibility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.deductible-eligibility-label {
  font-size: 0.82rem;
  color: #5f7380;
}

.eligibility-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid #d8e0e6;
}

.eligibility-chip.neutral {
  background: #f5f7f9;
  color: #667883;
}

.eligibility-chip.status-positive {
  background: #eef8f1;
  color: #0f7b45;
  border-color: #cfe6d5;
}

.eligibility-chip.status-negative {
  background: #fbeeee;
  color: #b14545;
  border-color: #efcdcd;
}

.footer-actions {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.3rem 0 0;
}

.footer-button {
  min-width: 116px;
  height: 44px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  cursor: pointer;
}
.footer-button.primary { background: #0f8b60; color: #fff; }
.footer-button.ghost {
  background: #f5f7f8;
  border: 1px solid var(--line);
  color: #223741;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,30,40,0.28);
  z-index: 100;
}

.calc-modal {
  position: fixed;
  top: 56px;
  left: calc(5vw + 22px);
  width: calc(90vw - 43px);
  min-width: 920px;
  min-height: 420px;
  max-width: none;
  max-height: calc(100vh - 80px);
  background: #fff;
  border: 1px solid #cfd8df;
  border-radius: 14px;
  box-shadow: 0 24px 50px rgba(12, 26, 35, 0.28);
  z-index: 120;
  overflow: auto;
  resize: both;
}

.calc-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem 0.9rem;
  border-bottom: 1px solid #e1e7eb;
  cursor: move;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
}

.modal-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--green-2);
  margin-bottom: 0.3rem;
}

.calc-modal-header h2 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.15;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-download-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 0.2rem;
}

.modal-nav-button {
  height: 32px;
  border-radius: 9px;
  border: 1px solid #d8e0e6;
  background: #f8fafb;
  color: #29404c;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  padding: 0 0.9rem;
}

.modal-nav-button:hover {
  background: #f1f5f7;
}

.modal-download-button {
  min-width: 58px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid #d8e0e6;
  background: #f8fafb;
  color: #29404c;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

.modal-download-button:hover {
  background: #f1f5f7;
}

.modal-action-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #324b58;
  font-size: 1.1rem;
  cursor: pointer;
}

.calc-modal-body { padding: 1rem 1.15rem 1.2rem; }
.modal-intro {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #49606d;
  line-height: 1.5;
}

.metric-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.metric-card {
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
  border: 1px solid #dbe4ea;
  border-radius: 12px;
  padding: 0.9rem;
  min-height: 118px;
}
.metric-label {
  font-size: 0.82rem;
  color: #617581;
  margin-bottom: 0.45rem;
}
.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: #112833;
  margin-bottom: 0.4rem;
}
.metric-helper {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #5e707b;
}

.section-heading { font-size: 1rem; font-weight: 800; margin: 0 0 0.75rem; }
.step-list-section, .eligibility-section { margin-top: 1rem; }
.step-list { display: flex; flex-direction: column; gap: 0.8rem; }

.rules-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rules-section {
  border: 1px solid #dde5eb;
  border-radius: 12px;
  background: #fff;
  padding: 1rem;
  scroll-margin-top: 1rem;
  transition: box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.rule-section-highlight {
  border-color: #d39d10;
  background: #fff9ea;
  box-shadow: 0 0 0 3px rgba(231, 179, 29, 0.18);
}

.rules-section-header {
  margin-bottom: 0.85rem;
}

.rules-section-header h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.rules-section-header p {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #5c6f7b;
}

.rules-card-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.8rem;
  overflow-x: auto;
}

.rules-card-strip .metric-value {
  font-size: 1.25rem;
  line-height: 1.3;
}

.rules-table-shell {
  overflow-x: auto;
}

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

.rules-table th,
.rules-table td {
  border: 1px solid #dde5eb;
  padding: 0.7rem 0.75rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.86rem;
  line-height: 1.4;
}

.rules-table th {
  background: #f4f8fb;
  font-weight: 800;
  color: #28404c;
}

.step-card {
  border: 1px solid #dde5eb;
  border-radius: 12px;
  background: #fff;
  padding: 0.95rem;
  transition: box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.step-card-highlight {
  border-color: #d39d10;
  background: #fff9ea;
  box-shadow: 0 0 0 3px rgba(231, 179, 29, 0.18);
}
.step-number {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--green-2);
  text-transform: uppercase;
}
.step-title { font-size: 1.08rem; font-weight: 800; margin-top: 0.2rem; }
.step-copy {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #465b67;
  margin: 0.55rem 0 0.7rem;
}
.step-formula {
  font-family: Consolas, monospace;
  font-size: 0.96rem;
  border: 1px solid #dfe6eb;
  border-radius: 10px;
  background: #f7f9fb;
  padding: 0.8rem;
  line-height: 1.55;
}
.step-result {
  margin-top: 0.7rem;
  font-size: 1rem;
  font-weight: 800;
  color: var(--green);
}

.step-references {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

.step-references-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #5f7380;
  padding-top: 0.2rem;
}

.step-references-pills {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.step-reference-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #f4f8fb;
  border: 1px solid #dbe4ea;
  color: #34515f;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 0.7rem;
}

.step-reference-button {
  cursor: pointer;
  appearance: none;
}

.step-reference-button:hover {
  background: #edf4fa;
  border-color: #c5d6e4;
}

.step-metrics {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.65rem;
  margin-top: 0.8rem;
}
.mini-metric {
  border: 1px solid #e2e8ed;
  border-radius: 10px;
  background: #fbfdff;
  padding: 0.8rem;
}
.mini-metric-label {
  font-size: 0.78rem;
  color: #5f7380;
  margin-bottom: 0.3rem;
}
.mini-metric-value { font-size: 1rem; font-weight: 700; }

.eligibility-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.eligibility-grid .metric-value {
  font-size: 1.18rem;
  line-height: 1.25;
}

.eligibility-grid .metric-helper {
  font-size: 0.78rem;
}

.status-positive .metric-value {
  color: #0f7b45;
}

.status-positive {
  background: linear-gradient(180deg, #f8fdf9, #eef8f1);
  border-color: #cfe6d5;
}

.status-negative .metric-value {
  color: #b14545;
}

.status-negative {
  background: linear-gradient(180deg, #fffafa, #fbeeee);
  border-color: #efcdcd;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 260px 1fr; }
  .grid-windhail { grid-template-columns: 1.4fr 1fr 1.7fr 1fr; }
}
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .grid-windhail, .boolean-row { grid-template-columns: 1fr; }
  .deductible-eligibility-row { align-items: flex-start; flex-direction: column; }
  .calc-modal { left: 4vw; width: 92vw; min-width: 0; }
}
