﻿@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600&display=swap");

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --border: #e5e5e5;
  --accent: #111111;
  --danger: #b42318;
  --radius: 8px;
  --topbar-height: 64px;
  font-family: "Noto Serif SC", "Noto Serif", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    linear-gradient(0deg, rgba(17, 17, 17, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--fg);
  line-height: 1.6;
}

body.report-mode {
  background: #fff;
  background-image: none;
}

body.report-mode main {
  padding: 16px 12px 40px;
}

body.has-topbar {
  padding-top: var(--topbar-height);
}

a {
  color: var(--fg);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 28px 24px 80px;
  animation: fadeIn 0.35s ease-out;
}

h1,
h2,
h3 {
  margin: 0 0 16px;
  font-weight: 600;
}

p {
  margin: 0 0 12px;
  color: var(--muted);
}

.button,
button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--fg);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--fg);
}

button.ghost,
.button.ghost {
  background: transparent;
  color: var(--fg);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  color: var(--fg);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.table th,
.table td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  font-size: 14px;
}

.table th {
  background: #fafafa;
  font-weight: 600;
}

.scroll-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 8px;
}

.report-table-wrap {
  width: 100%;
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: #fff;
}

.report-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.report-table th,
.report-table td {
  border: 1px solid #111;
  padding: 8px 6px;
  text-align: center;
  font-size: 15px;
  vertical-align: middle;
}

.report-table th {
  background: #f7f7f7;
  font-weight: 600;
}

.report-block h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
}

.page-viewport {
  width: 100%;
  position: relative;
  margin: 0 auto 20px;
  display: flex;
  justify-content: center;
}

.report-page {
  width: 900px;
  max-width: 900px;
  padding: 24px 24px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: "SimSun", "Songti SC", "STSong", serif;
  color: #000;
  font-size: 16px;
  line-height: 1.7;
  overflow: hidden;
}

.report-section {
  margin-bottom: 22px;
}

.report-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
}

.report-fixed-text {
  margin: 0 0 6px;
}

.report-indent {
  padding-left: 18px;
}

.exp-report-viewport {
  margin-top: 8px;
}

.exp-input-page {
  width: min(1280px, calc(100vw - 32px));
  max-width: 1280px;
  border: none;
  border-radius: 0;
  padding: 20px 8px 10px;
}

.exp-inline-gap {
  margin-top: 8px;
  margin-bottom: 8px;
}

.exp-subtitle-gap {
  margin-top: 16px;
  margin-bottom: 8px;
}

.report-inline-input {
  width: 140px;
  border: none;
  border-bottom: 1px solid #111;
  border-radius: 0;
  padding: 4px 4px;
  background: transparent;
  font-size: 15px;
}

.report-inline-input:focus {
  outline: none;
  border-bottom-width: 2px;
}

.exp-x-input {
  text-align: center;
  border: none;
  border-bottom: none;
  padding: 0;
  background: transparent;
  font-size: 15px;
  cursor: default;
}

.exp-x-input:focus {
  outline: none;
  border: none;
  border-bottom: none;
}

.exp-fixed-x {
  display: inline-block;
  width: 100%;
  text-align: center;
  font-size: 15px;
  color: #111;
}

.exp-toolbar {
  margin-top: 14px;
  padding-left: 18px;
 }

.report-paragraph {
  margin: 0 0 8px;
  color: #000;
  font-size: 15px;
}

.report-procedure {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
  color: #1d4ed8;
}

.report-procedure .report-title {
  color: #111;
}

.report-procedure .report-fixed-text {
  color: #1d4ed8;
  font-size: 0.667em;
}

.report-step-list {
  margin: 8px 0 0 32px;
  padding: 0 8px 0 0;
  color: #1d4ed8;
  font-size: 0.667em;
}

.report-step-list li {
  margin-bottom: 8px;
  line-height: 1.75;
}

.report-step-list li:last-child {
  margin-bottom: 0;
}

.analysis-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  margin-top: 10px;
}

.report-page .report-table {
  min-width: 0;
  font-size: 15px;
  table-layout: fixed;
}

.report-page .report-table th {
  background: #fff;
}

.report-page .report-row-header {
  width: auto;
}

.report-page .chart-fixed {
  width: 33.333% !important;
  max-width: 340px !important;
  min-width: 240px !important;
  margin-right: 0;
}

#table1View tr:nth-child(2) .report-value {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding-left: 2px;
  padding-right: 2px;
}

.report-page .report-value {
  display: inline-block;
  min-width: 100px;
  border-bottom: 1px solid #111;
  padding: 6px 4px;
  font-weight: 500;
}

.report-left {
  text-align: left;
  padding-left: 12px;
}

.report-blank-long {
  min-width: 240px;
}

.report-blank-short {
  min-width: 120px;
}

.report-item {
  margin-bottom: 18px;
}

.report-item-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.report-line {
  font-size: 15px;
  line-height: 1.8;
  word-break: break-word;
}

.report-computed {
  color: #1d4ed8;
}

.report-computed mjx-container {
  color: inherit !important;
}

.report-fill {
  display: inline-flex;
  position: relative;
  vertical-align: bottom;
  border-bottom: 1px solid #111;
  padding: 0 6px 3px;
  margin: 0 2px;
}

.report-fill-content {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.5;
}

.report-q2-line {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: 2px;
  white-space: nowrap;
}

.report-fill-formula {
  width: 300px;
  min-height: 42px;
  align-items: flex-end;
  overflow: hidden;
}

.report-fill-f0 {
  width: 118px;
  min-height: 34px;
  align-items: flex-end;
}

.report-q3-line {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
  white-space: nowrap;
}

.report-fill-e-mid {
  width: 360px;
  min-height: 34px;
  align-items: flex-end;
}

.report-fill-e-final {
  width: 160px;
  min-height: 34px;
  align-items: flex-end;
}

.report-fill-formula .report-fill-content mjx-container {
  font-size: 0.88em !important;
}

.report-fill-formula .report-fill-content {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  line-height: 1.2;
}

.report-fill-content mjx-container {
  margin: 0 !important;
}

.report-fill-formula .report-fill-content mjx-container {
  display: block !important;
  max-width: 100%;
  overflow: hidden;
}

.report-formula {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed #111;
  border-radius: 6px;
  background: #fff;
}

.report-formula-line {
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
  margin-bottom: 6px;
}

.report-formula-line:last-child {
  margin-bottom: 0;
}

.report-phi {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #ddd;
}

.report-blank {
  display: inline-block;
  min-width: 200px;
  padding: 2px 6px;
  border-bottom: 1px solid #111;
  vertical-align: baseline;
}

.report-row-header {
  background: #fafafa;
  font-weight: 600;
  width: 180px;
}

.diag-cell {
  position: relative;
  min-width: 180px;
  background:
    linear-gradient(
      to bottom right,
      transparent calc(50% - 1px),
      #111 calc(50% - 1px),
      #111 calc(50% + 1px),
      transparent calc(50% + 1px)
    );
}

.diag-top,
.diag-bottom {
  position: absolute;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  background: #fff;
  padding: 2px 4px;
}

.diag-only {
  padding: 0;
}

.diag-top {
  top: 6px;
  left: 8px;
}

.diag-bottom {
  right: 8px;
  bottom: 6px;
}

.report-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #111;
  border-radius: 0;
  padding: 6px 4px;
  text-align: center;
  font-size: 15px;
  background: transparent;
  color: var(--fg);
}

.report-input:focus {
  outline: none;
  border-bottom-width: 2px;
}

.report-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 15px;
}

.report-inline input {
  width: 120px;
  border: none;
  border-bottom: 1px solid #111;
  border-radius: 0;
  padding: 6px 4px;
  font-size: 15px;
  background: transparent;
}

.report-inline input:focus {
  outline: none;
  border-bottom-width: 2px;
}

.report-value {
  display: inline-block;
  min-width: 120px;
  border-bottom: 1px solid #111;
  padding: 6px 4px;
  font-weight: 600;
}

.table2-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}

.table2-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
}

.table2-side textarea {
  min-height: 180px;
}

@media (max-width: 960px) {
  .table2-layout {
    grid-template-columns: 1fr;
  }

  .report-fill-formula {
    width: min(300px, 76vw);
  }

  .report-fill-e-mid {
    width: min(360px, 82vw);
  }

  .report-q2-line {
    flex-wrap: wrap;
  }

  .report-q3-line {
    flex-wrap: wrap;
  }
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0 20px;
}

.result-toolbar {
  width: min(900px, 100%);
  margin: 12px auto 20px;
  position: relative;
  z-index: 1;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.badge {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.notice {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  font-size: 14px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 0.95;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  font-size: 14px;
  overflow: hidden;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

.topbar-center {
  flex: 1 1 auto;
  justify-content: center;
}

.topbar-email {
  font-size: 14px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}

.topbar-balance {
  font-size: 14px;
  color: var(--fg);
  white-space: nowrap;
}

.back-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}

.topup-plus {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.logout-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1200;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: min(86vh, 760px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.plan-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  padding: 12px;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
}

.plan-btn strong {
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
}

.pay-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fafafa;
}

.pay-box img {
  max-width: 220px;
  width: 100%;
  height: auto;
  display: block;
  margin: 8px auto 4px;
}

.chart-fixed {
  position: relative;
  width: 33.333%;
  max-width: 520px;
  min-width: 260px;
  flex: 0 0 auto;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  height: auto;
  margin-right: 0;
}

.chart-fixed canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.chart-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
}

.report-step-text {
  margin-bottom: 8px;
}

.chart-action-inline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 4px;
  margin-left: 0;
  flex: 0 0 auto;
}

.footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  main {
    padding: 20px 16px 60px;
  }

  h1 {
    font-size: 22px;
  }

  .topbar {
    height: auto;
    min-height: 64px;
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-center {
    justify-content: flex-start;
  }

  .topbar-email {
    max-width: 58vw;
  }

  body.has-topbar {
    padding-top: var(--topbar-height);
  }

  .chart-fixed {
    width: 66.666%;
    max-width: none;
  }

  .report-page {
    width: 100%;
    max-width: 100%;
    padding: 16px 12px 10px;
  }

  .report-indent {
    padding-left: 8px;
  }

  .report-page .chart-fixed {
    width: 66.666% !important;
    max-width: none !important;
    min-width: 200px !important;
  }

  .chart-row {
    flex-wrap: wrap;
  }

  .chart-action-inline {
    width: auto;
  }

}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
