/* ==========================================================================
   五金工具批发零售商城 —— 后台管理样式
   设计原则：简约清爽、信息密度适中、克制的色彩与圆角
   ========================================================================== */

:root {
  --brand: #1a6dd8;
  --brand-dark: #145ab3;
  --brand-soft: #eaf2fd;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdeaea;

  --text: #1f2937;
  --text-sub: #6b7280;
  --text-mute: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f0f2f5;
  --bg: #f5f7fa;
  --card: #ffffff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --sidebar-w: 210px;
}

* { box-sizing: border-box; }

body.xph-admin {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 布局 ---------------- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 20px 20px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; margin-top: 3px; letter-spacing: 0; }

.nav-group { padding: 14px 0 4px; }
.nav-group-title {
  padding: 0 20px 6px;
  font-size: 11px;
  color: #64748b;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar a.active { background: rgba(26, 109, 216, .18); color: #fff; border-left-color: var(--brand); font-weight: 500; }
.sidebar a .ic { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.sidebar .logout { margin-top: auto; color: #fca5a5; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .2px; }
.page-head .sub { color: var(--text-sub); font-size: 13px; margin-top: 3px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head h2 small { font-weight: 400; color: var(--text-sub); margin-left: 8px; font-size: 12px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------- 统计卡 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--text-sub); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 650; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--brand); }
.stat.ok { border-left: 3px solid var(--ok); }
.stat.warn { border-left: 3px solid var(--warn); }
.stat.danger { border-left: 3px solid var(--danger); }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table th {
  background: #fafbfc;
  font-weight: 600;
  color: var(--text-sub);
  font-size: 12.5px;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .actions { white-space: nowrap; }
.table .actions a, .table .actions button { margin-right: 6px; }
.table img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #f8fafc; }
.table .title-cell { display: flex; align-items: center; gap: 10px; }
.table .title-cell .t { font-weight: 500; color: var(--text); }
.table .title-cell .s { font-size: 12px; color: var(--text-mute); }

.empty { padding: 46px 20px; text-align: center; color: var(--text-mute); font-size: 13.5px; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 19px;
  background: #f1f5f9;
  color: var(--text-sub);
  white-space: nowrap;
}
.tag-blue   { background: var(--brand-soft);   color: var(--brand-dark); }
.tag-green  { background: var(--ok-soft);      color: var(--ok); }
.tag-yellow { background: var(--warn-soft);    color: var(--warn); }
.tag-red    { background: var(--danger-soft);  color: var(--danger); }
.tag-gray   { background: #f1f5f9;             color: var(--text-mute); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; background: var(--danger); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { opacity: .88; background: var(--ok); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link { border: none; background: none; color: var(--brand); padding: 2px 4px; }
.btn-link:hover { text-decoration: underline; background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 13px; color: var(--text-sub); font-weight: 500; }
.field > label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--text-mute); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=email], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 109, 216, .12);
}
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .1); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.err-msg { color: var(--danger); font-size: 12px; min-height: 16px; }

.form-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px;
  background: #fafbfc;
  border-top: 1px solid var(--line-soft);
}

/* ---------------- 筛选条 ---------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters .btn { height: 35px; }

/* ---------------- Tab ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; background: #fff; }
.tabs button {
  padding: 12px 16px;
  border: none; background: none;
  font-size: 14px; color: var(--text-sub);
  cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* ---------------- SKU 行编辑 ---------------- */
.sku-table th, .sku-table td { padding: 8px 8px; }
.sku-table input { padding: 6px 9px; font-size: 13px; }
.sku-table .del-btn { color: var(--danger); border: none; background: none; cursor: pointer; font-size: 17px; line-height: 1; padding: 0 5px; }
.spec-row { display: flex; gap: 8px; margin-bottom: 8px; }
.spec-row input { flex: 1; }

/* ---------------- 详情描述列表 ---------------- */
.desc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.desc-item { display: flex; gap: 8px; font-size: 13.5px; }
.desc-item .k { color: var(--text-sub); flex: 0 0 84px; }
.desc-item .v { color: var(--text); font-weight: 500; }

/* ---------------- 时间线 ---------------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brand-soft);
}
.timeline-item .tl-time { font-size: 12px; color: var(--text-mute); }
.timeline-item .tl-text { font-size: 13.5px; }

/* ---------------- 图表（纯 CSS 条形） ---------------- */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 10px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-item .bar {
  width: 100%;
  max-width: 26px;
  background: linear-gradient(180deg, #4a94e8, var(--brand));
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: opacity .15s;
}
.bar-item:hover .bar { opacity: .8; }
.bar-item .bar-label { font-size: 11px; color: var(--text-mute); white-space: nowrap; }
.bar-item .bar-val { font-size: 11px; color: var(--text-sub); font-variant-numeric: tabular-nums; }

.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.hbar-row .name { flex: 0 0 130px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row .track { flex: 1; height: 9px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.hbar-row .fill { height: 100%; background: var(--brand); border-radius: 5px; }
.hbar-row .val { flex: 0 0 92px; text-align: right; color: var(--text-sub); font-variant-numeric: tabular-nums; }

/* ---------------- 提示条 ---------------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-warn { background: var(--warn-soft); color: #92400e; border: 1px solid #fde3b8; }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #c9ddf8; }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2f7 0%, #e2e8f0 100%); padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 32px 30px;
}
.login-card .logo { text-align: center; margin-bottom: 6px; }
.login-card .logo h1 { font-size: 21px; margin: 0 0 5px; letter-spacing: .5px; }
.login-card .logo p { margin: 0 0 22px; color: var(--text-sub); font-size: 13px; }
.login-card .field { margin-bottom: 15px; }
.login-card .submit { width: 100%; padding: 10px; font-size: 15px; margin-top: 4px; }
.login-card .tips { margin-top: 18px; font-size: 12.5px; color: var(--text-mute); text-align: center; line-height: 1.9; }
.login-card .tips code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; color: var(--text-sub); }

/* ---------------- 杂项 ---------------- */
.muted { color: var(--text-sub); }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.mb { margin-bottom: 14px; }
.center { text-align: center; }
.right { text-align: right; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pager { margin-top: 16px; }
/* ThinkPHP 分页输出类名为 .pagination，这里同时兼容 .ui-pagination */
.pager .pagination, .pager .ui-pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pager .pagination li a, .pager .pagination li span,
.pager .ui-pagination li a, .pager .ui-pagination li span {
  display: block; padding: 5px 11px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--text); text-decoration: none; background: #fff;
}
.pager .pagination li.active span, .pager .ui-pagination li.active span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .pagination li a:hover, .pager .ui-pagination li a:hover { border-color: var(--brand); color: var(--brand); }
.pager .pagination li.disabled span, .pager .ui-pagination li.disabled span { color: var(--text-mute); background: #fafbfc; cursor: not-allowed; }

.footer-note { text-align: center; color: var(--text-mute); font-size: 12px; padding: 18px 0 0; }
.footer-note a { color: var(--text-mute); }

/* ---------------- 收银台 ---------------- */
.cashier-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.cart-line img { width: 38px; height: 38px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.cart-line .info { flex: 1; min-width: 0; }
.cart-line .info .n { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line .info .s { font-size: 12px; color: var(--text-mute); }
.cart-line .rm { color: var(--danger); cursor: pointer; border: none; background: none; font-size: 16px; }
.sum-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.sum-row.total { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 11px; font-size: 16px; font-weight: 650; }
.sum-row.total .v { color: var(--danger); font-variant-numeric: tabular-nums; }
.search-result {
  max-height: 320px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin-top: 8px;
}
.search-result .item { display: flex; gap: 10px; padding: 9px 11px; border-bottom: 1px solid var(--line-soft); cursor: pointer; align-items: center; }
.search-result .item:last-child { border-bottom: none; }
.search-result .item:hover { background: var(--brand-soft); }
.search-result img { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-sm); }
.search-result .meta { flex: 1; min-width: 0; }
.search-result .meta .n { font-size: 13px; font-weight: 500; }
.search-result .meta .p { font-size: 12px; color: var(--text-sub); }
.goods-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.goods-picker .g { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: #fff; }
.goods-picker .g:hover { border-color: var(--brand); }
.goods-picker .g img { width: 100%; height: 108px; object-fit: cover; display: block; }
.goods-picker .g .b { padding: 8px 10px; }
.goods-picker .g .n { font-size: 12.5px; line-height: 1.4; height: 35px; overflow: hidden; }
.goods-picker .g .p { color: var(--danger); font-weight: 600; font-size: 13px; margin-top: 4px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .cashier-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar .nav-group { display: flex; flex-wrap: wrap; padding: 8px 0; }
  .sidebar .nav-group-title { display: none; }
  .sidebar a { padding: 7px 13px; border-left: none; border-radius: var(--radius-sm); font-size: 13px; }
  .sidebar .logout { margin-top: 0; }
  .main { padding: 16px 14px 30px; }
  .table { font-size: 12.5px; }
  .table th, .table td { padding: 9px 10px; }
  /* 窄屏下表格横向滚动，避免挤压 */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll .table { min-width: 620px; }
}
@media (max-width: 560px) {
  .page-head h1 { font-size: 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat .value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .goods-picker { grid-template-columns: repeat(2, 1fr); }
  .hbar-row .name { flex-basis: 90px; }
}
/* ================================================================
   商家中心（多商户平台）
   ================================================================ */

/* 两栏卡片布局：窄屏自动堆叠 */
.two-col {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* 侧边栏待办徽标 */
.sidebar a .nav-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 商家工作台趋势图：
   柱体高度由控制器算好百分比内联在 style 里，这里只负责视觉 */
.bar-item { justify-content: flex-end; }
.bar-item .bar-num {
  font-size: 11px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-bottom: 2px;
}
.bar-item .bar-stack {
  width: 100%;
  max-width: 26px;
  background: linear-gradient(180deg, #4a94e8, var(--brand));
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: opacity .15s;
}
.bar-item:hover .bar-stack { opacity: .82; }
.bar-item .bar-x {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
  margin-top: 6px;
}

/* 待办清单 */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.todo-list li:last-child { border-bottom: none; }
.todo-list li .t { color: var(--text-sub); }
.todo-list li b { font-size: 17px; font-variant-numeric: tabular-nums; }
.t-brand  { color: var(--brand); }
.t-warn   { color: var(--warn); }
.t-danger { color: var(--danger); }

/* 表格操作区：按钮横向排列不换行 */
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-right: 6px; }
.table .actions .btn:last-child { margin-right: 0; }

/* 登录页底部的多端入口 */
.login-card .foot-links,
.auth-card .foot-links {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
}
.login-card .foot-links a,
.auth-card .foot-links a {
  color: var(--brand);
  text-decoration: none;
}
.login-card .foot-links a:hover,
.auth-card .foot-links a:hover { text-decoration: underline; }
.login-card .foot-links .sep,
.auth-card .foot-links .sep { margin: 0 8px; color: var(--line); }
