/* ===== 云上工作台 - 样式 ===== */
:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --fg: #1f2328;
  --fg-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --head-bg: #f8fafc;
  --row-hover: #f1f5f9;
  --sidebar-bg: #1f2937;
  --sidebar-fg: #cbd5e1;
  --sidebar-active: #2563eb;
  --topbar-bg: #ffffff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.5;
}

/* ===== 整体布局：顶栏 + 侧边栏 + 内容 ===== */
.app { display: flex; flex-direction: column; height: 100vh; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.top-right { display: flex; align-items: center; }

/* 公司切换 */
.company-switcher { display: flex; align-items: center; gap: 6px; margin-left: 24px; }
.company-label { font-size: 13px; color: var(--fg-muted); }
.company-select {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px;
  font-size: 14px; background: #fff; color: var(--fg); outline: none; font-weight: 600;
}
.company-select:disabled { background: var(--bg); color: var(--fg-muted); }

/* 用户下拉菜单 */
.user-menu { position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.user-menu:hover { background: var(--bg); }
.user-avatar { font-size: 20px; }
.user-name { font-size: 14px; }
.user-caret { font-size: 12px; color: var(--fg-muted); }
.dropdown {
  position: absolute; top: 42px; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 140px; display: none; z-index: 50;
}
.dropdown.show { display: block; }
.dropdown-item { padding: 10px 16px; font-size: 14px; cursor: pointer; }
.dropdown-item:hover { background: var(--bg); }

/* 主体：侧边栏 + 内容 */
.body { flex: 1; display: flex; overflow: hidden; }

/* 侧边栏 */
.sidebar {
  width: 220px; min-width: 220px; background: var(--sidebar-bg);
  padding: 12px 0; overflow-y: auto; flex-shrink: 0;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
.menu-group { margin-bottom: 4px; }
.menu-group-title {
  padding: 10px 20px 6px; font-size: 12px; color: #6b7280; font-weight: 600;
}
.menu-item {
  padding: 10px 20px 10px 24px; font-size: 14px; color: var(--sidebar-fg);
  cursor: pointer; border-left: 3px solid transparent; transition: all .12s;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active { background: var(--sidebar-active); color: #fff; border-left-color: #60a5fa; }

/* 内容区 */
.content { flex: 1; overflow: hidden; padding: 14px 18px; display: flex; flex-direction: column; min-height: 0; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }

/* 页面：整页不滚动，只有表格内部滚动 */
.page { display: none; }
.page.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.toolbar, .pager, .hint, .page-sub-title, .backup-box, .backup-result { flex-shrink: 0; }
/* 页面标题已按需求移除（菜单即为当前模块提示） */
.page-sub-title { font-size: 15px; font-weight: 700; margin: 20px 0 10px; color: var(--fg); }
.hint { font-size: 12px; color: var(--fg-muted); margin: -8px 0 12px; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filter {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px;
  background: #fff; color: var(--fg); outline: none;
}
.filter:focus { border-color: var(--accent); }
.total { color: var(--fg-muted); font-size: 13px; }
.legend { margin-left: auto; font-size: 12px; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.red { background: #fecaca; border: 1px solid var(--danger); }
.dot.yellow { background: #fef3c7; border: 1px solid var(--warn); }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--fg);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }

/* 表格 */
.table-wrap { flex: 1 1 0; min-height: 90px; overflow: auto; max-height: none; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.table-wrap::-webkit-scrollbar { height: 12px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f5f9; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; min-width: 100%; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--head-bg); position: sticky; top: 0; z-index: 1; font-weight: 600; color: var(--fg-muted); }
th.num { text-align: right; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover, th.sortable.active { color: var(--accent); }
.ip-table-shell { position: relative; flex: 1 1 0; min-height: 90px; display: flex; }
.ip-table-shell .table-wrap { width: 100%; padding-bottom: 36px; box-sizing: border-box; }
.ip-table-shell #ipTable { table-layout: fixed; }
.ip-total-bar { position: absolute; left: 1px; right: 1px; bottom: 1px; z-index: 3; display: grid; align-items: center; height: 35px; background: #f8fafc; border-top: 2px solid var(--border); border-radius: 0 0 8px 8px; box-shadow: 0 -4px 10px rgba(15,23,42,.06); font-size: 13px; font-weight: 700; overflow: hidden; }
.ip-total-bar > div { padding: 0 10px; overflow: hidden; white-space: nowrap; }
.ip-total-bar .num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.clickable { cursor: pointer; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.chaobao td { background: #fef2f2; }
tr.chayi td { background: #fffbeb; }
td.tag { font-weight: 600; }
.tag.weish{ color: var(--warn); } .tag.yishen{ color: var(--accent); }
.tag.yitui{ color: var(--ok); } .tag.zhuan{ color: var(--danger); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 10px; justify-content: center; }
.pager button { border: 1px solid var(--border); background: #fff; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .info { font-size: 13px; color: var(--fg-muted); }
.jump-input { width: 62px; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.jump-btn { border: 1px solid var(--border); background: #fff; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }

/* 统计卡片 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-card .label { font-size: 12px; color: var(--fg-muted); }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.stat-card.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat-card.clickable:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(37,99,235,.12); transform: translateY(-1px); }
.stat-section-title { font-size: 13px; font-weight: 700; color: var(--fg); margin: 2px 0 8px; }
.compact-cards { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; margin-bottom: 10px; }
.compact-cards .stat-card { padding: 10px 12px; min-height: 108px; }
.compact-cards .value { font-size: 18px; }
.compact-cards .label, .compact-cards .sub { font-size: 11px; }
#ipOverviewCards, #ipCards { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
#ipOverviewCards { margin-bottom: 10px; }
#ipOverviewCards .stat-card, #ipCards .stat-card { min-height: 116px; padding: 12px 16px; display: flex; flex-direction: column; }
#ipOverviewCards .value, #ipCards .value { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
#ipOverviewCards .sub, #ipCards .sub { line-height: 1.45; }
.package-result { margin: -6px 0 10px; font-size: 13px; line-height: 1.7; }
.package-result a { color: var(--accent); font-weight: 600; }
.package-result .warn { color: #c0392b; }
.package-result .muted { color: var(--fg-muted); }
.irs-total-cards { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.irs-total-cards .stat-card { padding: 10px 12px; min-height: 116px; }
.irs-total-cards .value { font-size: 18px; }
.irs-total-cards .label, .irs-total-cards .sub { font-size: 11px; }
.company-completion-card { min-height: 116px; }
.company-completion-card .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 发票齐整度 */
.fp-summary { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.fp-box { border-radius: 8px; padding: 12px 16px; font-size: 14px; border: 1px solid var(--border); }
.fp-box.ok { background: #f0fdf4; border-color: #86efac; }
.fp-box.warn { background: #fffbeb; border-color: #fcd34d; }
.fp-detail { font-size: 12px; color: var(--fg-muted); margin-top: 6px; line-height: 1.8; max-width: 700px; }

/* 备份页 */
.backup-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 24px; max-width: 600px; }
.backup-box p { margin-bottom: 12px; color: var(--fg-muted); }
.backup-box code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.backup-result { margin-top: 12px; font-size: 13px; color: var(--ok); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 10px; width: 640px; max-width: 92vw;
  max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal.modal-wide { width: min(1100px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--fg-muted); }
.modal-body { padding: 16px 18px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ip-breakdown-wrap { max-height: 62vh; }
.ip-breakdown-table { min-width: 760px; }
.ip-breakdown-summary td { background: #f8fafc; font-weight: 700; }
.perm-row { display: grid; grid-template-columns: minmax(140px, 1fr) 110px 110px; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.perm-row:last-child { border-bottom: none; }
.perm-row > span { font-weight: 600; }
.perm-row label { display: flex; align-items: center; gap: 5px; color: var(--fg); }
.modal-body .field { display: flex; flex-direction: column; gap: 3px; }
.modal-body .field.full { grid-column: 1 / -1; }
.modal-body label { font-size: 12px; color: var(--fg-muted); }
.modal-body input, .modal-body select {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; outline: none;
}
.modal-body input:focus { border-color: var(--accent); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.notice-textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-family: inherit; font-size: 13px; line-height: 1.6; }
.notice-textarea:last-child { flex: 1; }
.system-notice-mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.system-notice-dialog { width: min(640px, 100%); max-height: 80vh; overflow: auto; background: #fff; border-radius: 10px; padding: 22px 24px; box-shadow: 0 20px 50px rgba(15,23,42,.25); }
.system-notice-dialog h3 { margin: 0 0 12px; font-size: 20px; }
.system-notice-dialog p { margin: 0 0 12px; color: var(--fg-muted); line-height: 1.7; white-space: pre-wrap; }
.system-notice-dialog pre { margin: 0; padding: 12px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--border); white-space: pre-wrap; font-family: inherit; font-size: 13px; line-height: 1.7; }
.system-notice-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 登录遮罩 */
.login-mask {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 36px 40px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.12);
  width: 340px;
}
.login-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 20px; }
.login-input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 15px; margin-bottom: 12px; outline: none;
}
.login-input:focus { border-color: var(--accent); }
.login-btn { width: 100%; padding: 10px; font-size: 15px; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* 用户管理 */
.user-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.user-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.user-add { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { text-align: center; color: var(--fg-muted); padding: 40px; }


.btn.danger { color: #c0392b; border-color: #c0392b; }
.btn.danger:hover { background: #c0392b; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.storage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.storage-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fff; }
.storage-card .label { font-size: 12px; color: var(--fg-muted); }
.storage-card .value { margin-top: 5px; font-size: 17px; font-weight: 600; }
.storage-card .sub { margin-top: 3px; font-size: 11px; color: var(--fg-muted); }
.progress-track { height: 12px; border-radius: 6px; background: #e5e7eb; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s ease; }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--fg-muted); line-height: 1.6; }
.task-center-btn { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 7px 10px; cursor: pointer; margin-right: 10px; }
.task-center-btn .badge { margin-left: 4px; }
.task-item { border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; margin-bottom: 10px; background: #fff; }
.task-item-head { display: flex; align-items: center; gap: 8px; }
.task-item-head .task-name { font-weight: 600; flex: 1; word-break: break-all; }
.task-status { font-size: 12px; }
.task-status.running { color: #2563eb; }
.task-status.done { color: #16a34a; }
.task-status.failed { color: #dc2626; }
.task-status.cancelled { color: #d97706; }
.task-message { margin-top: 6px; font-size: 12px; color: var(--fg-muted); line-height: 1.6; }
.task-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* 数据更新日志 */
.uplog-day { margin-bottom: 8px; border: 1px solid #e3e6ee; border-radius: 8px; background: #fff; }
.uplog-day > summary { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.uplog-day > summary:hover { background: #f6f8fc; }
.uplog-day[open] > summary { border-bottom: 1px solid #e3e6ee; }

/* 日期筛选标签 */
.date-label { font-size: 12px; color: #6b7280; margin-left: 4px; white-space: nowrap; }
.date-sep { font-size: 12px; color: #9ca3af; margin: 0 2px; }

/* 无表格页面的滚动区域（数据更新等） */
#uplogList, #synclogList { flex: 1 1 0; min-height: 90px; overflow: auto; }
.backup-result { flex: 1 1 0; min-height: 90px; overflow: auto; }
.page-sub-title { margin: 10px 0 8px; }

/* ===== 右侧抽屉（待认领资料）===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.28); display: none; z-index: 60; }
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 580px; max-width: 94vw;
  background: #fff; box-shadow: -10px 0 30px rgba(15,23,42,.16);
  transform: translateX(102%); transition: transform .22s ease; z-index: 61;
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-hint { padding: 10px 16px; font-size: 12px; color: var(--fg-muted); background: #f8fafc; border-bottom: 1px solid var(--border); flex-shrink: 0; line-height: 1.6; }
.drawer-body { flex: 1; overflow: auto; padding: 12px 16px; }
.archive-drop-hint { margin: 8px 0; padding: 10px 12px; border: 1px dashed var(--border-strong, #cbd5e1); border-radius: 8px; color: var(--fg-muted); background: #f8fafc; text-align: center; font-size: 12px; transition: .15s ease; }
.archive-drop-hint.active { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.inbox-select-all { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--fg-muted); }
.inbox-select { margin-right: 8px; vertical-align: middle; }
.inbox-name-row { display: flex; align-items: flex-start; gap: 6px; }
.inbox-name-row .inbox-name { flex: 1; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.inbox-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.inbox-name { font-weight: 600; word-break: break-all; }
.inbox-meta { font-size: 12px; color: var(--fg-muted); margin: 3px 0 8px; }
.inbox-claim { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inbox-claim .filter { flex: 0 0 auto; }
.inbox-claim .inbox-contract { width: 170px; }

/* ===== 发票退税试点观察 ===== */
.pilot-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 10px; flex-shrink: 0; }
.pilot-card { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 10px 12px; }
.pilot-card-label { font-size: 12px; color: var(--fg-muted); margin-bottom: 4px; }
.pilot-card-value { font-size: 20px; font-weight: 700; color: var(--fg); }
.pilot-check-table { flex: 0 0 auto; max-height: 210px; margin-bottom: 6px; }
.pilot-columns { flex: 1 1 0; min-height: 140px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.pilot-block { min-height: 0; display: flex; flex-direction: column; }
.pilot-block .table-wrap { min-height: 100px; }
