/* ============================================================
   钧远·粮报 统一样式 v2.0（合规整改版）
   覆盖全部页面公共 class + 基础元素；移动端响应式
   ============================================================ */
:root {
  --primary: #2e7d32;        /* 主色：粮仓绿 */
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --accent: #f9a825;         /* 强调：收获金 */
  --accent-dark: #f57f17;
  --danger: #c62828;
  --info: #1565c0;
  --success: #2e7d32;
  --text: #263238;
  --text-2: #546e7a;
  --text-3: #90a4ae;
  --bg: #f4f6f5;
  --card: #ffffff;
  --border: #e0e6e3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(38,50,56,.06), 0 4px 14px rgba(38,50,56,.05);
  --sidebar-w: 210px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { opacity: .85; }

/* ---------- 布局：侧栏 + 主区 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #1b5e20 0%, #14532d 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.12);
  color: #fff;
}
.sidebar-menu { padding: 10px 0; flex: 1; }
.sidebar-menu a {
  display: block;
  padding: 11px 20px;
  color: rgba(255,255,255,.82);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.sidebar-menu a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-menu a.active {
  background: rgba(255,255,255,.14);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- 页头 ---------- */
.page-header { margin-bottom: 22px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text-2); margin-top: 4px; font-size: 13px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafcfb;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-body { padding: 20px; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-group input[type=text],
.form-group input[type=number],
.form-group input[type=password],
.form-group input[type=tel],
.form-group input[type=date],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46,125,50,.12);
}
.form-group textarea { resize: vertical; min-height: 64px; }
.form-group .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.4;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b71c1c; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover:not(:disabled) { background: #0d47a1; }
.btn-secondary { background: #eceff1; color: var(--text); border-color: #d5dde0; }
.btn-secondary:hover:not(:disabled) { background: #dfe6e9; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ---------- 表格 ---------- */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: #fff;
}
.table th {
  text-align: left;
  padding: 11px 12px;
  background: #f2f6f3;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf1ef;
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fbf9; }
.table tbody tr:last-child td { border-bottom: none; }

/* 状态徽章 */
.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pending, .status-draft { background: #fff3e0; color: #e65100; }
.status-confirmed { background: #e3f2fd; color: #1565c0; }
.status-partial { background: #f3e5f5; color: #6a1b9a; }
.status-paid, .status-settled { background: #e8f5e9; color: #2e7d32; }
.status-voided { background: #eceff1; color: #78909c; }

/* ---------- 指标卡（首页/统计） ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.stat-number { font-size: 26px; font-weight: 700; color: var(--text); }
/* 页面内直接使用 .label/.value 的指标卡（如库存/客商页） */
.stat-card .label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--text); }

/* ---------- 报表标签页 ---------- */
.report-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: #eef2ef;
  padding: 5px;
  border-radius: 10px;
  margin-bottom: 20px;
  width: fit-content;
  max-width: 100%;
}
.report-tabs a, .report-tabs button {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.report-tabs a.active, .report-tabs button.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ---------- 登录/注册页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 45%, #f9a825 130%);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  overflow: hidden;
}
.login-left { padding: 28px 30px; }
.login-right {
  background: var(--primary-light);
  padding: 22px 30px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-2);
}
.login-form .form-group { margin-bottom: 16px; }
.login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46,125,50,.12); }

/* ---------- 价格海报 ---------- */
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.price-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 18px 22px; }
.price-header h2 { font-size: 20px; }
.price-header .price-company { font-size: 13px; opacity: .85; margin-top: 4px; }
.price-item { display: flex; justify-content: space-between; padding: 13px 22px; border-bottom: 1px dashed var(--border); align-items: center; }
.price-item:last-child { border-bottom: none; }
.price-item .value { font-weight: 700; color: var(--danger); font-size: 16px; }
.price-detail { padding: 16px 22px; color: var(--text-2); font-size: 13px; }

/* ---------- 小票打印 ---------- */
.ticket {
  width: 80mm;
  margin: 0 auto;
  background: #fff;
  padding: 8mm;
  font-size: 12px;
  color: #000;
}
.ticket table { width: 100%; font-size: 12px; border-collapse: collapse; }
.ticket table td { padding: 3px 0; border: none; }
@media print {
  body * { visibility: hidden; }
  .ticket, .ticket * { visibility: visible; }
  .ticket { position: absolute; left: 0; top: 0; }
}

/* ---------- 地磅 ---------- */
.scale-container { max-width: 560px; margin: 0 auto; }
.weight-display {
  font-size: 56px;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 18px;
  font-variant-numeric: tabular-nums;
}
.unitLabel, .unit, .deductUnitLabel { color: var(--text-2); font-size: 13px; }

/* ---------- 教程页 ---------- */
.guide-section {
  background: #fff;
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  border: 1px solid var(--border);
}
.guide-section h3 { color: var(--primary); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--primary-light); font-size: 16px; }
.guide-section ol, .guide-section ul { line-height: 2; color: var(--text); padding-left: 20px; }
.tip {
  background: #e3f2fd;
  padding: 12px 15px;
  border-radius: 8px;
  margin: 15px 0;
  color: #1565c0;
  font-size: 14px;
  border-left: 4px solid #1565c0;
}
.warn {
  background: #fff3e0;
  padding: 12px 15px;
  border-radius: 8px;
  margin: 15px 0;
  color: #e65100;
  font-size: 14px;
  border-left: 4px solid #e65100;
}

/* ---------- 支付弹窗 ---------- */
.pay-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}
.pay-modal.show { display: flex; }
.pay-modal-content {
  background: #fff;
  border-radius: 14px;
  max-width: 420px;
  width: 100%;
  padding: 28px;
  position: relative;
  box-shadow: 0 16px 50px rgba(0,0,0,.2);
}
.pay-qrcode { text-align: center; margin: 16px 0; }
.pay-qrcode img { width: 220px; height: 220px; }
.pay-amount { font-size: 30px; font-weight: 800; color: var(--danger); text-align: center; }
.pay-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 10px; }

/* ---------- 通用工具 ---------- */
.container { max-width: 1200px; margin: 0 auto; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-2); font-size: 13px; }
.total { font-weight: 700; }
.icon { vertical-align: -2px; }
label, .label { user-select: none; }
.status { user-select: none; }

/* ---------- Toast（patch.js 使用） ---------- */
#toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast-item {
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  max-width: 80vw;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .sidebar-logo { border-bottom: none; border-right: 1px solid rgba(255,255,255,.12); padding: 16px; white-space: nowrap; }
  .sidebar-menu { display: flex; padding: 0; }
  .sidebar-menu a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 14px 14px; }
  .sidebar-menu a.active { border-left: none; border-bottom-color: var(--accent); }
  .main-content { padding: 18px 14px 30px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .page-header h2 { font-size: 19px; }
  .weight-display { font-size: 44px; }
  .stat-number { font-size: 22px; }
}


/* ===== 手机端极简适配 ===== */
.menu-toggle { display: none; }
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -220px; transition: left .2s; z-index: 100; width: 210px; height: 100vh; overflow-y: auto; }
  .sidebar.open { left: 0; }
  .main-content { margin-left: 0 !important; padding: 12px; }
  .menu-toggle { display: flex !important; position: fixed; top: 10px; left: 10px; z-index: 99; background: #2e7d32; color: #fff; border: none; border-radius: 6px; width: 40px; height: 40px; font-size: 18px; align-items: center; justify-content: center; }
  .stat-grid, .dashboard-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  table { font-size: 12px; }
  input, select, textarea { font-size: 16px !important; }
  .card { padding: 12px !important; }
}

/* 备案信息页脚（ICP + 公安联网备案） */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 22px; padding: 18px 16px; font-size: 12px;
}
.site-footer a {
  display: inline-flex; align-items: center; gap: 6px;
  color: #9aa0a6; text-decoration: none; line-height: 1;
}
.site-footer a:hover { color: var(--accent); }
.site-footer img { width: 14px; height: 16px; display: block; }
/* 深色登录/注册页：固定底部、浅色文字 */
.site-footer.on-dark {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 10px 16px; background: rgba(0,0,0,.20); gap: 22px;
}
.site-footer.on-dark a { color: rgba(255,255,255,.88); }
.site-footer.on-dark a:hover { color: #fff; }