/* ===== CSS Variables ===== */
:root {
  --primary: #0EA5A0;
  --primary-light: #14B8A6;
  --primary-dark: #0D9488;
  --primary-bg: #F0FDF9;
  --accent: #F59E0B;
  --accent-light: #FCD34D;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F97316;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --shadow: 0 4px 24px rgba(14, 165, 160, 0.08);
  --shadow-hover: 0 8px 32px rgba(14, 165, 160, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 960px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background Decoration ===== */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(14,165,160,0.06) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  bottom: -150px;
  left: -150px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245,158,11,0.05) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #0F766E 100%);
  color: white;
  padding: 48px 0 56px;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
  border-radius: 50%;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  border-radius: 50%;
}

.header-inner {
  position: relative;
  z-index: 1;
}

.breadcrumb {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 16px;
}

.breadcrumb a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: opacity 0.2s;
}

.breadcrumb a:hover {
  opacity: 1;
}

.breadcrumb span {
  margin: 0 6px;
  opacity: 0.6;
}

.site-header h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.site-header .subtitle {
  font-size: 15px;
  opacity: 0.85;
  font-weight: 400;
  line-height: 1.6;
}

.header-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 80px;
  opacity: 0.12;
}

/* ===== Main Content ===== */
main {
  padding: 40px 0 60px;
}

/* ===== Calculator Card ===== */
.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 32px;
  transition: box-shadow 0.3s;
}

.calc-card:hover {
  box-shadow: var(--shadow-hover);
}

/* ===== Tabs ===== */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--primary-bg);
}

.tab-btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  font-family: var(--font);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  transition: background 0.3s;
  border-radius: 3px 3px 0 0;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(14,165,160,0.04);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  background: var(--primary);
}

.tab-panel {
  display: none;
  padding: 28px 32px 32px;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-group input,
.form-group select {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,165,160,0.1);
}

.form-group input::placeholder {
  color: var(--text-light);
}

.form-hint {
  font-size: 12px;
  color: var(--primary);
  margin-top: 4px;
  display: none;
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  width: 100%;
  padding-right: 36px;
}

.input-suffix::after {
  content: '元';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

.input-suffix-suffix::after {
  content: '年';
}

.input-suffix-months::after {
  content: '月';
}

/* ===== Buttons ===== */
.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(14,165,160,0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14,165,160,0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

/* ===== Result ===== */
.result-container {
  display: none;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px dashed var(--border);
  animation: fadeIn 0.4s ease;
}

.result-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  border-left: 3px solid var(--border);
  transition: background 0.2s;
}

.result-item:hover {
  background: var(--primary-bg);
}

.result-item.highlight {
  background: var(--primary-bg);
  border-left-color: var(--primary);
}

.result-item.success {
  border-left-color: var(--success);
}

.result-item.warning {
  border-left-color: var(--warning);
}

.result-item.danger {
  border-left-color: var(--danger);
}

.result-item.primary {
  background: linear-gradient(135deg, var(--primary-bg), rgba(14,165,160,0.08));
  border-left-color: var(--primary);
  font-weight: 600;
}

.result-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.result-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.result-item.primary .result-value {
  color: var(--primary);
  font-size: 18px;
}

.result-item.danger .result-value {
  color: var(--danger);
}

.result-item.success .result-value {
  color: var(--success);
}

.result-summary {
  margin-top: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary-bg), rgba(14,165,160,0.04));
  border-radius: var(--radius-xs);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

.result-summary strong {
  color: var(--primary);
}

/* ===== Detail Table ===== */
.detail-table-wrap {
  margin-top: 20px;
}

.detail-table-wrap h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-table th {
  background: var(--primary-bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.detail-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.detail-table tbody tr:hover {
  background: var(--primary-bg);
}

/* ===== Section ===== */
.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 22px;
  background: var(--primary);
  border-radius: 3px;
  margin-right: 10px;
  vertical-align: middle;
}

/* ===== Formula Card ===== */
.formula-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 20px;
}

.formula-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.formula-item {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
}

.formula-item:last-child {
  margin-bottom: 0;
}

.formula-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.formula-expr {
  font-size: 15px;
  font-family: 'Courier New', Consolas, monospace;
  color: var(--primary-dark);
  background: rgba(14,165,160,0.06);
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
  word-break: break-all;
}

.formula-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.law-ref {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  font-style: italic;
}

/* ===== Tax Table ===== */
.tax-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.tax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tax-table th {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
}

.tax-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.tax-table tbody tr:nth-child(even) {
  background: var(--primary-bg);
}

.tax-table tbody tr:hover {
  background: rgba(14,165,160,0.08);
}

/* ===== Example Card ===== */
.example-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 20px;
}

.example-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.example-scenario {
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.example-scenario:last-child {
  margin-bottom: 0;
}

.example-scenario h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 10px;
}

.example-step {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  margin-bottom: 4px;
}

.example-step strong {
  color: var(--text);
}

.example-result {
  margin-top: 10px;
  padding: 10px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-xs);
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 600;
}

/* ===== FAQ ===== */
.faq-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 20px;
}

.faq-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: color 0.2s;
  user-select: none;
}

.faq-question:hover {
  color: var(--primary);
}

.faq-icon {
  font-size: 20px;
  color: var(--primary);
  font-weight: 300;
  transition: transform 0.3s;
  flex-shrink: 0;
  margin-left: 12px;
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.faq-answer-inner {
  padding-bottom: 16px;
}

/* ===== Ad Section ===== */
.ad-section {
  margin: 32px 0;
  text-align: center;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--text);
  color: rgba(255,255,255,0.6);
  padding: 32px 0;
  font-size: 13px;
  text-align: center;
  line-height: 1.8;
}

.site-footer a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
}

.site-footer a:hover {
  color: white;
}

.footer-links {
  margin-bottom: 8px;
}

.footer-links a {
  margin: 0 12px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--danger);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ===== Disclaimer ===== */
.disclaimer {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 13px;
  color: #92400E;
  line-height: 1.7;
}

.disclaimer strong {
  color: #78350F;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root {
    --max-width: 100%;
  }

  .site-header {
    padding: 32px 0 40px;
  }

  .site-header h1 {
    font-size: 24px;
  }

  .header-icon {
    display: none;
  }

  .tab-btn {
    font-size: 14px;
    padding: 14px 12px;
  }

  .tab-panel {
    padding: 20px 16px 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .formula-card,
  .example-card,
  .faq-card {
    padding: 20px 16px;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .section-title {
    font-size: 19px;
  }
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 20px;
  }

  .site-header .subtitle {
    font-size: 13px;
  }

  .result-value {
    font-size: 14px;
  }

  .result-item.primary .result-value {
    font-size: 16px;
  }
}

/* ===== Print ===== */
@media print {
  .site-header,
  .ad-section,
  .site-footer,
  .btn-row,
  .toast {
    display: none;
  }

  .calc-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .result-container {
    display: block !important;
  }
}
