:root {
  --brand-primary: #500000;
  --brand-light: #ffffff;
  --brand-muted: #f4f1f1;
  --text-color: #2d2a2a;
  --text-muted: #5f5757;
  --shadow: 0 18px 40px rgba(80, 0, 0, 0.1);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--brand-muted);
  color: var(--text-color);
  line-height: 1.6;
}

.hero {
  background: var(--brand-primary);
  color: var(--brand-light);
  padding: 3rem 1.5rem;
}

.hero__content {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: center;
}

.hero__logo {
  width: 110px;
  height: 110px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  background: var(--brand-light);
  padding: 0.75rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 3vw, 2.75rem);
}

.hero p {
  margin: 0.5rem 0;
}

.hero__tagline a {
  color: var(--brand-light);
  font-weight: 600;
  text-decoration: underline;
}

.layout {
  max-width: 1100px;
  margin: -3rem auto 3rem;
  padding: 0 1.5rem;
}

.card {
  background: var(--brand-light);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  color: var(--brand-primary);
}

.tabs {
  display: grid;
  gap: 2rem;
}

.tabs__list {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--brand-light);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.tabs__tab {
  border: none;
  background: transparent;
  color: var(--brand-primary);
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tabs__tab.is-active {
  background: var(--brand-primary);
  color: var(--brand-light);
  box-shadow: 0 10px 24px rgba(80, 0, 0, 0.25);
}

.tabs__tab:focus-visible {
  outline: 3px solid rgba(80, 0, 0, 0.35);
  outline-offset: 2px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.panel-stack {
  display: grid;
  gap: 2rem;
}

.form {
  display: grid;
  gap: 1.5rem;
}

.form__group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form__group--dual {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  font-weight: 600;
  color: var(--text-color);
}

input[type="number"] {
  appearance: textfield;
  border: 1px solid #d8caca;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(80, 0, 0, 0.15);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand-primary);
}

.slider-value {
  font-weight: 600;
  color: var(--brand-primary);
}

.help-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.results__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.result-item {
  border: 1px solid #e6dede;
  border-radius: 14px;
  padding: 1.25rem;
  display: grid;
  gap: 0.5rem;
  background: linear-gradient(180deg, #ffffff 0%, #fcf8f8 100%);
}

.result-item h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.result-item__value {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.result-item__detail {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.result-item--highlight {
  border: 2px solid var(--brand-primary);
}

.results__notes {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: rgba(80, 0, 0, 0.08);
  color: var(--text-color);
  font-size: 0.95rem;
}

.definition-list {
  margin: 0;
  display: grid;
  gap: 1.25rem;
}

.definition-list dt {
  font-weight: 700;
  color: var(--brand-primary);
}

.definition-list dd {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.accrual-form {
  display: grid;
  gap: 1.5rem;
}

.accrual-controls {
  display: grid;
  gap: 0.75rem;
  align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.table-wrapper {
  overflow-x: auto;
}

.accrual-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.accrual-table caption {
  caption-side: top;
  font-weight: 600;
  text-align: left;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.accrual-table th,
.accrual-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #e6dede;
  text-align: left;
}

.accrual-table th:first-child,
.accrual-table td:first-child {
  padding-left: 0.75rem;
}

.accrual-table th:last-child,
.accrual-table td:last-child {
  padding-right: 0.75rem;
}

.accrual-table input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #d8caca;
  font-size: 0.95rem;
}

.accrual-table input[type="number"]:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(80, 0, 0, 0.15);
}

.accrual-value {
  font-weight: 600;
  color: var(--text-color);
}

.accrual-value.is-negative {
  color: #a10014;
}

.accrual-value.is-positive {
  color: var(--brand-primary);
}

.accrual-table tr.is-shortfall {
  background: rgba(80, 0, 0, 0.05);
}

.accrual-table tr.is-carryover {
  background: rgba(80, 0, 0, 0.12);
}

.accrual-summary {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: rgba(80, 0, 0, 0.08);
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 500;
}

.footer {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  :root {
    font-size: 15px;
  }

  .hero {
    padding: 2.5rem 1.25rem;
  }

  .layout {
    margin-top: -2.5rem;
  }

  .card {
    padding: 1.75rem;
  }

  .panel-stack {
    gap: 1.5rem;
  }

  .results__grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .tabs__list {
    width: 100%;
    flex-wrap: wrap;
  }

  .tabs__tab {
    flex: 1 1 100%;
    text-align: center;
  }

  .accrual-table {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .hero__content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero__logo {
    margin: 0 auto;
  }

  .layout {
    margin-top: -2rem;
  }

  .table-wrapper {
    margin: 0 -1.5rem;
  }
}

@media (max-width: 540px) {
  :root {
    font-size: 14px;
  }

  .hero {
    padding: 2rem 1rem;
  }

  .card {
    padding: 1.5rem;
  }

  .table-wrapper {
    margin: 0;
  }

  .tabs__list {
    flex-direction: column;
    gap: 0.25rem;
  }

  .tabs__tab {
    padding: 0.7rem 1rem;
  }

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

  .accrual-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .accrual-table thead {
    display: none;
  }

  .accrual-table tbody tr {
    display: grid;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #e6dede;
    border-radius: 14px;
    background: #fff;
  }

  .accrual-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .accrual-table tbody th {
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(80, 0, 0, 0.12);
    padding-bottom: 0.5rem;
  }

  .accrual-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    border: none;
  }

  .accrual-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 1rem;
  }

  .accrual-table tbody tr.is-shortfall {
    background: rgba(80, 0, 0, 0.08);
  }

  .accrual-table tbody tr.is-carryover {
    box-shadow: 0 0 0 2px rgba(80, 0, 0, 0.15);
  }

  .accrual-table input[type="number"] {
    max-width: 120px;
  }
}
