.result-grid,
.tax-summary-grid,
.adjustment-grid,
.proposal-main {
  display: grid;
  gap: 14px;
}

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.adjustment-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tax-section {
  display: grid;
  gap: 16px;
}

.tax-section + .tax-section {
  margin-top: 18px;
}

.tax-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fcfa 100%);
}

.result-card.editable {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-card.highlight {
  border-color: rgba(47, 128, 104, 0.45);
  background: var(--primary-soft);
}

.result-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.result-card strong {
  font-size: 26px;
  line-height: 1.2;
}

.result-card input {
  min-height: 42px;
  text-align: right;
  font-size: 24px;
  font-weight: 900;
}

.sub-result-line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, auto);
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefc;
}

.sub-result-line span,
.mini-result-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.sub-result-line strong,
.mini-result-grid strong {
  text-align: right;
  font-size: 18px;
}

.inline-details {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-details summary {
  min-height: 46px;
  padding: 13px 14px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.inline-details[open] summary {
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

.inline-details > *:not(summary) {
  margin: 14px;
}

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

.mini-result-grid div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefc;
}

.consumption-settings {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tax-lines {
  display: grid;
  gap: 8px;
}

.tax-lines div,
.tax-lines label {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, auto);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.tax-lines span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.tax-lines strong {
  font-size: 18px;
  text-align: right;
}

.tax-lines input {
  text-align: right;
}

.tax-lines .total {
  border-bottom: 0;
  color: var(--primary-dark);
}

.tax-lines .total strong {
  font-size: 23px;
}

.adjustment-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f7fcfa;
}

.sub-result-line.loss-carryforward-line {
  grid-template-columns: minmax(160px, 1fr) 280px;
}

.loss-carryforward-amount-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  justify-self: end;
  width: 280px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.loss-carryforward-amount-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  text-align: right;
}

.loss-carryforward-amount-field span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.adjustment-box tfoot th,
.adjustment-box tfoot td {
  border-top: 2px solid var(--line-strong);
  background: #eef8f3;
  color: var(--primary-dark);
  font-weight: 900;
}

.adjustment-box tfoot th {
  text-align: left;
}

.adjustment-box tfoot td {
  text-align: right;
}

.tax-credit-amount,
.loss-carryforward-amount {
  text-align: right;
}

.loss-carryforward-table th:last-child,
.loss-carryforward-table td:last-child {
  text-align: right;
}

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

.rate-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fcfa;
}

.rate-card h4 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 15px;
}

.rate-card-note {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.rate-card label {
  display: grid;
  gap: 6px;
}

.rate-card label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.unit-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.unit-input input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  text-align: right;
}

.unit-input span {
  display: grid;
  place-items: center;
  height: 100%;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
}

.consumption-table {
  margin-top: 14px;
}

.consumption-table .number-cell {
  text-align: right;
  font-weight: 900;
  white-space: nowrap;
}

.investment-table input,
.investment-table select {
  width: 100%;
}

.investment-table th:nth-child(1) {
  width: 20%;
}

.investment-table th:nth-child(2) {
  width: 14%;
}

.investment-table th:nth-child(3) {
  width: 30%;
}

.investment-table th:nth-child(4),
.investment-table th:nth-child(5) {
  width: 14%;
}

.investment-table th:nth-child(6) {
  width: 76px;
}

.investment-table .investment-gross-amount {
  text-align: right;
}

.investment-table tfoot th,
.investment-table tfoot td {
  border-top: 2px solid var(--line-strong);
  background: #eef8f3;
  color: var(--primary-dark);
  font-weight: 900;
}

.investment-table tfoot th {
  text-align: left;
}

.investment-add-button {
  margin-top: 0 !important;
}

.method-reference-note {
  margin: 12px 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.fixed-asset-reference-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.simple-tax-target {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, auto);
  gap: 12px;
  align-items: center;
  margin: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefc;
}

.simple-tax-target span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.simple-tax-target strong {
  text-align: right;
  font-size: 18px;
}

.small-table tfoot th,
.small-table tfoot td {
  border-top: 2px solid var(--line-strong);
  background: #eef8f3;
  color: var(--primary-dark);
  font-weight: 900;
}

.small-table tfoot th {
  text-align: left;
}

.small-table tfoot td {
  text-align: right;
}

.cell-error {
  position: relative;
  border: 2px solid var(--red) !important;
  background: var(--red-soft) !important;
}

.cell-error::after {
  content: attr(data-error);
  position: absolute;
  right: 8px;
  bottom: calc(100% + 8px);
  z-index: 6;
  display: none;
  width: max-content;
  max-width: min(320px, calc(100vw - 40px));
  padding: 8px 10px;
  border-radius: 8px;
  background: #331915;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(28, 36, 32, 0.18);
}

.cell-error:hover::after,
.cell-error:focus-within::after {
  display: block;
}

.proposal-builder {
  display: grid;
  gap: 14px;
}

.api-settings {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.api-warning,
.proposal-status {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.6;
}

.api-warning {
  color: var(--amber);
}

.api-settings-actions {
  justify-content: flex-start;
}

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

.proposal-status[data-tone="success"] {
  color: var(--primary-dark);
}

.proposal-status[data-tone="warn"] {
  color: var(--amber);
}

.proposal-status[data-tone="error"] {
  color: var(--red);
}

.proposal-diagnostics-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: -6px;
}

.proposal-diagnostics-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.proposal-diagnostics-modal.hidden {
  display: none;
}

.proposal-diagnostics-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 28, 23, 0.42);
}

.proposal-diagnostics-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(28, 36, 32, 0.25);
}

.proposal-diagnostics-header,
.proposal-diagnostics-footer {
  display: flex;
  align-items: center;
}

.proposal-diagnostics-header {
  justify-content: space-between;
  gap: 12px;
}

.proposal-diagnostics-header h3 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 18px;
}

.proposal-diagnostics-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.proposal-diagnostics-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.proposal-diagnostics-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.proposal-diagnostics-list dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.proposal-diagnostics-footer {
  justify-content: flex-end;
}

.proposal-builder-heading {
  align-items: center;
}

.proposal-builder-heading .button {
  min-width: 118px;
}

.proposal-main label {
  display: grid;
  gap: 8px;
}

.proposal-main textarea {
  width: 100%;
  min-height: 600px;
  resize: vertical;
  line-height: 1.7;
}

.proposal-references {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.proposal-references h4 {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 14px;
}

.proposal-references ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.proposal-references li {
  display: grid;
  gap: 2px;
}

.proposal-references a {
  color: var(--primary-dark);
  overflow-wrap: anywhere;
}

.bottom-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .result-grid,
  .tax-summary-grid,
  .adjustment-grid,
  .rate-card-grid,
  .mini-result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sub-result-line.loss-carryforward-line {
    grid-template-columns: minmax(120px, 1fr) minmax(180px, 240px);
  }

  .loss-carryforward-amount-field {
    width: 100%;
  }

  .tax-lines div,
  .tax-lines label {
    grid-template-columns: 1fr;
  }
}
