/* 从众管理系统 - 全局样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background-color: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ===== 通用组件 ===== */

.card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 24px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
}

/* 按钮 */
.btn {
  height: 34px;
  padding: 0 16px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.btn-primary {
  background: #1890ff;
  color: #fff;
  border-color: #1890ff;
}

.btn-primary:hover {
  background: #40a9ff;
  border-color: #40a9ff;
  color: #fff;
}

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  background: #fafafa;
  border-bottom: 1px solid #e8e8e8;
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  color: #666;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.data-table .text-right {
  text-align: right;
}

.data-table .text-center {
  text-align: center;
}

.data-table .money {
  font-family: "Consolas", "Monaco", monospace;
}

.data-table .empty-row td {
  text-align: center;
  color: #999;
  padding: 40px 16px;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 6px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #333;
  font-weight: 500;
}

.form-group label .required {
  color: #ff4d4f;
  margin-right: 2px;
}

.form-group input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.form-group input:disabled {
  background: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

.form-group input.error {
  border-color: #ff4d4f;
}

.form-group .error-msg {
  color: #ff4d4f;
  font-size: 12px;
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 2000;
  animation: toastFadeIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.success {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #52c41a;
}

.toast.error {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: #ff4d4f;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden {
  display: none !important;
}

/* ===== 侧边栏布局 ===== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: #1e2a3a;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(24, 144, 255, 0.15);
  color: #fff;
  border-left-color: #1890ff;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* 右侧主内容区 */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: #f0f2f5;
}

/* ===== 首页仪表盘 ===== */

.dashboard-header {
  background: #fff;
  padding: 22px 40px 16px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.dashboard-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: 2px;
}

.dashboard-header .header-subtitle {
  font-size: 13px;
  color: #bbb;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ===== 时间维度切换按钮 ===== */

.period-toggle-bar {
  display: flex;
  gap: 0;
  padding: 16px 32px 0;
}

.period-btn {
  height: 34px;
  padding: 0 22px;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.period-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.period-btn:last-child {
  border-radius: 0 4px 4px 0;
}

.period-btn:not(:first-child) {
  margin-left: -1px;
}

.period-btn:hover {
  border-color: #1890ff;
  color: #1890ff;
  z-index: 1;
  position: relative;
}

.period-btn.active {
  background: #1890ff;
  color: #fff;
  border-color: #1890ff;
  z-index: 2;
  position: relative;
}

/* ===== 图表区布局 ===== */

.charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  padding: 20px 32px 32px;
}

.chart-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.chart-card-head {
  padding: 15px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
}

.chart-card-body {
  flex: 1;
  padding: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-card-body canvas {
  max-width: 100%;
  max-height: 100%;
}

.chart-empty {
  color: #bbb;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* ===== 首页底部统计表格（三列） ===== */

.stats-table-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 0 32px 32px;
}

.stat-table-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 紧凑型数据表格 */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table thead th {
  background: #fafbfc;
  border-bottom: 1px solid #e8e8e8;
  padding: 9px 14px;
  text-align: left;
  font-weight: 500;
  color: #999;
  position: sticky;
  top: 0;
  z-index: 1;
}

.stats-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid #f5f5f5;
  color: #444;
}

.stats-table tbody tr:hover {
  background: #fafbfc;
}

.stats-table .col-right { text-align: right; }
.stats-table .col-center { text-align: center; }
.stats-table .money { font-family: "Consolas", "Monaco", monospace; }

/* ===== 旧版统计表格（保留兼容） ===== */

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px 32px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stat-card-head {
  padding: 15px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
}

.stat-card-body {
  max-height: 420px;
  overflow-y: auto;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stat-table thead th {
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 10px 16px;
  text-align: left;
  font-weight: 500;
  color: #999;
  position: sticky;
  top: 0;
  z-index: 1;
}

.stat-table tbody td {
  padding: 9px 16px;
  border-bottom: 1px solid #f8f8f8;
  color: #444;
}

.stat-table tbody tr:hover {
  background: #fafbfc;
}

.stat-table .empty-row td {
  text-align: center;
  color: #bbb;
  padding: 36px 16px;
}

.stat-table .col-right { text-align: right; }
.stat-table .col-center { text-align: center; }
.stat-table .money { font-family: "Consolas", "Monaco", monospace; }

.quick-links {
  display: flex;
  gap: 20px;
  padding: 0 32px 32px;
}

.link-card {
  flex: 1;
  max-width: 360px;
  background: #fff;
  border-radius: 8px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.link-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(24, 144, 255, 0.12);
}

.link-card .link-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.link-card .link-icon.icon-products { background: #e6f4ff; }

.link-card .link-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

.link-card .link-desc {
  font-size: 13px;
  color: #aaa;
}

/* ===== 子页面 ===== */

.page-header-bar {
  background: #fff;
  padding: 0 40px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0f0f0;
}

.page-header-bar .brand {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 1px;
}

.page-header-bar .brand a {
  color: #1890ff;
  text-decoration: none;
}

.page-header-bar .brand a:hover {
  text-decoration: underline;
}

.page-header-bar .page-title {
  font-size: 15px;
  color: #666;
  font-weight: 400;
}

.page-body {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 40px;
}

.back-home {
  display: block;
  text-align: center;
  padding: 20px 0 36px;
  font-size: 13px;
  color: #999;
  text-decoration: none;
  transition: color 0.2s;
}

.back-home:hover {
  color: #1890ff;
}

/* ===== 子页面统一标题行 ===== */

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 16px;
}

.page-title-row h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

.page-title-row .back-link {
  font-size: 14px;
  color: #1890ff;
  text-decoration: none;
}

.page-title-row .back-link:hover {
  text-decoration: underline;
}

/* ===== 库存管理图标 ===== */

.link-card .link-icon.icon-products { background: #e6f4ff; }
.link-card .link-icon.icon-products::after { content: "📦"; font-size: 24px; }

.link-card .link-icon.icon-inventory { background: #fff7e6; }
.link-card .link-icon.icon-inventory::after { content: "📋"; font-size: 24px; }

/* ===== 删除按钮 ===== */

.btn-del {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: #ff4d4f;
  border-color: #ffccc7;
  background: #fff;
}

.btn-del:hover {
  color: #fff;
  background: #ff4d4f;
  border-color: #ff4d4f;
}

/* ===== select 下拉框 ===== */

.form-group select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.form-group select:focus {
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.form-group select.error {
  border-color: #ff4d4f;
}

/* ===== 搜索栏 ===== */

.search-card {
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-item label {
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}

.search-item input[type="text"],
.search-item input[type="date"] {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  width: 150px;
  transition: border-color 0.2s;
}

.search-item input[type="text"]:focus,
.search-item input[type="date"]:focus {
  border-color: #1890ff;
}

.search-item input[type="date"] {
  width: 140px;
}

.search-sep {
  color: #999;
  font-size: 13px;
}

.search-actions {
  gap: 8px;
}

/* ===== 分页 ===== */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid #f0f0f0;
}

.pagination-info {
  font-size: 14px;
  color: #666;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-controls select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.btn-page {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-page:disabled {
  color: #ccc;
  cursor: not-allowed;
  border-color: #d9d9d9;
}

.btn-page:disabled:hover {
  color: #ccc;
  border-color: #d9d9d9;
}

.page-num {
  font-size: 14px;
  color: #333;
}

/* ===== 弹窗内搜索 ===== */

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-with-btn input:focus {
  border-color: #1890ff;
}

.input-with-btn input.error {
  border-color: #ff4d4f;
}

.search-result-area {
  margin-top: 16px;
  border: 1px solid #f0f0f0;
  border-radius: 4px;
}

.result-title {
  font-size: 13px;
  color: #999;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.result-empty {
  padding: 24px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.product-result-list {
  max-height: 260px;
  overflow-y: auto;
}

.product-result-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f8f8f8;
  transition: background 0.15s;
  font-size: 14px;
}

.product-result-item:hover {
  background: #e6f7ff;
}

.product-result-item:last-child {
  border-bottom: none;
}

.pri-name {
  font-weight: 500;
  color: #333;
  flex: 1;
}

.pri-code {
  color: #999;
  font-size: 13px;
}

.pri-price,
.pri-point {
  color: #666;
  font-size: 13px;
  font-family: "Consolas", "Monaco", monospace;
}

/* ===== 选中产品信息 ===== */

.selected-product-info {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.spi-row {
  font-size: 14px;
  padding: 3px 0;
}

.spi-label {
  color: #666;
}

.spi-value {
  color: #333;
  font-weight: 500;
}

.spi-value.money {
  font-family: "Consolas", "Monaco", monospace;
}

/* ===== 登录页 ===== */

.login-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 50%, #1a252f 100%);
}

.login-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  width: 400px;
  max-width: 90vw;
  padding: 48px 40px 40px;
}

.login-brand {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #1e2a3a;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 14px;
  color: #999;
  margin-bottom: 32px;
  letter-spacing: 2px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-group label {
  font-size: 13px;
  color: #666;
}

.login-btn {
  width: 100%;
  height: 42px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 4px;
  margin-top: 8px;
}

/* ===== 侧边栏底部 ===== */

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  flex: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(255, 77, 79, 0.3);
  border-color: rgba(255, 77, 79, 0.5);
  color: #fff;
}

/* ===== 编辑/修改角色按钮 ===== */

.btn-edit {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: #1890ff;
  border-color: #91d5ff;
  background: #fff;
}

.btn-edit:hover {
  color: #fff;
  background: #1890ff;
  border-color: #1890ff;
}

/* ===== 表格网格线 ===== */
.data-table th,
.data-table td {
  border: 1px solid #e8e8e8;
}

.data-table thead th {
  border-bottom: 2px solid #e0e0e0;
}

/* ===== 复选框列 ===== */
.col-check {
  width: 44px;
  text-align: center !important;
}

.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
}

/* ===== 删除选中按钮 ===== */
.btn-danger {
  background: #ff4d4f;
  color: #fff;
  border-color: #ff4d4f;
}

.btn-danger:hover {
  background: #ff7875;
  border-color: #ff7875;
}

.btn-danger:disabled {
  background: #f5f5f5;
  color: #ccc;
  border-color: #d9d9d9;
  cursor: not-allowed;
}

.btn-danger:disabled:hover {
  color: #ccc;
  border-color: #d9d9d9;
}

/* ===== 输入框后缀 ===== */
.input-suffix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-suffix-wrap input {
  flex: 1;
  padding-right: 32px;
}

.input-suffix-wrap .input-suffix {
  position: absolute;
  right: 10px;
  color: #999;
  font-size: 14px;
  pointer-events: none;
  line-height: 36px;
}

.col-action {
  width: 70px;
}

.btn-edit-row {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #1890ff;
  border-radius: 3px;
  background: #fff;
  color: #1890ff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-edit-row:hover {
  background: #1890ff;
  color: #fff;
}

/* ===== 右键菜单 ===== */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
  z-index: 2000;
  min-width: 120px;
  padding: 4px 0;
  animation: ctxFadeIn 0.12s ease;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background 0.15s;
}

.context-menu-item:hover {
  background: #e6f7ff;
  color: #1890ff;
}

/* 点位权限隐藏：默认全部隐藏，JS 根据角色显隐 */
.th-point-col,
.point-field {
  display: none;
}
