/* 树森发卡智能仓 · Web 中控 — HKXH-grade ops tokens (no AI neon junk) */
:root {
  --primary: #4458fe;
  --primary-hover: #3a4ce6;
  --topbar: #222653;
  --bg: #f6f9fc;
  --sidebar: #f3f6fa;
  --card: #ffffff;
  --thead: #fafafb;
  --text: #1f2433;
  --muted: #6a74a5;
  --border: #e4e8f0;
  --ok: #1f8f4e;
  --ok-bg: #e8f7ee;
  --warn: #b86e00;
  --warn-bg: #fff4e0;
  --bad: #d70015;
  --bad-bg: #fdecee;
  --off: #636366;
  --off-bg: #eef0f4;
  --radius: 8px;
  --sidebar-w: 192px;
  --topbar-h: 68px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── App shell ── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--topbar); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0; position: sticky; top: 0; z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px; background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-mark svg { display: block; }
.brand-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.65); margin-top: 2px; font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255,255,255,.85); }
.topbar-right a { color: rgba(255,255,255,.85); padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); }
.topbar-right a:hover { background: rgba(255,255,255,.08); color: #fff; }

.app-body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--border); padding: 12px 10px 24px;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: block; padding: 9px 12px; border-radius: 6px;
  color: var(--text); font-size: 13px; font-weight: 500;
}
.sidebar-nav a:hover { background: #e8edf5; color: var(--text); }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-section {
  margin: 14px 12px 6px; font-size: 11px; color: var(--muted);
  font-weight: 600; text-transform: none; letter-spacing: 0;
}

.content {
  flex: 1; min-width: 0; padding: 20px 24px 48px; max-width: 1200px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 20px; font-weight: 650; color: var(--topbar); }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 4px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 12px; font-size: 15px; font-weight: 650; color: var(--topbar);
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.card h2:last-child { border-bottom: none; padding-bottom: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.stat {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 14px 12px;
}
.stat .n { font-size: 24px; font-weight: 700; color: var(--topbar); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 6px; }

table.data, table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--thead); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:hover td { background: #fafbfd; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #c6ebd5; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a8; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #f5c2c7; }
.badge.off { background: var(--off-bg); color: var(--off); border-color: #dde1e8; }
.badge.info { background: #eef1ff; color: var(--primary); border-color: #d5dbff; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ops-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ops-row form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.force-lab { display: inline-flex; align-items: center; gap: 3px; margin: 0; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1; min-width: 42px; }
.force-lab input { width: auto; margin: 0; accent-color: var(--primary); }
.force-lab.is-muted { opacity: .45; }

/* ── Products table: aligned modules ── */
.table-wrap { overflow-x: auto; margin: 0 -2px; }
table.data.products-table { table-layout: fixed; min-width: 860px; }
table.data.products-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--thead);
  box-shadow: 0 1px 0 var(--border);
}
table.data.products-table th,
table.data.products-table td {
  vertical-align: middle;
  padding: 10px 12px;
}
.products-table .col-id { width: 56px; }
.products-table .col-name { width: auto; min-width: 180px; }
.products-table .col-cat { width: 96px; }
.products-table .col-num { width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.products-table .col-status { width: 72px; text-align: center; }
.products-table .col-ops { width: 260px; }
.products-table th.col-num,
.products-table th.col-status,
.products-table th.col-ops { text-align: inherit; }
.products-table th.col-num { text-align: right; }
.products-table th.col-status { text-align: center; }
.products-table th.col-ops { text-align: left; }

.cell-name { min-width: 0; max-width: 100%; }
.cell-name-title {
  font-weight: 650; color: var(--text); font-size: 13px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-name-desc {
  margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.35;
  height: calc(1.35em * 2); /* fixed 2-line slot → equal row height */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  line-clamp: 2; overflow: hidden; word-break: break-word;
}
.cell-name-desc.is-empty { visibility: hidden; }

.tabular { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.tabular .unit { color: var(--muted); font-weight: 500; font-family: var(--font); font-size: 11px; margin-left: 2px; }

.products-table .badge {
  min-width: 44px; height: 22px; justify-content: center; padding: 0 8px;
  box-sizing: border-box;
}

.ops-module {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 248px;
  flex-wrap: nowrap;
}
.ops-module > a.btn {
  flex: 0 0 52px; width: 52px; padding: 5px 0; justify-content: center;
}
.ops-module .ops-toggle {
  display: flex; margin: 0; flex: 0 0 52px;
}
.ops-module .ops-toggle button {
  width: 52px; padding: 5px 0; justify-content: center;
}
.ops-module .ops-delete {
  display: flex; align-items: center; gap: 6px; margin: 0; flex: 1 1 auto; min-width: 0;
}
.ops-module .ops-delete button {
  flex: 0 0 52px; width: 52px; padding: 5px 0; justify-content: center;
}
.ops-module .force-lab { flex: 0 0 42px; justify-content: flex-start; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; line-height: 1.2; font-family: inherit;
}
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.success { background: var(--ok); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
a.btn { color: #fff; }
a.btn.secondary { color: var(--text); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; max-width: 420px; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff; font: inherit; font-size: 13px;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(68,88,254,.12);
}
textarea { min-height: 120px; max-width: 100%; font-family: var(--mono); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.flash {
  padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px;
  background: #eef1ff; color: #2a3ab8; border: 1px solid #d5dbff;
}
.flash.err { background: var(--bad-bg); color: var(--bad); border-color: #f5c2c7; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #c6ebd5; }

.mono { font-family: var(--mono); font-size: 12px; }
.mono.pre { white-space: pre-wrap; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; font-size: 13px; }
form.inline { display: inline; }

/* ── Login split ── */
.login-page { min-height: 100vh; background: var(--bg); }
.login-shell {
  min-height: 100vh; max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, 400px);
  gap: 40px; align-items: center; padding: 40px 28px;
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; padding: 28px 18px; }
  .sidebar { display: none; }
}
.login-promo h1 { margin: 0 0 10px; font-size: 28px; color: var(--topbar); font-weight: 700; line-height: 1.25; }
.login-promo p.lead { margin: 0 0 22px; color: var(--muted); font-size: 14px; max-width: 420px; }
.promo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 460px; }
.promo-item {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 12px;
}
.promo-item .t { font-size: 13px; font-weight: 650; color: var(--topbar); }
.promo-item .d { font-size: 12px; color: var(--muted); margin-top: 4px; }
.login-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 28px 24px;
}
.login-card h2 { margin: 0 0 6px; font-size: 18px; color: var(--topbar); }
.login-card .hint { color: var(--muted); font-size: 12px; margin: 0 0 18px; }
.login-card .btn { width: 100%; padding: 10px 14px; }

.cats-table td { vertical-align: middle; }
.td-ops { white-space: nowrap; }
.td-ops .ops-row { flex-wrap: nowrap; }
.pill-link { font-size: 12px; }

@media (max-width: 720px) {
  .content { padding: 14px 12px 40px; }
  .td-ops .ops-row { flex-wrap: wrap; }
  .ops-module { width: auto; }
  .products-table .col-ops { width: 260px; }
}
