/* ========================================================
   common.css — erp-api-gateway 公共样式
   所有功能页统一引入:
     <link rel="stylesheet" href="/static/common.css" />
   页面特有样式追加在自己的 <style> 中即可
   ======================================================== */

/* ---- 基础重置 ---- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0; padding: 0;
  background: #f5f6f8; color: #1d1d1f; min-height: 100vh;
}

/* ---- 顶部导航 ---- */
.top-nav {
  background: #1a5cc7; display: flex; gap: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.top-nav a {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px; color: rgba(255,255,255,0.75);
  font-size: 13px; text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s; flex-shrink: 0;
}
.top-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.top-nav a.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.top-nav .nav-right {
  margin-left: auto; opacity: 0.7;
  font-size: 12px; padding: 10px 16px;
  color: rgba(255,255,255,0.7); white-space: nowrap;
}

/* ---- 页面头部渐变 ---- */
.header {
  background: linear-gradient(135deg, #1f6feb 0%, #4a8af4 100%);
  color: #fff; padding: 20px 18px 24px;
}
.header h1 { font-size: 18px; margin: 0 0 4px; font-weight: 500; }
.header .sub { font-size: 12px; opacity: 0.85; }

/* 用户信息卡 */
.user-card {
  background: rgba(255,255,255,0.15); border-radius: 10px;
  padding: 12px 14px; margin-top: 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.3); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 15px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 14px; font-weight: 500; }
.user-info .role { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.user-info .dept { font-size: 11px; opacity: 0.75; }

/* ---- 容器/卡片 ---- */
.container { padding: 16px; max-width: 960px; margin: 0 auto; }

.card {
  background: #fff; border-radius: 12px; padding: 20px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); margin-bottom: 14px;
}
.card h2 {
  font-size: 15px; margin: 0 0 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .badge {
  margin-left: auto; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; background: #eef2ff; color: #4338ca; font-weight: 400;
}

/* ---- 搜索栏 ---- */
.search-row {
  display: flex; gap: 8px; margin-bottom: 12px;
  flex-wrap: wrap; align-items: center;
}
.search-row input {
  flex: 1; min-width: 180px; padding: 10px 12px;
  border: 0.5px solid #d2d2d7; border-radius: 8px;
  font-size: 14px; background: #fafafa;
}
.search-row input:focus { outline: none; border-color: #1f6feb; background: #fff; }

/* ---- 按钮 ---- */
.btn {
  padding: 10px 18px; background: #1f6feb; color: #fff;
  border: none; border-radius: 8px; font-size: 14px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #1859c5; }
.btn:disabled { background: #c0c0c5; cursor: not-allowed; }
.btn.secondary {
  background: #fff; color: #1d1d1f; border: 0.5px solid #d2d2d7;
}
.btn.secondary:hover { background: #f5f5f7; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { background: #b91c1c; }
.btn.danger:hover { background: #991b1b; }
.btn.success { background: #1d6f42; }
.btn.success:hover { background: #155d35; }

/* ---- 过滤行 ---- */
.filter-row {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center; margin-bottom: 12px;
}
.filter-row label {
  font-size: 13px; color: #6e6e73;
  display: flex; align-items: center; gap: 4px; cursor: pointer;
}
.filter-row input[type="checkbox"] { margin: 0; }

/* Toggle 按钮组 */
.toggle-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toggle-group label {
  font-size: 12px; padding: 3px 8px;
  border: 0.5px solid #d2d2d7; border-radius: 4px;
  cursor: pointer; user-select: none;
}
.toggle-group label.active {
  background: #e8f0fe; border-color: #1f6feb; color: #1f6feb;
}
.toggle-group input[type="checkbox"] { display: none; }

/* ---- Tab 切换 ---- */
.tabs {
  display: flex; gap: 0; margin-bottom: 12px;
  border-bottom: 1px solid #e5e5e7;
}
.tab {
  padding: 8px 16px; font-size: 14px; color: #6e6e73;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s; position: relative;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: #1f6feb; }
.tab.active { color: #1f6feb; border-bottom-color: #1f6feb; font-weight: 500; }
.tab-badge {
  font-size: 11px; background: #f0f0f2; color: #6e6e73;
  padding: 1px 6px; border-radius: 10px; font-weight: 400;
}
.tab.active .tab-badge { background: #e8f0fe; color: #1f6feb; }

/* ---- 结果区域 ---- */
.result { margin-top: 12px; }
.result-wrapper {
  margin-top: 12px; border: 0.5px solid #e5e5e7;
  border-radius: 8px; overflow-x: auto; background: #fafbfc;
}

/* 表格 */
.result-wrapper table, .result table {
  width: 100%; border-collapse: collapse; font-size: 12px; min-width: 600px;
}
.result-wrapper th, .result th {
  position: sticky; top: 0; background: #f0f0f2; color: #6e6e73;
  font-weight: 500; padding: 8px; text-align: left;
  border-bottom: 0.5px solid #e5e5e7;
  font-size: 11px; white-space: nowrap; user-select: none;
}
.result-wrapper th { cursor: pointer; }
.result-wrapper th:hover { background: #e5e7eb; }
.result-wrapper th .sort-arrow { margin-left: 3px; font-size: 10px; color: #9b9ba0; }
.result-wrapper th.sort-active { color: #1f6feb; }
.result-wrapper th.sort-active .sort-arrow { color: #1f6feb; }

.result-wrapper td, .result td {
  padding: 6px 8px; border-bottom: 0.5px solid #ececee; font-size: 12px;
}
.result-wrapper tr:last-child td, .result tr:last-child td { border-bottom: none; }
.result-wrapper tr:hover td, .result tr:hover td { background: #f5f5f7; }

.result-wrapper .price { font-family: 'Courier New', monospace; text-align: right; }
.result-wrapper .num { text-align: right; }
.result-wrapper .stock-ok { color: #1d6f42; font-weight: 500; }
.result-wrapper .stock-zero { color: #b91c1c; }
.result-wrapper .btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 4px;
}
.result-wrapper .btn-icon:hover { background: #e8f0fe; }

/* 空/加载/错误状态 */
.empty {
  padding: 24px; text-align: center; color: #9b9ba0; font-size: 13px;
}
.loading {
  padding: 16px; text-align: center; color: #6e6e73; font-size: 13px;
}
.error {
  padding: 14px 16px; color: #b91c1c;
  background: #fef2f2; border-radius: 6px; font-size: 13px;
}
.success-msg {
  padding: 14px 16px; color: #1d6f42;
  background: #f0fdf4; border-radius: 6px; font-size: 13px;
}

/* ---- 分页工具栏 ---- */
.pagination {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 8px 12px; border-top: 0.5px solid #e5e5e7;
  background: #fff; font-size: 12px; color: #6e6e73;
}
.pagination .total { white-space: nowrap; }
.pagination .summary { margin: 0 auto; white-space: nowrap; }
.pagination .pages { display: flex; gap: 4px; align-items: center; }
.pagination button {
  padding: 4px 10px; border: 0.5px solid #d2d2d7;
  border-radius: 4px; background: #fff; color: #1d1d1f;
  font-size: 12px; cursor: pointer;
}
.pagination button:hover:not(:disabled) { background: #f5f5f7; }
.pagination button:disabled { color: #c0c0c5; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: #6e6e73; }

/* ---- 水印 ---- */
.watermark-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 9999; overflow: hidden;
}
.watermark-overlay .wm-line {
  display: flex; white-space: nowrap;
  font-weight: 600; color: rgba(0,0,0,0.045);
  letter-spacing: 4px; user-select: none;
}
.watermark-overlay .wm-line span { margin-right: 30px; flex-shrink: 0; }
.wm-wrap {
  position: absolute; top: -10%; left: -5%;
  width: 110%; height: 120%;
  display: flex; flex-direction: column; justify-content: space-around;
  transform: rotate(-28deg); transform-origin: center center;
}
.wm-line-1 { font-size: 18px; line-height: 44px; }
.wm-line-2 { font-size: 16px; line-height: 36px; }

/* ---- 弹窗 ---- */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 10000;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px;
  max-width: 500px; width: 90%;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 16px 18px; border-bottom: 0.5px solid #e5e5e7;
}
.modal-header .title { font-size: 15px; font-weight: 500; }
.modal-header .sub { font-size: 12px; color: #6e6e73; margin-top: 4px; }
.modal-body { padding: 16px 18px; }
.modal-footer {
  padding: 12px 18px; border-top: 0.5px solid #e5e5e7;
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---- 功能入口卡片（首页） ---- */
.entry-grid { display: flex; flex-direction: column; gap: 10px; }
.entry-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 10px;
  background: #f8f9fc; border: 0.5px solid #e8e9ec;
  text-decoration: none; color: #1d1d1f; cursor: pointer;
  transition: background 0.2s;
}
.entry-card:hover { background: #eef1f7; }
.entry-card .entry-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.entry-card .entry-icon.blue { background: #e8f0fe; }
.entry-card .entry-icon.green { background: #d1f4d8; }
.entry-card .entry-icon.orange { background: #fed7aa; }
.entry-card .entry-info { flex: 1; }
.entry-card .entry-title { font-size: 14px; font-weight: 500; }
.entry-card .entry-desc { font-size: 11px; color: #6e6e73; margin-top: 2px; }
.entry-card .entry-arrow { color: #c0c0c5; font-size: 18px; }

/* ---- 移动端卡片 ---- */
.mobile-cards { display: none; }
.data-card {
  background: #fff; border-radius: 8px; padding: 12px 14px;
  margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.data-card .card-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.data-card .card-row:last-child { margin-bottom: 0; }
.data-card .date { font-size: 12px; color: #6e6e73; }
.data-card .handler { font-size: 12px; color: #6e6e73; }
.data-card .serial {
  font-size: 16px; font-weight: 600; color: #1f6feb;
  font-family: 'Courier New', monospace;
}
.data-card .bill-no { font-size: 12px; color: #6e6e73; }
.data-card .product-name { font-size: 13px; color: #1d1d1f; margin: 4px 0; }
.data-card .party { font-size: 12px; color: #6e6e73; }
.data-card .sn { font-size: 12px; color: #6e6e73; }

/* ---- 响应式 ---- */
@media (max-width: 767px) {
  .result-wrapper table, .result table { font-size: 11px; min-width: auto; }
  .result-wrapper th, .result-wrapper td,
  .result th, .result td { padding: 4px 6px; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .result table { display: none; }
  .mobile-cards { display: block; }
  .pagination { flex-wrap: wrap; gap: 8px; }
}
@media (min-width: 768px) {
  .result table { display: table; }
  .mobile-cards { display: none; }
}
