/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f0f2f5; color: #303133; font-size: 14px;
}
[v-cloak] { display: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 启动加载 ============ */
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1d3557 0%, #2b5876 100%); z-index: 9999;
}
.loading-box { text-align: center; color: #fff; }
.loading-logo { font-size: 56px; animation: float 2s ease-in-out infinite; }
.loading-title { font-size: 22px; letter-spacing: 4px; margin: 14px 0 26px; font-weight: 300; }
.loading-spinner { display: flex; justify-content: center; gap: 8px; }
.loading-spinner span { width: 10px; height: 10px; border-radius: 50%; background: #67c23a; animation: bounce 1.2s infinite ease-in-out; }
.loading-spinner span:nth-child(2) { animation-delay: .18s; background: #409eff; }
.loading-spinner span:nth-child(3) { animation-delay: .36s; background: #e6a23c; }
.loading-tip { margin-top: 22px; font-size: 13px; opacity: .75; }
@keyframes bounce { 0%,80%,100%{transform:scale(.5);opacity:.5} 40%{transform:scale(1.2);opacity:1} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1d3557 0%, #2b5876 55%, #4e7a93 100%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ''; position: absolute; border-radius: 50%; opacity: .12; background: #fff;
}
.login-wrap::before { width: 480px; height: 480px; right: -140px; top: -140px; }
.login-wrap::after { width: 360px; height: 360px; left: -100px; bottom: -100px; }
.login-card {
  width: 420px; max-width: 100%; background: #fff; border-radius: 16px; padding: 40px 40px 28px;
  box-shadow: 0 18px 60px rgba(0,0,0,.28); position: relative; z-index: 2;
  animation: loginIn .45s ease both;
}
@keyframes loginIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.login-logo { text-align: center; font-size: 46px; line-height: 1; animation: float 4s ease-in-out infinite; }
.login-title { text-align: center; font-size: 23px; font-weight: 700; margin: 12px 0 4px; color: #1d3557; letter-spacing: 1px; }
.login-sub { text-align: center; color: #909399; font-size: 13px; margin-bottom: 22px; letter-spacing: .5px; }
.login-error { margin-bottom: 14px; border-radius: 8px; }
.login-card .el-form-item { margin-bottom: 16px; }
.login-card .el-input--large { height: 44px; }
.login-card .el-input--large .el-input__wrapper { border-radius: 10px; }
.login-links {
  display: flex; align-items: center; justify-content: space-between;
  margin: -4px 2px 14px; font-size: 13px;
}
.login-tip {
  margin-top: 18px; background: #f4f8ff; border: 1px dashed #a0cfff; border-radius: 10px;
  padding: 10px 14px; font-size: 12px; color: #5a7a9a; line-height: 1.9;
}
.login-btn { width: 100%; height: 46px; font-size: 16px; letter-spacing: 6px; border-radius: 10px; }
.login-btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(64,158,255,.35); transition: all .2s; }
/* 找回密码步骤 */
.fgt-steps { display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 8px; }
.fgt-step { position: relative; padding-left: 34px; font-size: 14px; color: #4a5568; line-height: 1.7; }
.fgt-num {
  position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%;
  background: #ecf5ff; color: #409eff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

/* ============ 主布局 ============ */
.layout { height: 100%; }
.sidebar {
  background: #1d2b3a; transition: width .25s; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.sidebar .logo {
  height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  color: #fff; white-space: nowrap; overflow: hidden; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar .logo .icon { font-size: 26px; }
.sidebar .logo .txt { font-size: 17px; font-weight: 600; letter-spacing: 1px; }
.sidebar .logo .txt small { display: block; font-size: 10px; font-weight: 400; opacity: .55; letter-spacing: 2px; }
.sidebar .el-menu { border-right: none; flex: 1; }
.sidebar-collapse-btn { color: #fff; }
.topbar {
  background: #fff; height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; box-shadow: 0 1px 6px rgba(0,21,41,.08); position: relative; z-index: 10;
}
.topbar .page-title { font-size: 17px; font-weight: 600; color: #1d3557; margin-left: 12px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px; border-radius: 6px; }
.topbar-user:hover { background: #f5f7fa; }
.topbar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #409eff; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.main-body { background: #f0f2f5; padding: 16px; overflow-y: auto; }
.panel-card { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 4px rgba(0,21,41,.05); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.pager { margin-top: 14px; display: flex; justify-content: flex-end; }
.page-section { margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: #1d3557; display:flex; align-items:center; gap:8px; }
.section-title::before { content:''; width:4px; height:15px; background:#409eff; border-radius:2px; }

/* Element 菜单深色覆盖 */
.sidebar .el-menu { background: #1d2b3a; }
.sidebar .el-menu-item, .sidebar .el-sub-menu__title { color: #b7c4d3; height: 46px; line-height: 46px; }
.sidebar .el-menu-item:hover, .sidebar .el-sub-menu__title:hover { background: #26394d !important; color: #fff; }
.sidebar .el-menu-item.is-active { background: #2b6cb0 !important; color: #fff; }
.sidebar .el-sub-menu .el-menu-item { background: #16222e !important; min-width: 0; }
.sidebar .el-sub-menu .el-menu-item.is-active { background: #2b6cb0 !important; }
.sidebar .el-menu-item .el-icon, .sidebar .el-sub-menu__title .el-icon { margin-right: 8px; font-size: 17px; }
.sidebar .el-menu--collapse .el-menu-item .el-icon { margin-right: 0; }
.sidebar .el-menu--collapse { width: 64px; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border-radius: 10px; padding: 18px 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 1px 4px rgba(0,21,41,.06); transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,21,41,.12); }
.stat-card .ico { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; flex-shrink: 0; }
.stat-card .val { font-size: 24px; font-weight: 700; color: #1d2b3a; line-height: 1.2; }
.stat-card .lbl { color: #909399; font-size: 13px; margin-top: 4px; }
.ico.blue { background: linear-gradient(135deg,#409eff,#5dade2); }
.ico.green { background: linear-gradient(135deg,#67c23a,#85ce61); }
.ico.orange { background: linear-gradient(135deg,#e6a23c,#f0b870); }
.ico.red { background: linear-gradient(135deg,#f56c6c,#f89898); }
.ico.cyan { background: linear-gradient(135deg,#13c2c2,#5cdbd3); }
.ico.purple { background: linear-gradient(135deg,#722ed1,#9254de); }
.chart-row { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-bottom: 16px; }
.chart-box { background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,21,41,.05); }
.chart-box .chart-title { font-weight: 600; margin-bottom: 8px; color: #1d3557; }
.chart-canvas { width: 100%; height: 300px; }

/* ============ 商品图片占位 ============ */
.prod-thumb {
  width: 36px; height: 36px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600; vertical-align: middle;
}
.prod-cell { display: flex; align-items: center; gap: 9px; }
.prod-cell .meta { line-height: 1.35; }
.prod-cell .meta .name { font-weight: 500; }
.prod-cell .meta .sub { color: #909399; font-size: 12px; }

/* ============ 单据 ============ */
.order-head { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px 18px; background: #f8fafc; padding: 16px; border-radius: 8px; margin-bottom: 14px; }
.order-items-tip { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.order-total { text-align: right; font-size: 15px; padding: 10px 4px; }
.order-total b { color: #f56c6c; font-size: 22px; margin-left: 8px; }
.amount-cell { color: #f56c6c; font-weight: 600; }
.status-col .el-tag { min-width: 64px; justify-content: center; }

/* 单据详情打印 */
.print-order { padding: 30px 40px; color: #000; }
.print-order h1 { text-align: center; font-size: 22px; margin-bottom: 6px; }
.print-order .p-no { text-align: center; color: #444; margin-bottom: 18px; font-size: 13px; }
.print-order .p-info { display: flex; flex-wrap: wrap; gap: 6px 40px; font-size: 13px; margin-bottom: 14px; }
.print-order table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-order th, .print-order td { border: 1px solid #333; padding: 7px 8px; text-align: center; }
.print-order th { background: #eee; }
.print-order .p-foot { margin-top: 18px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 40px; }
.print-order .p-sign { margin-top: 40px; display: flex; justify-content: space-around; font-size: 13px; }

/* 条码标签 */
.barcode-sheet { padding: 10px; }
.barcode-label { display: inline-block; width: 230px; padding: 10px 12px; border: 1px dashed #bbb; margin: 6px; text-align: center; vertical-align: top; }
.barcode-label .b-name { font-size: 12px; height: 32px; overflow: hidden; line-height: 16px; }
.barcode-label .b-spec { font-size: 11px; color: #666; }
.barcode-label .b-price { font-size: 12px; margin-top: 2px; }
.barcode-label svg { max-width: 100%; }

/* ============ 工具类 ============ */
.text-danger { color: #f56c6c; }
.text-warning { color: #e6a23c; }
.text-success { color: #67c23a; }
.text-info { color: #909399; }
.text-bold { font-weight: 600; }
.text-right { text-align: right; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.flex { display: flex; align-items: center; }
.flex-gap { gap: 10px; }
.dialog-footer { text-align: right; }
.el-table .cell .el-button + .el-button { margin-left: 4px; }
.kv-line { color:#606266; font-size:13px; line-height:2; }
.kv-line b { color:#303133; }
.fin-mini-card { border-radius: 8px; padding: 14px 18px; color:#fff; }
.fin-mini-card .v { font-size: 22px; font-weight: 700; }
.fin-mini-card .l { font-size: 13px; opacity: .9; margin-top: 2px; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .no-print { display: none !important; }
}
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .chart-row { grid-template-columns: 1fr; }
}

/* ============================================================
   移动端适配（≤768px 手机 / 小平板竖屏）
   ============================================================ */
.mobile-menu-btn { display: none; color: #1d3557; }

@media (max-width: 768px) {
  /* ---- 通用 ---- */
  body { font-size: 14px; -webkit-text-size-adjust: 100%; }
  .hide-mobile { display: none !important; }
  .mobile-menu-btn { display: inline-flex; }

  /* ---- 侧边栏抽屉化 ---- */
  .layout { flex-direction: row; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1001;
    width: 232px !important; max-width: 82vw;
    transform: translateX(-101%);
    transition: transform .25s ease;
    padding-top: env(safe-area-inset-top);
    box-shadow: none;
  }
  .sidebar.drawer-open { transform: translateX(0); box-shadow: 2px 0 18px rgba(0,0,0,.35); }
  .sidebar .el-menu { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .sidebar-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .sidebar-mask.show { opacity: 1; pointer-events: auto; }

  /* ---- 顶栏 ---- */
  .topbar {
    height: 52px !important; padding: 0;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .topbar .page-title { font-size: 16px; margin-left: 6px; }
  .topbar-user { padding: 4px 6px; gap: 0; }

  /* ---- 主内容 ---- */
  .main-body {
    padding: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .panel-card { padding: 12px; border-radius: 8px; }

  /* ---- 统计卡片：内联 4 列样式强制 2 列 ---- */
  .stat-grid { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; margin-bottom: 10px; }
  .stat-card { padding: 12px; gap: 10px; border-radius: 8px; }
  .stat-card .ico { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; }
  .stat-card .val { font-size: 17px; word-break: break-all; }
  .stat-card .lbl { font-size: 11px; margin-top: 3px; line-height: 1.35; }

  /* ---- 图表 ---- */
  .chart-row { grid-template-columns: 1fr !important; gap: 10px; margin-bottom: 10px; }
  .chart-box { padding: 10px 12px; }
  .chart-canvas { height: 220px !important; }

  /* ---- 工具栏：输入/选择/日期纵向全宽（含内联宽度覆盖），按钮换行 ---- */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 12px; }
  .toolbar > .el-input,
  .toolbar > .el-select,
  .toolbar > .el-date-editor,
  .toolbar > .el-input-number,
  .toolbar > div { width: 100% !important; }
  .toolbar .spacer { display: none; }
  .toolbar .el-button { min-height: 36px; }
  .toolbar .el-button + .el-button { margin-left: 0; }
  .toolbar .el-range-editor { width: 100% !important; }
  .toolbar .el-radio-group { display: flex; }
  .toolbar .el-tag { max-width: 100%; white-space: normal; height: auto; min-height: 34px; line-height: 1.5; padding: 6px 10px; }

  /* ---- 单据表单 ---- */
  .order-head { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .order-items-tip { flex-direction: column; align-items: flex-start; gap: 8px; }
  .order-total { font-size: 14px; text-align: left; }
  .order-total b { font-size: 18px; }

  /* ---- 分页 ---- */
  .pager { justify-content: center; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pager .el-pagination { flex-wrap: nowrap; }
  .el-pagination .btn-prev, .el-pagination .btn-next, .el-pager li { min-width: 32px; height: 32px; line-height: 32px; }

  /* ---- 弹窗近全屏 ---- */
  .el-overlay .el-dialog {
    width: 96vw !important; margin: 2vh auto !important; max-height: 96vh;
  }
  .el-dialog { --el-dialog-padding-primary: 12px; }
  .el-dialog__header { padding: 14px 16px 10px; }
  .el-dialog__title { font-size: 16px; }
  .el-dialog__body { padding: 8px 16px 16px; max-height: calc(96vh - 108px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .el-dialog__footer { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .el-message-box { width: 90vw !important; max-width: 90vw; }
  .el-message { min-width: auto !important; max-width: 88vw; }

  /* ---- 表单：label 顶置，输入 16px 防 iOS 聚焦放大 ---- */
  .el-row { margin-left: 0 !important; margin-right: 0 !important; }
  .el-col { max-width: 100% !important; flex: 0 0 100% !important; padding-left: 0 !important; padding-right: 0 !important; }
  .el-form-item { margin-bottom: 14px; }
  .el-form-item__label {
    float: none !important; display: block !important; width: auto !important;
    text-align: left !important; line-height: 1.6 !important; padding-bottom: 2px;
  }
  .el-form-item__content { margin-left: 0 !important; flex-wrap: wrap; }
  .el-input__inner, .el-textarea__inner { font-size: 16px; height: 40px; }
  .el-textarea__inner { height: auto; }
  .el-range-input { font-size: 16px; }
  .el-input-number .el-input__inner { text-align: center; }
  .el-select .el-input__wrapper, .el-input__wrapper { min-height: 40px; }

  /* ---- 描述列表：label/value 堆叠 ---- */
  .el-descriptions__table, .el-descriptions__table tbody, .el-descriptions__table tr { display: block; }
  .el-descriptions__cell { display: block; width: 100% !important; max-width: 100% !important; }

  /* ---- 标签页横向滚动 ---- */
  .el-tabs__nav-wrap { overflow-x: auto; overflow-y: hidden; }
  .el-tabs__nav { white-space: nowrap; }

  /* ---- 表格紧凑化（仍可左右滑动查看全部列） ---- */
  .el-table { font-size: 13px; }
  .el-table .el-button { min-height: 28px; }
  /* 窄屏下列宽被压缩：文本单元格自动换行完整显示，操作按钮不折行 */
  .el-table .cell { white-space: normal !important; word-break: break-word; line-height: 1.4; }
  .el-table .cell .el-button,
  .el-table .cell .el-button span { white-space: nowrap; }
  .el-table .cell .el-button { flex-shrink: 0; }
  /* 固定列改普通列随表格横滑，避免宽操作列浮层遮挡首列内容（#app 提特异性，压过 EP 自带 !important） */
  #app .el-table tr .el-table-fixed-column--right,
  #app .el-table tr .el-table-fixed-column--left {
    position: static !important;
    box-shadow: none !important;
    z-index: auto !important;
  }
  #app .el-table .el-table-fixed-column--right::before,
  #app .el-table .el-table-fixed-column--left::before,
  #app .el-table .el-table-fixed-column--right::after,
  #app .el-table .el-table-fixed-column--left::after { display: none !important; }
  /* 单据弹窗扫码行：输入框弹性收缩，“选择商品”按钮不被裁切 */
  .order-items-tip .flex.flex-gap { flex-wrap: nowrap; }
  .order-items-tip .flex.flex-gap > .el-input { width: auto !important; flex: 1 1 0%; min-width: 0; }
  .order-items-tip .flex.flex-gap > .el-button { flex-shrink: 0; margin-left: 8px; }

  /* ---- 登录页 ---- */
  .login-wrap { padding: 12px; }
  .login-card { width: 94vw; max-width: 400px; padding: 28px 20px 20px; border-radius: 14px; }
  .login-logo { font-size: 40px; }
  .login-title { font-size: 19px; }
  .login-btn { height: 44px; letter-spacing: 4px; }
  .el-dialog.login-dialog { width: 92vw !important; }

  /* ---- 设置/其他 ---- */
  .kv-line { line-height: 1.8; }
  .fin-mini-card { padding: 12px; }
  .fin-mini-card .v { font-size: 18px; }
}

@media (max-width: 380px) {
  .stat-card { padding: 10px 8px; gap: 8px; }
  .stat-card .ico { width: 36px; height: 36px; font-size: 18px; }
  .stat-card .val { font-size: 15px; }
  .stat-card .lbl { font-size: 10px; }
  .main-body, .panel-card { padding-left: 8px; padding-right: 8px; }
}

/* 食安追溯 */
.trace-node { height: 100%; }
.trace-step { font-size: 15px; font-weight: 600; color: #1d2b3a; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid #409eff; }
.trace-item { padding: 8px 0; border-bottom: 1px dashed #eee; }
.trace-item:last-child { border-bottom: none; }
.trace-sub { font-size: 12px; color: #606266; margin-left: 12px; margin-top: 2px; }
