/* ============ หน้าคำนวณภาษี (tax.js) ============ */

.tax-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tax-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* แท็บ บุคคล/นิติบุคคล */
.tax-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 4px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.tax-tab {
  border: 0;
  background: transparent;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.tax-tab.active {
  color: var(--brand, #2563eb);
  border-bottom-color: var(--brand, #2563eb);
}

/* แถบควบคุม */
.tax-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
  align-items: start;
}

/* ปุ่ม "ดึงรายได้จากระบบ" ให้อยู่ระดับเดียวกับช่อง input */
.tax-field-action .tax-field-spacer {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.tax-field-action .btn {
  width: 100%;
  min-height: 40px;
}

.tax-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.tax-hint {
  font-weight: 400;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.3;
}

.tax-section {
  padding: 18px;
}

.tax-section h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

/* การ์ดรายได้ */
.tax-rev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.tax-rev-item {
  background: var(--surface-2, #f8fafc);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tax-rev-item span {
  font-size: 12px;
  color: #64748b;
}

.tax-rev-item b {
  font-size: 18px;
  color: var(--ink, #0f172a);
}

/* toggle วิธีหักค่าใช้จ่าย */
.tax-expense-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border, #e2e8f0);
}

.tax-toggle-label {
  font-weight: 700;
  font-size: 13px;
  color: #334155;
}

.tax-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* ฟอร์มลดหย่อน */
.tax-deduction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.tax-link-btn {
  align-self: flex-start;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 2px;
}

.tax-link-btn:hover {
  background: #dbeafe;
}

.tax-half-tag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
  margin-left: 2px;
}

.tax-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.tax-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

/* ตารางสรุปการคำนวณ */
.tax-calc {
  display: flex;
  flex-direction: column;
}

.tax-calc-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border, #eef2f7);
  font-size: 14px;
}

.tax-calc-row.subtotal {
  font-weight: 700;
  background: var(--surface-2, #f8fafc);
  border-radius: 8px;
  padding: 10px 8px;
  border-bottom: 0;
}

.tax-calc-row .minus {
  color: #dc2626;
}

/* ขั้นบันไดภาษี */
.tax-brackets {
  margin-top: 14px;
  background: var(--surface-2, #f8fafc);
  border-radius: 10px;
  padding: 10px 12px;
}

.tax-bracket-head {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 6px;
}

.tax-bracket-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  color: #475569;
}

.tax-bracket-note {
  margin-top: 12px;
  font-size: 13px;
  color: #16a34a;
}

/* ผลลัพธ์สุดท้าย */
.tax-final {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border-radius: 12px;
}

.tax-final span {
  font-size: 15px;
  font-weight: 600;
}

.tax-final b {
  font-size: 22px;
}

.tax-effrate {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  text-align: right;
}

.tax-disclaimer {
  padding: 14px 16px;
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  line-height: 1.5;
}
