/* WAWA 多账户数据中心 —— 图表与卡片样式移植自油猴脚本 0.8.2，新增登录页/账户条/弹窗 */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #F6F8FA;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1D2129;
}

/* ---------- 登录页 ---------- */
#wa-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wa-login-card {
  width: min(360px, 90vw);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .12);
  padding: 36px 32px;
  text-align: center;
}
.wa-login-card h1 { font-size: 22px; margin: 0 0 6px; }
.wa-login-card p { font-size: 12px; color: #9AA1AB; margin: 0 0 24px; }
.wa-login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  font-size: 14px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color .15s;
}
.wa-login-card input:focus { border-color: #0F9D58; }
.wa-login-err { color: #F53F3F; font-size: 12px; min-height: 18px; margin: 0 0 8px; }

/* ---------- 头部 ---------- */
.wa-header {
  background: #fff;
  border-bottom: 1px solid #EDF0F3;
  padding: 16px 24px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.wa-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.wa-title h1 { margin: 0; font-size: 20px; font-weight: 700; }
.wa-subtitle { font-size: 12px; color: #9AA1AB; margin-top: 2px; display: block; }
.wa-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.wa-btn {
  border: none;
  background: linear-gradient(135deg, #31C47A, #ABE425);
  color: #fff;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.wa-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(49, 196, 122, .35); }
.wa-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.wa-btn-ghost {
  border: 1px solid #E5E7EB;
  background: #fff;
  color: #374151;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.wa-btn-ghost:hover { background: #F3F4F6; border-color: #D1D5DB; }
.wa-btn-danger { color: #F53F3F; background: #FEF1F1; border-color: #FAD4D4; }
.wa-btn-danger:hover { background: #FDE3E3; border-color: #F6B7B7; }

/* ---------- 账户条 ---------- */
.wa-accounts-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 10px;
  flex-wrap: wrap;
}
.wa-acc-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.wa-acc-chip:hover { border-color: #0F9D58; }
.wa-acc-chip.active {
  background: #EAF7EF;
  border-color: #0F9D58;
  color: #0F9D58;
  font-weight: 600;
}
.wa-acc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.wa-acc-dot.ok { background: #31C47A; }
.wa-acc-dot.expired { background: #F53F3F; }
.wa-acc-dot.error { background: #FF8F1F; }
.wa-acc-dot.pending { background: #9AA1AB; }
.wa-acc-meta { font-size: 11px; color: #9AA1AB; font-weight: 400; }
.wa-acc-gear {
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; color: #6B7280; padding: 0 2px;
}
.wa-acc-gear:hover { color: #0F9D58; }

/* ---------- 标签页 & 时间尺度 ---------- */
.wa-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #EDF0F3;
  overflow-x: auto;
}
.wa-tab {
  padding: 12px 18px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #6B7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.wa-tab.active { color: #0F9D58; border-bottom-color: #0F9D58; font-weight: 600; }

.wa-range-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0 0;
}
.wa-range-label { font-size: 12px; color: #9AA1AB; white-space: nowrap; }
.wa-range-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.wa-range-btn {
  padding: 5px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: #fff;
  color: #6B7280;
  font-size: 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.wa-range-btn:hover { border-color: #0F9D58; color: #0F9D58; }
.wa-range-btn.active {
  background: #EAF7EF;
  border-color: #0F9D58;
  color: #0F9D58;
  font-weight: 600;
}

/* ---------- 主体 ---------- */
.wa-body { padding: 20px 24px 40px; max-width: 1280px; margin: 0 auto; }

.wa-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.wa-stat-card {
  background: #fff;
  border: 1px solid #EDF0F3;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.wa-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
  border-color: #D7F0E3;
}
.wa-stat-label { font-size: 12px; color: #9AA1AB; margin-bottom: 4px; }
.wa-stat-value { font-size: 20px; font-weight: 700; color: #111827; line-height: 1.2; }
.wa-stat-warn .wa-stat-value { color: #FF8F1F; }

.wa-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.wa-span-2 { grid-column: span 2; }
.wa-span-all { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .wa-dashboard-grid { grid-template-columns: 1fr; }
  .wa-span-2 { grid-column: span 1; }
}

.wa-card {
  background: #fff;
  border: 1px solid #EDF0F3;
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03);
  min-width: 0;
}
.wa-card-title { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 12px; }
.wa-chart-box { overflow-x: auto; position: relative; }

.wa-chart-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(17, 24, 39, .92);
  color: #fff;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  transform: translateY(-100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}

.wa-chart-legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 8px 2px 2px;
}
.wa-legend-item-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #4B5563;
}

.wa-donut-box { display: flex; align-items: center; justify-content: center; min-height: 180px; }
.wa-donut-wrap {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; justify-content: center; width: 100%;
}
.wa-legend {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 110px; max-width: 200px;
}
.wa-legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #4B5563; line-height: 1.2;
}
.wa-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.wa-legend-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-legend-value { font-variant-numeric: tabular-nums; color: #111827; font-weight: 600; }

.wa-compare-box {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 180px; justify-content: center;
}
.wa-compare-block {
  padding: 12px 14px;
  border-radius: 12px;
  background: #F8FAFB;
  border: 1px solid #F1F3F5;
}
.wa-compare-label { font-size: 12px; color: #9AA1AB; margin-bottom: 4px; }
.wa-compare-value { font-size: 20px; font-weight: 700; color: #111827; line-height: 1.2; }
.wa-compare-diff { font-size: 12px; margin-top: 4px; font-weight: 600; }
.wa-compare-na { color: #9AA1AB; font-weight: 400; }

/* 账户对比卡 */
.wa-acc-compare-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #F8FAFB;
  border: 1px solid #F1F3F5;
}
.wa-acc-compare-row + .wa-acc-compare-row { margin-top: 8px; }
.wa-acc-compare-main { min-width: 0; }
.wa-acc-compare-name { font-size: 13px; font-weight: 600; color: #111827; }
.wa-acc-compare-meta { font-size: 11px; color: #9AA1AB; margin-top: 2px; }
.wa-acc-compare-nums { display: flex; gap: 16px; align-items: baseline; white-space: nowrap; }
.wa-acc-compare-num b { font-size: 15px; font-weight: 700; }
.wa-acc-compare-num span { font-size: 11px; color: #9AA1AB; display: block; }

/* 今日收益列表 */
.wa-list-box { display: flex; flex-direction: column; gap: 8px; }
.wa-earning-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px;
  border-radius: 10px;
  background: #F8FAFB;
  border: 1px solid #F1F3F5;
}
.wa-earning-main { min-width: 0; }
.wa-earning-title {
  font-size: 13px; font-weight: 600; color: #111827;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wa-earning-title .wa-acc-tag {
  font-size: 11px; font-weight: 500; color: #4E8CF5;
  background: #EEF4FE; border-radius: 6px; padding: 1px 6px; margin-right: 6px;
}
.wa-earning-meta { font-size: 11px; color: #9AA1AB; margin-top: 2px; }
.wa-earning-amount { font-size: 15px; font-weight: 700; color: #0F9D58; white-space: nowrap; }

/* ---------- 表格 ---------- */
.wa-table-box {
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* iOS 触控惯性滚动 */
}
.wa-table-box { max-height: 420px; }
.wa-monthly-box { max-height: 260px; }
.wa-table-box.wa-allbooks { max-height: none; }
.wa-table-compact { min-width: 0 !important; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1150px; /* 列多，保证手机上横向滑动而不是挤压 */
}

.wa-scroll-hint {
  display: none;
  font-size: 11px;
  color: #9AA1AB;
  margin: 2px 0 6px;
}
@media (max-width: 700px) {
  .wa-scroll-hint { display: block; }
  .wa-body { padding: 12px 10px 30px; }
  .wa-header { padding: 12px 12px 0; }
  .wa-table-count { margin-left: 0; width: 100%; }
}

/* 表格上方的镜像横向滚动条（JS 同步 scrollLeft；不可滚动时自动隐藏） */
.wa-scroll-proxy {
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  margin: 0 0 4px;
}
.wa-scroll-proxy > div { height: 1px; }
.wa-scroll-proxy::-webkit-scrollbar { height: 10px; }
.wa-scroll-proxy::-webkit-scrollbar-track { background: #F1F3F5; border-radius: 5px; }
.wa-scroll-proxy::-webkit-scrollbar-thumb { background: #C9CDD4; border-radius: 5px; }
.wa-scroll-proxy::-webkit-scrollbar-thumb:hover { background: #A9AEB8; }

/* 桌面端一屏放下全部列：取消最小宽度、收紧留白（手机端仍保留横向滑动） */
@media (min-width: 1024px) {
  .wa-table-box.wa-allbooks table { min-width: 0 !important; }
  .wa-table-box.wa-allbooks th,
  .wa-table-box.wa-allbooks td { padding: 8px 8px; }
  .wa-table-box.wa-allbooks .wa-book-title { max-width: 200px; }
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #EEF0F3;
  white-space: nowrap;
}
th {
  background: #F8FAFB;
  color: #6B7280;
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  top: 0;
}
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #F8FAFB; }
.wa-book-title {
  font-weight: 600; color: #111827;
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
}
.wa-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #EAF7EF;
  color: #0F9D58;
  font-size: 12px;
}
.wa-badge-stale {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: #F3F4F6;
  color: #9AA1AB;
  font-size: 11px;
}
.wa-badge-expired {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #FEF1F1;
  color: #F53F3F;
  font-size: 12px;
}
.wa-row-stale td { color: #9AA1AB; }
.wa-money { color: #0F9D58; font-weight: 600; }
.wa-up { color: #0F9D58; }
.wa-down { color: #F53F3F; }

.wa-btn-link {
  border: none;
  background: #F3F4F6;
  color: #374151;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.wa-btn-link:hover { background: #E5E7EB; }
.wa-btn-link.wa-btn-danger-link { color: #F53F3F; background: #FEF1F1; margin-left: 6px; }
.wa-btn-link.wa-btn-danger-link:hover { background: #FDE3E3; color: #D92D20; }

/* ---------- 书籍总览表：排序 / 筛选 / 搜索 / 序号 ---------- */
.wa-table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.wa-filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.wa-search-input {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  font-size: 12px;
  outline: none;
  width: 180px;
  transition: border-color .15s;
}
.wa-search-input:focus { border-color: #0F9D58; }
.wa-table-count { font-size: 12px; color: #9AA1AB; margin-left: auto; white-space: nowrap; }
.wa-cols-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 8px 12px;
  margin: 6px 0;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: #F8FAFB;
  font-size: 12px;
}
.wa-col-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #374151;
  user-select: none;
}
.wa-col-check input { accent-color: #0F9D58; }
.wa-th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.wa-th-sort:hover { color: #0F9D58; }
.wa-row-num { color: #9AA1AB; font-size: 12px; font-variant-numeric: tabular-nums; width: 40px; }
.wa-book-link {
  border: none;
  background: transparent;
  color: #1D2129;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-align: left;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
}
.wa-book-link:hover { color: #0F9D58; text-decoration: underline; }

.wa-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.wa-empty {
  padding: 40px 20px;
  text-align: center;
  color: #9AA1AB;
  font-size: 13px;
}

/* ---------- 弹窗 ---------- */
#wa-modal-root { position: fixed; inset: 0; z-index: 999; display: none; }
#wa-modal-root.open { display: flex; align-items: center; justify-content: center; }
.wa-mask { position: absolute; inset: 0; background: rgba(17, 24, 39, .5); backdrop-filter: blur(4px); }
.wa-modal {
  position: relative;
  width: min(520px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
  padding: 22px 24px;
}
.wa-modal.wa-modal-wide { width: min(720px, 94vw); }
.wa-modal h3 { margin: 0 0 14px; font-size: 17px; }
.wa-modal .wa-close-x {
  position: absolute; top: 14px; right: 16px;
  border: none; background: #F3F4F6; color: #6B7280;
  width: 30px; height: 30px; border-radius: 8px;
  font-size: 16px; cursor: pointer;
}
.wa-form-row { margin-bottom: 14px; }
.wa-form-row label { display: block; font-size: 12px; color: #6B7280; margin-bottom: 6px; }
.wa-form-row input, .wa-form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #E5E7EB;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.wa-form-row input:focus, .wa-form-row textarea:focus { border-color: #0F9D58; }
.wa-form-row textarea { min-height: 110px; resize: vertical; word-break: break-all; }
.wa-form-tip { font-size: 11px; color: #9AA1AB; margin-top: 6px; line-height: 1.6; }
.wa-form-tip code {
  background: #F3F4F6; padding: 1px 5px; border-radius: 5px;
  font-size: 11px;
}
.wa-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 添加账户方式切换 */
.wa-add-tabs {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.wa-add-tab {
  flex: 1;
  padding: 9px 0;
  border: 1px solid #E5E7EB;
  background: #fff;
  border-radius: 10px;
  font-size: 13px;
  color: #6B7280;
  cursor: pointer;
  transition: all .15s;
}
.wa-add-tab.active {
  background: #EAF7EF;
  border-color: #0F9D58;
  color: #0F9D58;
  font-weight: 600;
}
.wa-add-tab:disabled { opacity: .5; cursor: not-allowed; }

/* 扫码区 */
.wa-qr-box {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0 4px;
  min-height: 220px;
  justify-content: center;
}
.wa-qr-box img { width: 190px; height: 190px; border-radius: 12px; border: 1px solid #EDF0F3; }
.wa-qr-status { font-size: 13px; color: #6B7280; margin-top: 12px; }
.wa-qr-status.expired { color: #F53F3F; }

/* toast */
#wa-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  transition: opacity .3s;
  pointer-events: none;
  max-width: 80vw;
  background: #1D2129;
}
#wa-toast.success { background: #00B361; }
#wa-toast.warn { background: #FF8F1F; }
#wa-toast.error { background: #F53F3F; }
