/* ============================================================
   Wildberries 跨境个体户个税台账 — 薄荷绿毛玻璃主题
   ============================================================ */
:root {
  --mint-50:  #f0faf6;
  --mint-100: #e3f6ee;
  --mint-200: #c9ecdd;
  --mint-300: #a6e0c8;
  --mint-400: #7fd0b1;
  --mint-500: #57bf96;
  --mint-600: #41a87d;
  --mint-700: #338a68;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-shadow: 0 8px 32px rgba(60, 150, 115, 0.18);
  --glass-blur: blur(14px) saturate(165%);

  --text: #234137;
  --text-soft: #5b7468;
  --text-faint: #8aa294;
  --line: rgba(70, 150, 115, 0.16);

  --warn-bg: rgba(217, 160, 60, 0.14);
  --warn-fg: #a9752a;
  --warn-bd: rgba(217, 160, 60, 0.26);
  --rub-bg: rgba(102, 180, 130, 0.14);
  --rub-fg: #2f8255;
  --ad-bg: rgba(70, 160, 220, 0.12);
  --ad-fg: #2b7cad;

  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: transparent;
  min-height: 100vh;
}

body {
  position: relative;
  overflow-x: hidden;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 600px at 12% -10%, #d7f3e6 0%, transparent 55%),
    radial-gradient(1000px 700px at 100% 0%, #c7ecdd 0%, transparent 50%),
    radial-gradient(900px 800px at 50% 120%, #b9e6d2 0%, transparent 55%),
    linear-gradient(160deg, #eafff5 0%, #d9f3e8 40%, #c7ecdd 100%);
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: clamp(12px, 1.6vw, 16px) clamp(14px, 2vw, 24px);
  margin: clamp(12px, 1.6vw, 18px) clamp(12px, 2vw, 22px) 0;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; }
.app-header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--text-soft); }
.header-actions { display: flex; gap: 10px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 20px;
  padding: clamp(12px, 1.8vw, 20px) clamp(12px, 2vw, 22px) 40px;
  align-items: start;
}
.side-col { display: flex; flex-direction: column; gap: 20px; }
.main-col { min-width: 0; }

.card { padding: 18px 20px; }
.card-title { margin: 0 0 14px; font-size: 15.5px; font-weight: 700; color: var(--mint-700); }

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--glass-bg-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(60,150,115,.2); }
.btn:active { transform: translateY(0); }
.btn.solid {
  background: linear-gradient(135deg, var(--mint-400), var(--mint-600));
  color: #fff; border-color: transparent;
}
.btn.ghost { background: var(--glass-bg-strong); }
.btn.tiny { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: #b3462f; border-color: rgba(179,70,47,.3); }

/* ---------- Drop zone ---------- */
.drop-zone {
  border: 2px dashed var(--mint-400);
  border-radius: var(--radius);
  background: rgba(255,255,255,.4);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.drop-zone.drag-over {
  background: rgba(127, 208, 177, 0.28);
  border-color: var(--mint-600);
}
.drop-icon { font-size: 30px; }
.drop-main { margin: 8px 0 4px; font-weight: 600; }
.drop-sub { margin: 0; font-size: 12px; color: var(--text-soft); }

.upload-hints { margin-top: 14px; font-size: 12.5px; line-height: 1.7; }
.hint-line { color: var(--text-soft); margin: 6px 0; }
.hint-warn { color: var(--warn-fg); margin: 6px 0; font-weight: 600; }
.hint-tip { color: var(--text-soft); margin: 6px 0; }

.debug-box { margin-top: 14px; font-size: 12.5px; color: var(--text-soft); }
.debug-box summary { cursor: pointer; user-select: none; }
.debug-box textarea {
  width: 100%; min-height: 80px; margin: 8px 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px; font-size: 12px; resize: vertical;
  background: rgba(255,255,255,.6); color: var(--text);
}

/* ---------- Rate panel ---------- */
.rate-add { display: flex; gap: 8px; flex-wrap: wrap; }
.rate-note { font-size: 12px; color: var(--text-soft); margin: 10px 0; line-height: 1.6; }
.rate-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow: auto; }
.rate-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.5); border: 1px solid var(--line); font-size: 12.5px;
}
.rate-item .rate-val { font-weight: 700; color: var(--mint-700); }
.rate-item .rate-src { color: var(--text-soft); font-size: 11.5px; }
.rate-item .rate-src.notice { color: var(--rub-fg); }
.rate-item .rate-del { cursor: pointer; color: #b3462f; border: none; background: none; font-size: 13px; }

.mini-input, .mini-select {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 9px; font-size: 12.5px; background: rgba(255,255,255,.7); color: var(--text);
}
.mini-input { width: 120px; max-width: 100%; }

/* ---------- Month bar ---------- */
.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.month-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.month-tab {
  padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: rgba(255,255,255,.5); color: var(--text-soft);
}
.month-tab.active {
  background: linear-gradient(135deg, var(--mint-400), var(--mint-600));
  color: #fff; border-color: transparent;
}
.month-tab .mt-del { margin-left: 6px; opacity: .7; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-filter { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-soft); }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.summary-info { font-size: 12.5px; color: var(--mint-700); font-weight: 600; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.summary-table th, .summary-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.summary-table th { color: var(--mint-700); font-weight: 700; }
.summary-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.summary-table tr.grand { background: rgba(127,208,177,.16); font-weight: 700; }
.summary-table tr.grand td:first-child { color: var(--mint-700); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.entry-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 880px; }
.entry-table th, .entry-table td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.entry-table thead th {
  position: sticky; top: 0; background: rgba(231, 246, 238, 0.92);
  color: var(--mint-700); font-weight: 700; z-index: 1; backdrop-filter: blur(6px);
}
.entry-table tbody tr:hover { background: rgba(127, 208, 177, 0.1); }
.entry-table .col-num { text-align: right; }
.entry-table .col-check { width: 36px; }
.entry-table .col-act { width: 70px; }
/* 操作列吸附右侧：横向滚动时「删除」按钮始终可见，无需滑到最右 */
.entry-table th.col-act, .entry-table td.col-act {
  position: sticky; right: 0; z-index: 2;
  background: #edf7f1;
  box-shadow: -8px 0 10px -8px rgba(35, 65, 55, 0.3);
}
.entry-table thead th.col-act { z-index: 3; background: #e7f6ee; }
.entry-table tbody tr:hover td.col-act { background: #e0f1e8; }
.row-summary td.col-act { background: #fbf3e0 !important; }
.entry-table input.amount, .entry-table input.ratesel {
  width: 92px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,.7); font-size: 12px; text-align: right;
}
.entry-table select.cat-select {
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px;
  background: rgba(255,255,255,.7); font-size: 12px; max-width: 130px;
}
.entry-table .cny-amount { font-weight: 700; color: var(--mint-700); }
.row-summary { background: rgba(255, 230, 180, 0.18) !important; }
.row-summary td:first-child { position: relative; }

.empty-hint { padding: 26px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  line-height: 1.5; white-space: nowrap;
}
.tag.wb { background: rgba(127,208,177,.16); color: var(--mint-700); border: 1px solid rgba(127,208,177,.3); }
.tag.summary { background: rgba(180,150,90,.14); color: #8a6a2a; border: 1px solid rgba(180,150,90,.26); }
.tag.warn {
  background: rgba(217,160,60,.14);
  color: #a9752a;
  border: 1px solid rgba(217,160,60,.26);
}
.tag.ad-upd {
  background: rgba(70,160,220,0.12);
  color: #2b7cad;
  border: 1px solid rgba(70,160,220,.24);
}
.tag.rub-notice {
  background: rgba(102, 180, 130, 0.14);
  color: #2f8255;
  border: 1px solid rgba(102,180,130,.28);
}
.tag-stack { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ---------- Category panel ---------- */
.category-panel { margin-top: 16px; font-size: 13px; }
.category-panel summary { cursor: pointer; color: var(--mint-700); font-weight: 600; }
.cat-actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px; font-size: 12px;
  background: rgba(255,255,255,.55); border: 1px solid var(--line);
}
.cat-chip .cat-type { font-size: 10.5px; color: var(--text-faint); }
.cat-chip .cat-del { cursor: pointer; color: #b3462f; border: none; background: none; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(35, 65, 55, 0.32);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none; }
.modal { max-width: 520px; width: 100%; padding: 24px; max-height: 90vh; overflow: auto; }
.modal-title { margin: 0 0 12px; font-size: 16px; }
.modal-title.warn { color: var(--warn-fg); }
.modal-title.rub { color: var(--rub-fg); }
.modal-body { font-size: 13.5px; line-height: 1.7; color: var(--text); margin: 0 0 12px; }
.modal-tip { font-size: 12.5px; color: var(--text-soft); background: rgba(127,208,177,.14); padding: 10px 12px; border-radius: var(--radius-sm); margin: 0 0 16px; line-height: 1.6; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.toast {
  padding: 11px 18px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: var(--glass-bg-strong); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  color: var(--text); animation: toastIn .25s ease;
  max-width: 460px; text-align: center;
}
.toast.warn { border-color: var(--warn-bd); color: var(--warn-fg); background: rgba(255,248,235,.92); }
.toast.ok { border-color: rgba(127,208,177,.5); color: var(--mint-700); }
.toast .toast-actions { margin-top: 10px; display: flex; gap: 10px; justify-content: center; }
.toast .toast-btn {
  cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 5px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
}
.toast .toast-btn.primary { background: linear-gradient(135deg, var(--mint-400), var(--mint-600)); color: #fff; border-color: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* rate hover hint */
.rate-hint { position: relative; }
.rate-hint::after {
  content: attr(data-hint);
  position: absolute; bottom: 130%; left: 0; width: 220px;
  background: #2b4038; color: #fff; padding: 8px 10px; border-radius: 8px;
  font-size: 11px; font-weight: 500; line-height: 1.5; opacity: 0; pointer-events: none;
  transition: opacity .15s ease; z-index: 30;
}
.rate-hint:hover::after { opacity: 1; }

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

/* 条目行：文档日期小字 */
.doc-date { font-size: 11px; color: var(--text-faint); margin-top: 2px; font-weight: 500; }
.month-select { max-width: 110px; }

/* 顶部全局免责提示 */
.disclaimer-bar {
  max-width: 1280px; width: calc(100% - 28px); margin: 14px auto 0; padding: 10px 18px;
  background: rgba(255, 244, 229, 0.9); border: 1px solid #f2d9ad; border-radius: 12px;
  color: #8a5a1f; font-size: 13px; font-weight: 500; line-height: 1.6;
  backdrop-filter: blur(8px);
}

/* 条目备注输入 */
.remark-input {
  width: 100%; min-width: 90px; border: 1px dashed var(--line, #cfe3da); border-radius: 8px;
  padding: 5px 8px; font-size: 12px; background: rgba(255,255,255,0.6); color: var(--text-main, #223);
}
.remark-input:focus { outline: none; border-style: solid; border-color: var(--mint-600, #3fae92); }

/* 分页栏 */
.pagination-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 12px 4px 4px; font-size: 12px; color: var(--text-faint, #6b7f78);
}
.pg-size { display: flex; align-items: center; gap: 6px; }
.pg-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 28px; height: 26px; padding: 0 8px; border: 1px solid var(--line, #cfe3da); border-radius: 7px;
  background: rgba(255,255,255,0.7); color: var(--text-main, #223); font-size: 12px; cursor: pointer;
}
.pg-btn:hover:not(:disabled) { border-color: var(--mint-600, #3fae92); color: var(--mint-700, #2e8c74); }
.pg-btn.active { background: var(--mint-600, #3fae92); border-color: var(--mint-600, #3fae92); color: #fff; }
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pg-ellipsis { padding: 0 4px; color: var(--text-faint, #6b7f78); }
.pg-info { white-space: nowrap; }

/* 手动新增记录弹窗 */
.modal-wide { max-width: 620px; }
.modal-image { max-width: 90vw; max-height: 90vh; padding: 0; background: transparent; box-shadow: none; position: relative; }
.modal-image img { max-width: 90vw; max-height: 88vh; border-radius: 12px; display: block; }
.modal-close { position: absolute; top: -12px; right: -12px; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: #fff; color: #333; font-size: 16px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.manual-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 14px 0 6px; }
.manual-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-main, #2b3a36); font-weight: 600; }
.manual-form label.manual-full { grid-column: 1 / -1; }
.manual-form input, .manual-form select { padding: 8px 9px; border: 1px solid var(--line, #cfe3da); border-radius: 9px; font-size: 13px; font-weight: 500; background: rgba(255,255,255,.75); }
.manual-form input:focus, .manual-form select:focus { outline: none; border-color: var(--mint-600, #3fae92); }

/* 条目图片核实列 */
.col-img { text-align: center; vertical-align: middle; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line, #cfe3da); cursor: pointer; display: inline-block; vertical-align: middle; }
.thumb:hover { border-color: var(--mint-600, #3fae92); box-shadow: 0 0 0 2px rgba(63,174,146,.25); }
.btn.tiny.link { font-size: 11px; padding: 2px 6px; margin-top: 2px; color: var(--mint-700, #2e8c74); background: transparent; border: 1px solid var(--line, #cfe3da); }
.btn.tiny.link:hover { border-color: var(--mint-600, #3fae92); }

/* 汇总面板：窄屏横向滚动，避免月份多时溢出 */
#summaryPanel { overflow-x: auto; }
#summaryPanel .summary-table { min-width: 520px; }

/* ============ 响应式断点 ============ */

/* 平板及以下：左栏堆叠到上方，整体单列 */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { flex-direction: column; }
  .app-header { margin-left: 14px; margin-right: 14px; }
  .layout { padding-left: 14px; padding-right: 14px; }
  .disclaimer-bar { width: calc(100% - 28px); }
}

/* 手机：进一步压缩内边距、表单单列、月份/工具条纵向排列 */
@media (max-width: 640px) {
  .app-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; }
  .app-header h1 { font-size: 17px; }

  .card { padding: 14px 14px; }
  .card-title { font-size: 14.5px; }

  .month-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .month-tabs { overflow-x: auto; padding-bottom: 4px; }
  .month-bar #btnAddMonth,
  .month-bar #btnAddManual { width: 100%; }

  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .summary-info { text-align: left; }

  .cat-filter { width: 100%; }
  .cat-filter .mini-select { flex: 1; }

  .manual-form { grid-template-columns: 1fr; }

  .rate-add { flex-direction: column; align-items: stretch; }
  .rate-add .mini-select,
  .rate-add .mini-input { width: 100%; }

  .modal { padding: 18px 16px; }
  .modal-mask { padding: 12px; align-items: flex-start; }
  .modal-image { padding: 12px; }

  .entry-table { font-size: 12px; min-width: 820px; }
  .entry-table th, .entry-table td { padding: 8px 7px; }

  .pagination-bar { justify-content: center; }
}

/* 超窄屏：表头更小、弹窗按钮全宽 */
@media (max-width: 420px) {
  .app-header h1 { font-size: 15.5px; }
  .modal-actions { gap: 8px; }
  .modal-actions .btn { width: 100%; }
  .entry-table { min-width: 760px; }
}
