html, body, main, header, footer {
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "Segoe UI", sans-serif;
  background-color: #f3f4f6;
  color: #1f2937;
  line-height: 1.6;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 24px 16px;
  text-align: center;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
}

#page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
}

#page-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  opacity: 0.85;
  font-weight: 400;
}

#header-ad {
  margin: 16px auto 0;
  max-width: 720px;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

#app {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.panel {
  flex: 1;
  min-width: 0;
}

#input-panel {
  flex: 0 0 56%;
  max-width: 56%;
}

#result-panel {
  flex: 0 0 44%;
  max-width: 44%;
  position: sticky;
  top: 24px;
}

.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e3a5f;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: #2563eb;
  border-radius: 2px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 12px;
  color: #9ca3af;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  z-index: 1;
}

.form-input {
  width: 100%;
  padding: 10px 12px 10px 28px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: #1f2937;
  background: #fafafa;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.form-input::placeholder {
  color: #c4c4c4;
  font-size: 13px;
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: #1f2937;
  background: #fafafa;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background-color: #fff;
}

.input-hint {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

.error-msg {
  display: block;
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  min-height: 18px;
}

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  padding: 8px 16px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  transition: all 0.2s;
  user-select: none;
}

.radio-item:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}

.radio-item input[type="radio"] {
  accent-color: #2563eb;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.radio-label {
  cursor: pointer;
}

.rate-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.rate-info span {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}

.deduction-summary {
  margin-top: 16px;
  padding: 12px 16px;
  background: #f0fdf4;
  border-radius: 8px;
  font-size: 14px;
  color: #166534;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.deduction-summary strong {
  font-size: 16px;
}

.result-card {
  padding: 20px 24px;
}

.result-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-item {
  background: #f9fafb;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}

.result-item.result-highlight {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1.5px solid #bfdbfe;
}

.result-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.result-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: #1e3a5f;
  font-variant-numeric: tabular-nums;
}

.result-highlight .result-value {
  font-size: 24px;
  color: #2563eb;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
}

.bracket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bracket-table thead th {
  background: #f3f4f6;
  color: #374151;
  font-weight: 700;
  padding: 10px 8px;
  text-align: center;
  border-bottom: 2px solid #d1d5db;
  white-space: nowrap;
  font-size: 12px;
}

.bracket-table tbody td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid #f3f4f6;
  color: #4b5563;
}

.bracket-table tbody tr:hover {
  background: #f9fafb;
}

.bracket-table tbody tr.bracket-active {
  background: #eff6ff;
  font-weight: 700;
}

.bracket-table tbody tr.bracket-active td {
  color: #1e3a5f;
}

.bracket-row-empty td {
  color: #9ca3af !important;
  padding: 20px 8px !important;
}

@media (max-width: 767px) {
  #info-section {
    flex-direction: column;
    gap: 16px;
    padding: 0 12px 20px;
  }

  #sec-intro,
  #sec-scenarios {
    flex: 1 1 100%;
  }

  .info-card {
    padding: 20px;
  }

  .scenario-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .scenario-item {
    padding: 10px 12px;
    font-size: 13px;
  }

  .scenario-icon {
    font-size: 18px;
  }

  #intro-text {
    font-size: 13px;
    line-height: 1.8;
  }
}

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

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.breakdown-item:last-child {
  border-bottom: none;
}

.breakdown-item.breakdown-total {
  margin-top: 4px;
  padding: 14px 16px;
  background: #fefce8;
  border-radius: 8px;
  border-bottom: none;
}

.breakdown-total .breakdown-label {
  font-weight: 700;
  color: #92400e;
}

.breakdown-total .breakdown-value {
  font-size: 20px;
  font-weight: 700;
  color: #92400e;
}

.breakdown-label {
  font-size: 13px;
  color: #6b7280;
}

.breakdown-value {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

#info-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 24px;
  display: flex;
  gap: 24px;
}

.info-card {
  flex: 1;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  padding: 28px;
}

.info-title {
  font-size: 19px;
  font-weight: 700;
  color: #1e3a5f;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 20px;
  background: #2563eb;
  border-radius: 2px;
}

#sec-intro {
  flex: 0 0 38%;
}

#sec-scenarios {
  flex: 0 0 62%;
}

#intro-text {
  font-size: 14px;
  line-height: 1.9;
  color: #4b5563;
  margin: 0;
}

#intro-text strong {
  color: #1e3a5f;
  font-weight: 700;
}

.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.scenario-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 14px;
  color: #374151;
  transition: background 0.2s;
}

.scenario-item:hover {
  background: #eff6ff;
}

.scenario-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.scenario-name {
  font-weight: 500;
}

footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: #9ca3af;
}

.page-info a {
  color: #6b7280;
  text-decoration: none;
}

.page-info a:hover {
  color: #2563eb;
}

@media (max-width: 767px) {
  #app {
    flex-direction: column;
    gap: 16px;
  }

  #input-panel,
  #result-panel {
    flex: 1 1 100%;
    max-width: 100%;
  }

  #result-panel {
    position: static;
    top: auto;
  }

  #page-title {
    font-size: 22px;
  }

  #page-subtitle {
    font-size: 12px;
  }

  main {
    padding: 16px 12px;
  }

  .card {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 14px;
  }

  .result-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .result-value {
    font-size: 17px;
  }

  .result-highlight .result-value {
    font-size: 20px;
  }

  .radio-group {
    flex-direction: column;
    gap: 8px;
  }

  .rate-info span {
    font-size: 11px;
    padding: 3px 8px;
  }
}

@media (max-width: 400px) {
  .result-cards {
    grid-template-columns: 1fr;
  }

  .result-item.result-highlight {
    grid-column: 1;
  }

  #page-title {
    font-size: 20px;
  }

  .card {
    padding: 12px;
  }

  .section-title {
    font-size: 15px;
  }

  .form-input,
  .form-select {
    font-size: 14px;
    padding: 8px 12px 8px 26px;
  }
}
