:root {
  --primary: #1677ff;
  --primary-hover: #1057cc;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  padding: 24px;
}

.page-shell {
  max-width: 1400px;
  margin: 0 auto;
}

/* 顶部标题区 */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.header-title {
  flex-shrink: 0;
}

.header-title .subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.header-title h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 汇率组件 */
.exchange-widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 340px;
}

.exchange-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exchange-rate {
  justify-content: space-between;
  margin-bottom: 6px;
}

.exchange-label {
  font-size: 12px;
  color: var(--muted);
}

.exchange-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: right;
  background: #f9fafb;
}

.currency-unit {
  font-size: 12px;
  color: var(--muted);
}

.convert-operator {
  font-size: 14px;
  color: var(--muted);
}

/* 汇总币种切换 */
.currency-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-label {
  font-size: 13px;
  color: var(--muted);
}

.switch-button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.switch-button:hover {
  background: #f3f4f6;
}

.switch-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 语言切换 */
.language-switcher {
  display: flex;
  gap: 6px;
}

.lang-button {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
}

.lang-button:hover {
  background: #f3f4f6;
}

.lang-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 卡片通用样式 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

/* 月度财务汇总吸顶 */
.monthly-summary-card {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  width: 100%;
  transition: box-shadow 0.2s;
}

.monthly-summary-card.is-sticky {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: #d1d5db;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 汇总表格 */
.summary-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td {
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  white-space: nowrap;
  vertical-align: middle;
  border-bottom: 1px solid #eef0f3;
}

.summary-table th:first-child,
.summary-table td:first-child {
  min-width: 120px;
  text-align: left;
}

.summary-table th:not(:first-child),
.summary-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text);
}

.summary-table tr:hover td {
  background: #f9fafb;
}

/* 客户资料查询 */
.query-card .card-header {
  border-bottom: 1px solid var(--border);
}

.query-content {
  padding: 16px 20px;
}

.query-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.query-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.query-label {
  font-size: 14px;
  color: var(--muted);
}

.query-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  min-width: 200px;
}

.month-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.result-label {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.result-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  min-width: 140px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.analyze-button {
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.analyze-button:hover {
  background: var(--primary-hover);
}

/* 视图模式切换 */
.view-mode-section {
  margin-bottom: 20px;
}

.view-mode-switcher {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.mode-button {
  padding: 10px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-button:hover {
  background: #f3f4f6;
}

.mode-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 明细表格 */
.ledger-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.ledger-table th {
  position: sticky;
  top: 0;
  padding: 12px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.ledger-table td {
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
}

.ledger-table tr:hover td {
  background: rgba(22, 119, 255, 0.06);
}

.ledger-table input[type="text"],
.ledger-table input[type="date"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  background: #fbfdff;
}

.ledger-table input[type="date"] {
  min-width: 120px;
}

.numeric {
  text-align: right;
}

.numeric input {
  text-align: right;
}

.action-col {
  text-align: center;
}

/* 币种按钮 */
.currency-buttons {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.currency-btn {
  min-width: 44px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.currency-btn:hover:not(.active) {
  background: #f3f4f6;
}

.currency-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 操作按钮 */
.delete-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.delete-btn:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.action-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f3f4f6;
}

.add-row-btn {
  margin: 16px 20px;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  align-self: flex-start;
}

.add-row-btn:hover {
  background: var(--primary-hover);
}

/* 分页控件 */
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-label {
  font-size: 13px;
  color: var(--muted);
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 60px;
}

.page-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.page-info {
  font-size: 13px;
  color: var(--muted);
}

/* 正负数值颜色 */
.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

/* 回到顶部 */
.back-to-top {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* 响应式 */
@media screen and (max-width: 1200px) {
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .exchange-widget {
    min-width: 100%;
  }
}

@media screen and (max-width: 768px) {
  body {
    padding: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-title h1 {
    font-size: 22px;
  }

  .title-tab {
    font-size: 16px;
    padding: 10px 14px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .query-row {
    flex-direction: column;
  }

  .result-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .view-mode-switcher {
    flex-wrap: wrap;
  }

  .mode-button {
    flex: 1;
    min-width: calc(33.33% - 6px);
  }

  .add-row-btn {
    flex: 1 1 100%;
    margin: 8px 0 0;
    text-align: center;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }

  .customers-shell {
    padding: 0;
  }

  .sub-tabs {
    flex-wrap: wrap;
  }

  .sub-tabs .back-btn {
    margin-left: 0;
    margin-top: 8px;
    width: 100%;
  }

  .pagination-controls {
    flex-wrap: wrap;
    gap: 6px;
  }

  .month-checkboxes {
    gap: 8px;
  }

  .exchange-widget {
    min-width: 100%;
    padding: 10px 12px;
  }

  .exchange-input {
    width: 72px;
  }

  .footer {
    margin-top: 24px;
    padding: 16px 12px;
  }
}

@media screen and (max-width: 480px) {
  body {
    padding: 8px;
  }

  .title-tab {
    font-size: 14px;
    padding: 8px 10px;
  }

  .title-tabs {
    gap: 2px;
  }

  .header-title .subtitle {
    font-size: 12px;
  }

  .summary-table {
    min-width: 560px;
  }

  .summary-table th,
  .summary-table td {
    padding: 0 8px;
    font-size: 12px;
  }

  .summary-table th:first-child,
  .summary-table td:first-child {
    min-width: 80px;
  }

  .result-value {
    min-width: 100px;
    font-size: 14px;
  }

  .mode-button {
    font-size: 12px;
    padding: 8px 12px;
  }

  .add-row-btn {
    font-size: 12px;
    padding: 10px 16px;
  }

  .ledger-table {
    min-width: 720px;
  }

  .ledger-table th,
  .ledger-table td {
    padding: 6px 4px;
    font-size: 12px;
  }

  .ledger-table input[type="text"],
  .ledger-table input[type="date"] {
    padding: 4px 6px;
    font-size: 12px;
  }

  .fee-table {
    font-size: 12px;
    min-width: 900px;
  }

  .fee-table thead th {
    padding: 6px 4px;
  }

  .fee-table tbody td {
    padding: 4px 4px;
  }

  .sub-tab {
    font-size: 13px;
    padding: 8px 14px;
  }

  .switch-button,
  .lang-button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .switch-button {
    min-width: auto;
  }

  .lang-button {
    min-width: 60px;
  }

  .back-to-top {
    width: 40px;
    height: 40px;
    font-size: 12px;
    right: 12px;
    bottom: 12px;
  }

  .footer-text {
    font-size: 12px;
  }

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

  .card-header {
    padding: 12px;
  }

  .query-content {
    padding: 12px;
  }
}

/* 标签页样式 */
.title-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--primary);
  position: relative;
  z-index: 10;
}

.title-tab {
  font-size: 20px;
  font-weight: 600;
  color: #888;
  padding: 12px 20px;
  cursor: pointer;
  margin: 0;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  user-select: none;
  position: relative;
  z-index: 11;
}

.title-tab:hover {
  color: var(--primary);
  background: rgba(22, 119, 255, 0.05);
  border-radius: 6px 6px 0 0;
}

.title-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--card);
  border-radius: 6px 6px 0 0;
}

/* 客户档案容器 */
.customers-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.customers-shell .card {
  margin-bottom: 20px;
}

/* 子标签页样式 */
.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.sub-tab {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.sub-tab:hover {
  background: #e5e7eb;
  color: var(--text);
}

.sub-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sub-tabs .back-btn {
  margin-left: auto;
}

/* THB/CNY 客户子容器 */
.thb-customers-subshell,
.cny-customers-subshell {
  width: 100%;
}

/* THB/CNY 客户容器（兼容旧类名） */
.thb-customers-shell,
.cny-customers-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
}

.thb-customers-shell .card,
.cny-customers-shell .card {
  margin-bottom: 20px;
}

/* 仓储费用表格样式 */
.fee-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  font-size: 13px;
}

.fee-table thead th {
  padding: 8px 6px;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
  border: 1px solid #d1d5db;
  white-space: nowrap;
}

.fee-table .fee-header-row1 th {
  color: white;
}

.fee-table .fee-header-row2 th {
  background: #f3f4f6;
  font-weight: 500;
  font-size: 12px;
}

.fee-group.inbound-group {
  background: #4ade80;
}

.fee-group.outbound-group {
  background: #fb923c;
}

.fee-group.storage-group {
  background: #a78bfa;
}

.fee-group.others-group {
  background: #60a5fa;
}

.fee-col-customer {
  background: #3b82f6 !important;
  color: white;
  text-align: center;
  min-width: 120px;
}

.fee-table tbody td {
  border: 1px solid #d1d5db;
  padding: 4px 6px;
  text-align: center;
  vertical-align: middle;
}

.fee-input {
  width: 100%;
  padding: 4px 6px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 13px;
  outline: none;
  resize: none;
}

.fee-input:focus {
  background: #fffbeb;
  box-shadow: inset 0 0 0 2px #f59e0b;
}

.fee-input:hover {
  background: #f9fafb;
}

.fee-cell {
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
}

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

.fee-table .editing-row {
  background: #fffbeb;
}

.edit-btn {
  padding: 4px 10px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
}

.edit-btn:hover {
  background: #2563eb;
}

.save-btn {
  padding: 4px 10px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
}

.save-btn:hover {
  background: #059669;
}

.fee-table .action-col {
  width: 60px;
}

.fee-table .fee-col-customer-row {
  font-weight: 500;
  text-align: left;
}

/* 调整各列宽度 */
.fee-table .fee-col-customer {
  min-width: 130px;
}

.fee-table .fee-col-index {
  min-width: 40px;
  width: 40px;
}

.fee-cell-index {
  font-weight: 500;
  color: var(--muted);
}

.fee-table .fee-col {
  min-width: 60px;
}

.fee-table .fee-col:nth-child(n+1):nth-child(-n+5) {
  min-width: 55px;
}

/* 备案信息区块 */
.footer {
  max-width: 1400px;
  margin: 40px auto 0;
  padding: 24px 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.footer-text {
  margin: 0;
  line-height: 1.8;
}

.footer-text a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-text a:hover {
  color: var(--primary);
  text-decoration: underline;
}
