/* 后台管理布局样式 */
.admin-layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar { width: 200px; background: #17202A; color: #CBD5E1; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 18px 20px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand em { color: var(--primary); font-style: normal; }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar .nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 20px; color: #CBD5E1; font-size: 14px; text-align: left; border-left: 3px solid transparent; }
.sidebar .nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar .nav-item.active { background: rgba(217,56,44,.15); color: #fff; border-left-color: var(--primary); }
.sidebar .nav-item .ico { font-size: 16px; }
.sidebar .foot { padding: 14px 20px; font-size: 12px; color: #64748B; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 700; flex: none; user-select: none; vertical-align: middle; }
.sidebar .foot-info { line-height: 1.5; min-width: 0; }
.sidebar .foot-info b { color: #E2E8F0; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .avatar-mini { width: 26px; height: 26px; font-size: 12px; vertical-align: middle; }
/* 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.content { padding: 24px; flex: 1; }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .value.red { color: var(--primary); }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 6px; }

.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.panel-head .ops { display: flex; gap: 10px; align-items: center; font-weight: 400; }
.panel-body { padding: 16px 20px; }
.panel-body.no-pad { padding: 0; }

/* 工具栏 */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar input[type=date], .toolbar select { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }

/* 图表 */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding: 10px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 70%; max-width: 42px; background: linear-gradient(180deg, #F0544A, var(--primary)); border-radius: 5px 5px 0 0; min-height: 2px; transition: height .4s; position: relative; }
.chart .bar .val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart .xlabel { font-size: 11px; color: var(--muted); }

/* 热销列表 */
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank .row { display: flex; align-items: center; gap: 12px; }
.rank .no { width: 22px; height: 22px; border-radius: 6px; background: #F3F4F6; color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank .row:nth-child(1) .no { background: var(--primary); color: #fff; }
.rank .row:nth-child(2) .no { background: #FCA5A5; color: #fff; }
.rank .row:nth-child(3) .no { background: #FECACA; color: #7F1D1D; }
.rank .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .amt { color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.rank .qty { color: var(--muted); font-size: 12px; width: 70px; text-align: right; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* 商品表格操作列 */
.ops-cell { display: flex; gap: 6px; }
.link-btn { color: var(--blue); font-size: 13px; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: #DC2626; }
.link-btn:disabled { color: #9CA3AF; cursor: not-allowed; text-decoration: none; }

.low-stock { color: #DC2626; font-weight: 600; }

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar .brand span, .sidebar .nav-item span:not(.ico), .sidebar .foot-info { display: none; }
  .sidebar .foot { justify-content: center; padding: 14px 0; }
  .sidebar .nav-item { justify-content: center; padding: 12px 0; }
  .content { padding: 14px; }
}

/* ---------- 面板工具条统一（搜索 / 筛选 / 新增按钮） ---------- */
.panel-head { flex-wrap: wrap; gap: 10px; }
.panel-head .ops { flex-wrap: wrap; gap: 8px; }
.panel-head .ops input[type=text], .panel-head .ops input[type=date], .panel-head .ops select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; outline: none; font-size: 13px; color: var(--text);
}
.panel-head .ops input:focus, .panel-head .ops select:focus { border-color: var(--primary); }
.panel-head .ops input[type=text] { width: 180px; }
.panel-head .ops .btn { height: 34px; }

/* ---------- 登录页移动端优化 ---------- */
/* svh：手机浏览器地址栏收起/展开时高度更稳，键盘弹出时不易把卡片顶出屏幕 */
.login-page { min-height: 100vh; min-height: 100svh; }

@media (max-width: 768px) {
  .login-page { padding: 16px; }
  .login-card {
    max-width: 100%;
    padding: 26px 20px 22px;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(16, 24, 40, .10);
  }
  .login-card .logo { font-size: 24px; }
  .login-card .sub { margin-bottom: 22px; }
  .login-card .field { margin-bottom: 16px; }
  .login-card .field label { margin-bottom: 8px; font-size: 13px; }
  /* 16px 起步：避免 iOS Safari 聚焦输入框时整页自动放大 */
  .login-card .field input { height: 46px; font-size: 16px; border-radius: 10px; padding: 0 12px; }
  .login-card .btn { height: 48px; font-size: 16px; font-weight: 600; border-radius: 10px; margin-top: 10px; }
  .login-tip { margin-top: 14px; padding: 10px 12px; font-size: 12px; line-height: 1.8; }
}

/* ---------- 手机端：面板工具条 / 弹窗表单 ---------- */
@media (max-width: 720px) {
  /* 标题一行，搜索/筛选/按钮另起一行铺开，不再和标题挤在一起 */
  .panel-head { display: block; }
  .panel-head .ops { margin-top: 12px; }
  .panel-head .ops input[type=text], .panel-head .ops input[type=date] { width: 100%; font-size: 16px; height: 40px; }
  .panel-head .ops select { flex: 1 1 40%; min-width: 0; height: 40px; font-size: 14px; }
  .panel-head .ops .btn { flex: 1 1 40%; height: 40px; }

  /* 弹窗：更贴边、按钮加大、表单两列自动换行，输入 16px 防 iOS 放大 */
  .modal-mask { padding: 12px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }
  .modal-foot .btn { flex: 1; height: 44px; font-size: 15px; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .field-row { flex-wrap: wrap; gap: 10px; }
  .field-row .field { flex: 1 1 46%; }
}
