/* =========================================================
   集团资产管理系统 · 视觉系统 v2 —— 「台账控制台 / Ledger Console」
   浅冷灰画布 + 深墨蓝侧栏 + 翡翠绿信号色；克制、精确、有呼吸感。
   ========================================================= */
:root {
  /* 画布与面板 */
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --ink: #1a2230;
  --ink-2: #3a4558;
  --muted: #727d8f;
  --line: #e6eaf1;
  --line-soft: #eef1f6;

  /* 侧栏（深墨蓝，非近黑+荧光） */
  --sidebar-1: #16233f;
  --sidebar-2: #0e1a30;
  --sidebar-ink: #aeb9cc;
  --sidebar-ink-2: #eef3fb;

  /* 信号色：翡翠绿（替代靛蓝，语义=通过/确认） */
  --accent: #1f9d6b;
  --accent-d: #157a52;
  --accent-soft: #e7f5ee;
  --accent-line: #bfe6d4;

  /* 辅助语义色 */
  --warn: #e0922b;
  --warn-soft: #fbf0dd;
  --danger: #d8453c;
  --danger-d: #b8362f;
  --danger-soft: #fcebe9;
  --danger-line: #f6cfca;
  --info: #2f7fe0;
  --info-soft: #e8f1fc;

  /* 形状与阴影 */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20,30,55,.05), 0 2px 8px rgba(20,30,55,.04);
  --shadow: 0 1px 3px rgba(20,30,55,.06), 0 10px 30px rgba(20,30,55,.06);
  --shadow-lg: 0 24px 70px rgba(15,23,42,.30);
  --ring: 0 0 0 3px var(--accent-soft);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { min-height: 100vh; }

/* 入场动效（route/内容切换）；reduced-motion 时关闭 */
@keyframes contentIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadePop {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -360px 0; } 100% { background-position: 360px 0; } }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(31,157,107,.16), transparent 55%),
    radial-gradient(900px 500px at 110% 120%, rgba(47,127,224,.14), transparent 55%),
    linear-gradient(135deg, #16233f 0%, #13294a 55%, #143a52 100%);
}
.login-card {
  width: 392px; max-width: 100%;
  background: var(--panel); border-radius: 20px; padding: 38px 34px;
  box-shadow: var(--shadow-lg);
  animation: fadePop .35s cubic-bezier(.22,.61,.36,1) both;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .2px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.login-card .hint {
  margin-top: 20px; font-size: 12px; color: var(--ink-2);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: var(--radius-sm); line-height: 1.8;
}
.login-card .hint b { color: var(--accent-d); }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-1) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-ink);
  padding: 18px 14px 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 15px;
  padding: 6px 10px 18px; letter-spacing: .3px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #2bb98a 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(31,157,107,.4);
}
.brand .logo svg { width: 18px; height: 18px; }
.brand .brand-sub { font-weight: 500; font-size: 11px; color: var(--sidebar-ink); letter-spacing: 0; }

.nav-group { margin-top: 10px; }
.nav-group .title {
  font-size: 11px; color: #6b7a96; padding: 10px 12px 4px;
  letter-spacing: 1px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--sidebar-ink); cursor: pointer; font-size: 13.5px; margin: 2px 0;
  user-select: none; position: relative; transition: background .15s, color .15s;
}
.nav-item .ic { width: 18px; height: 18px; display: inline-flex; flex-shrink: 0; color: #8595b0; transition: color .15s; }
.nav-item .ic svg { width: 18px; height: 18px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--sidebar-ink-2); }
.nav-item:hover .ic { color: #cdd8ea; }
.nav-item.active { background: rgba(31,157,107,.16); color: #fff; font-weight: 600; }
.nav-item.active .ic { color: #5fe0ab; }
/* 激活项的左侧细信号条 */
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 60px; background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .right .muted { margin-right: 0; color: var(--muted); font-size: 12.5px; }
.topbar .right #orgSel {
  width: 188px; flex-shrink: 0; height: 36px; padding: 0 30px 0 12px; font-size: 13px;
}
.topbar .right .user {
  display: flex; flex-direction: column; line-height: 1.35; align-items: flex-start;
  font-size: 12.5px; color: var(--muted);
}
.topbar .right .user b { color: var(--ink); font-weight: 600; font-size: 13px; }
.topbar .right #logoutBtn { height: 36px; padding: 0 14px; }

.content { padding: 22px; animation: contentIn .26s cubic-bezier(.22,.61,.36,1) both; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px;
}
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.kpi .value.small { font-size: 20px; }
.kpi .bar { height: 4px; border-radius: 4px; margin-top: 12px; background: linear-gradient(90deg, var(--accent), #46c493); opacity: .9; }

.section-title { font-weight: 700; font-size: 15px; margin: 4px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title::before {
  content: ""; width: 4px; height: 15px; border-radius: 3px; background: var(--accent); margin-right: 2px;
  flex-shrink: 0;
}

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap;
  position: sticky; top: 60px; z-index: 9; background: var(--panel);
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; height: 36px; padding: 0 12px; }
.toolbar button { height: 36px; padding: 0 15px; }
.search-row { display: inline-flex; align-items: center; gap: 6px; }
.search-row input { width: auto; height: 36px; padding: 0 12px; }
.search-row button { height: 36px; padding: 0 15px; }
/* 筛选行：下拉筛选 + 搜索框 */
.filter-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select {
  width: auto; height: 36px; padding: 0 30px 0 12px; max-width: 220px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 13px; color: var(--ink-2); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.filter-select:hover { border-color: var(--primary-d); }
.filter-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-select.active { border-color: var(--primary); color: var(--primary-d); background-color: var(--accent-soft); }

/* ---------- 表单控件 ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #aab2c0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 64px; }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23727d8f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .45; transition: .15s; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: -2px; margin-right: 6px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: var(--radius-sm); padding: 9px 16px;
  background: var(--accent); color: #fff; font-weight: 600; transition: background .15s, transform .05s, box-shadow .15s;
}
button:hover { background: var(--accent-d); }
button:active { transform: translateY(1px); }
button.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
button.ghost:hover { background: var(--panel-2); color: var(--ink); }
button.danger { background: var(--danger); color: #fff; border: 1px solid var(--danger); }
button.danger:hover { background: var(--danger-d); border-color: var(--danger-d); }
button.ghost.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger-line); }
button.ghost.danger:hover { background: var(--danger-soft); color: var(--danger-d); border-color: #f0b0aa; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-d); }
button.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.chk-group { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 6px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.chk input { width: auto; margin: 0; }
.duty-tpl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; }

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12.5px;
  position: sticky; top: 0; border-bottom: 1px solid var(--line);
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f5fbf8; }
tbody tr:last-child td { border-bottom: none; }
td.wrap, th.wrap { white-space: normal; }
td.ellip, th.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
td.ellip.w-name { max-width: 210px; }
td.ellip.w-model { max-width: 230px; }
.table-wrap table thead th:last-child,
.table-wrap table tbody td:last-child {
  position: sticky; right: 0; z-index: 6; background: #fff; box-shadow: -1px 0 0 var(--line);
}
.table-wrap table thead th:last-child { background: var(--panel-2); z-index: 8; }
.table-wrap table tbody tr:hover td:last-child { background: #f5fbf8; }
.row-link { cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 13.5px; }
.empty::before { content: "📭"; display: block; font-size: 28px; margin-bottom: 8px; opacity: .7; }

/* ---------- 徽章（语义化配色，匹配新系统） ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.b-green  { background: #e7f5ee; color: #137a52; }
.b-blue   { background: #e8f1fc; color: #1f63c4; }
.b-orange { background: #fbf0dd; color: #a9691a; }
.b-red    { background: #fcebe9; color: #b8362f; }
.b-teal   { background: #e3f4f1; color: #0c7d6e; }
.b-amber  { background: #fbf0dd; color: #a9691a; }
.b-gray   { background: #eef1f6; color: #5c6678; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px; z-index: 100; overflow-y: auto;
  animation: fadePop .15s ease both;
}
.modal {
  width: 540px; max-width: 100%; background: #fff; border-radius: 16px; padding: 22px 24px;
  box-shadow: var(--shadow-lg); animation: fadePop .18s cubic-bezier(.22,.61,.36,1) both;
  max-height: calc(100vh - 64px); overflow-y: auto;
}
.modal.wide { width: 980px; max-width: 95vw; }
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal .form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.modal .form-grid .full { grid-column: 1 / -1; }
.modal .form-grid input, .modal .form-grid select, .modal .form-grid textarea { width: 100%; box-sizing: border-box; }
.modal .form-grid .tag-input { width: 100%; }
.modal .form-grid img.preview { max-width: 100%; max-height: 120px; border-radius: 8px; margin-top: 8px; border: 1px solid var(--line); }
.modal .img-row { display: flex; align-items: center; gap: 12px; }
.readonly-field {
  width: 100%; box-sizing: border-box; min-height: 36px;
  padding: 8px 11px; border: 1px dashed var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--ink-2); font-size: 13.5px;
  font-variant-numeric: tabular-nums; word-break: break-all;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head span { font-size: 16px; font-weight: 600; }
.modal-x { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px 6px; border-radius: 6px; }
.modal-x:hover { background: var(--panel-2); color: var(--ink); }
.modal-body { font-size: 14px; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.alert { padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; }
.alert.ok  { background: var(--accent-soft); color: #157a52; border: 1px solid var(--accent-line); }
.alert.err { background: var(--danger-soft); color: #991b1b; border: 1px solid var(--danger-line); }
.dlg-msg { color: var(--ink-2); line-height: 1.7; margin: 2px 0 0; }
.err-list { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-size: 13px; max-height: 180px; overflow-y: auto; }

/* ---------- 多选选择器（资产/用品） ---------- */
.picker-field { display: flex; gap: 8px; align-items: flex-start; }
.picker-display {
  flex: 1; min-width: 0; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.picker-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 6px 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: #157a52; border: 1px solid var(--accent-line);
  font-size: 12.5px; line-height: 1.5;
}
.picker-chip .chip-x {
  border: none; background: transparent; cursor: pointer; color: inherit;
  font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.picker-chip .chip-x:hover { background: rgba(0, 0, 0, .08); }
.picker-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.picker-bar input[type="text"], .picker-bar input:not([type]) {
  flex: 1; min-width: 200px; height: 34px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; box-sizing: border-box;
}
.picker-bar .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.picker-bar .chk input { width: auto; margin: 0; }
.picker-table-wrap {
  max-height: 52vh; overflow: auto; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
}
.picker-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.picker-table-wrap th, .picker-table-wrap td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
}
.picker-table-wrap th.pk-check, .picker-table-wrap td.pk-check { width: 38px; max-width: 38px; padding-left: 12px; padding-right: 6px; }
/* 语义列宽：由 JS 输出的 col-* 类指定（合计 100%，避免溢出） */
.picker-table-wrap .col-img { width: 54px; max-width: 54px; padding-left: 8px; padding-right: 4px; overflow: visible; }
.picker-table-wrap .col-img .thumb { width: 34px; height: 34px; }
.picker-table-wrap .col-code { width: 18%; }
.picker-table-wrap .col-name { width: 16%; }
.picker-table-wrap .col-cat  { width: 11%; }
.picker-table-wrap .col-model{ width: 18%; }
.picker-table-wrap .col-spec { width: 13%; }
.picker-table-wrap .col-custodian { width: 10%; }
.picker-table-wrap .col-loc  { width: 12%; }
.picker-table-wrap .col-stock{ width: 9%; }
.picker-table-wrap .col-unit { width: 8%; }
.picker-table-wrap .col-qty  { width: 100px; max-width: 100px; }
.picker-table-wrap th {
  background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12.5px;
  position: sticky; top: 0; z-index: 2;
}
.picker-table-wrap tbody tr:hover { background: #f5fbf8; }
.picker-table-wrap tbody tr:last-child td { border-bottom: none; }
.picker-table-wrap input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.picker-table-wrap input.pk-qty { width: 76px; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; box-sizing: border-box; }
.err-list li { margin-bottom: 3px; }
input[type="file"] { padding: 8px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--panel-2); width: 100%; }

/* ---------- 自建日期选择器 ------------ */
.datepicker { position: relative; }
.dp-input { cursor: pointer; background: #fff; }
.dp-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: 15px; opacity: .55; }
.datepicker:focus-within .dp-icon { opacity: 1; }
.dp-popup {
  position: fixed; z-index: 300; width: 284px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px; animation: fadePop .12s ease both;
}
.dp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.dp-title { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.dp-nav {
  width: 28px; height: 28px; padding: 0; border-radius: 8px; background: var(--panel-2); color: var(--ink);
  font-size: 15px; line-height: 1; border: none; cursor: pointer; transition: background .12s, color .12s;
}
.dp-nav:hover { background: var(--accent-soft); color: var(--accent-d); }
.dp-week { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.dp-week span { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-day {
  text-align: center; font-size: 13px; padding: 7px 0; border-radius: 8px; cursor: pointer; color: var(--ink);
  transition: background .12s;
}
.dp-day:hover { background: var(--accent-soft); }
.dp-day.other { visibility: hidden; }
.dp-day.today { color: var(--accent-d); font-weight: 700; }
.dp-day.today::after { content: ""; display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin: 1px auto 0; }
.dp-day.sel { background: var(--accent); color: #fff; font-weight: 600; }
.dp-day.sel:hover { background: var(--accent-d); }
.dp-foot { display: flex; gap: 8px; margin-top: 10px; }
.dp-btn {
  flex: 1; padding: 7px 0; border-radius: 8px; border: none; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s;
}
.dp-btn:hover { background: var(--accent-d); }
.dp-btn.ghost { background: var(--panel-2); color: var(--ink); }
.dp-btn.ghost:hover { background: var(--line); }

/* ---------- 详情 ---------- */
.detail-head { display: flex; gap: 20px; align-items: flex-start; }
.detail-head img { width: 180px; height: 140px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 18px 0 12px; border-bottom: 1px solid var(--line); }
.tabs .tab { padding: 9px 14px; cursor: pointer; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; transition: color .12s, border-color .12s; }
.tabs .tab:hover { color: var(--ink-2); }
.tabs .tab.active { color: var(--accent-d); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #1a2230; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: fadePop .15s; max-width: 340px; display: flex; align-items: center; gap: 8px;
}
.toast::before { content: "✓"; color: #5fe0ab; font-weight: 700; }
.toast.err { background: var(--danger-d); }
.toast.err::before { content: "!"; color: #ffd5d1; }
.toast.ok { background: var(--accent-d); }
.toast.ok::before { content: "✓"; }
.toast.fade { opacity: 0; transition: opacity .3s; }

/* ---------- 图表 ---------- */
.charts { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.chart-box h4 { margin: 0 0 12px; font-size: 14px; }
.chart-box canvas { max-height: 280px; }

.muted { color: var(--muted); }
.flex { display: flex; gap: 12px; align-items: center; }
.nowrap { white-space: nowrap; }

/* ---------- 加载态 ---------- */
.card-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); min-height: 140px; font-size: 13.5px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
/* 骨架屏（表格/清单加载占位） */
.skeleton { padding: 18px 20px; }
.skeleton .sk-line { height: 14px; border-radius: 7px; margin: 12px 0; background: linear-gradient(90deg, #eef1f6 25%, #e2e7f0 37%, #eef1f6 63%); background-size: 720px 100%; animation: shimmer 1.2s infinite linear; }
.skeleton .sk-line.w40 { width: 40%; } .skeleton .sk-line.w70 { width: 70%; } .skeleton .sk-line.w55 { width: 55%; }

/* ---------- 条码标签 ---------- */
.barcode-label { width: 320px; margin: 6px auto 4px; padding: 14px 16px 12px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; background: #fff; }
.barcode-label .bl-title { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-bottom: 8px; }
.barcode-label .barcode-svg { display: block; margin: 0 auto; max-width: 100%; }
.barcode-label .bl-name { font-size: 15px; font-weight: 700; margin-top: 8px; }
.barcode-label .bl-meta { font-size: 12px; color: #374151; margin-top: 3px; }
.barcode-label .bl-meta.muted { color: var(--muted); }

@media print {
  body * { visibility: hidden; }
  #barcodeLabel, #barcodeLabel * { visibility: visible; }
  #barcodeLabel { position: absolute; left: 0; top: 0; width: 100%; border: none; }
  .modal-mask { position: static; background: none; display: block; }
  .modal { box-shadow: none; }
}

/* ================= 分类管理页面 ================= */
.cat-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; margin-top: 12px; }
.cat-list-panel { display: flex; flex-direction: column; gap: 10px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cat-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); min-height: 90px;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent-line); }
.cat-card .cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat-card .cat-name { font-size: 14px; font-weight: 600; color: var(--ink); word-break: break-word; }
.cat-card .cat-code {
  font-size: 11.5px; font-weight: 700; letter-spacing: .5px; color: var(--accent-d);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 6px; padding: 1px 7px; flex-shrink: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.cat-card .cat-code-empty {
  color: var(--muted); background: #eef1f6; border-color: var(--line);
  font-family: inherit; font-weight: 600; letter-spacing: 0;
}
.cat-card .cat-used { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.cat-card .cat-used .badge { font-size: 10.5px; font-weight: 600; }
.cat-card .cat-actions { display: flex; gap: 6px; margin-top: 8px; }
.cat-card .cat-actions button { flex: 1; margin-top: 0; }
.cat-edit-hint { margin-top: 10px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }

.cat-add-panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; height: fit-content; }
.cat-add-panel .section-title-sm { font-size: 13.5px; font-weight: 700; margin: 0 0 12px; color: var(--ink); }
.cat-add-panel .field-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.cat-add-panel .field-row label { font-size: 12px; color: var(--muted); font-weight: 600; }
.cat-add-panel .field-row input, .cat-add-panel .field-row select { width: 100%; height: 34px; font-size: 13px; }
.cat-add-panel button.primary.sm { width: 100%; padding: 8px 16px; margin-top: 6px; }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .cat-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 10px 12px; gap: 4px;
  }
  .brand { padding: 4px 10px 4px 4px; flex-shrink: 0; }
  .brand .brand-sub { display: none; }
  .nav-group { margin-top: 0; display: flex; align-items: center; gap: 2px; }
  .nav-group .title { display: none; }
  .nav-item { margin: 0; white-space: nowrap; padding: 8px 12px; }
  .nav-item.active::before { display: none; }
  .nav-item.active { background: rgba(31,157,107,.22); }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .topbar .right #orgSel { width: 130px; }
}

/* ================= 无障碍：尊重减弱动效 ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .content, .modal, .modal-mask, .login-card, .dp-popup { animation: none !important; }
}

/* tag-select：可选已有、可手动输入的分类/标签 */
.tag-select-wrap { position: relative; display: inline-block; width: 100%; }
.tag-select-wrap input { width: 100%; padding-right: 34px; }
.tag-arrow {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; background: transparent; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.tag-arrow:hover { color: var(--ink); background: var(--panel-2); }
.tag-menu {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000; background: #fff;
  border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; display: none;
}
.tag-menu-item { padding: 8px 12px; font-size: 13px; color: var(--ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-menu-item:hover { background: var(--accent-soft); color: var(--accent-d); }
.tag-menu-item.active { background: var(--accent-soft); color: var(--accent-d); font-weight: 600; }
.tag-menu-item.tag-custom { font-size: 12px; color: var(--muted); font-style: italic; border-top: 1px solid var(--line); }

/* 表格图片缩略图 */
.thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fafc;
  vertical-align: middle;
  cursor: pointer;
}
.thumb:hover {
  border-color: var(--primary-d);
  transform: scale(1.05);
}

/* ---------- 库存水位进度条 ---------- */
td.w-stock { min-width: 200px; white-space: normal; }
.stock-bar { display: flex; align-items: center; gap: 9px; }
.sb-track {
  position: relative; flex: 1; min-width: 100px; height: 8px;
  background: #eef1f6; border-radius: 999px; overflow: hidden;
}
.sb-fill {
  height: 100%; border-radius: 999px; transition: width .25s ease, background-color .2s ease;
}
/* 三段过渡：红(不足阈值) -> 黄(接近阈值) -> 绿(充足) */
.sb-fill.low  { background: linear-gradient(90deg, #dc2626, #ef4444); }
.sb-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.sb-fill.ok   { background: linear-gradient(90deg, #16a34a, #22c55e); }
.sb-threshold {
  position: absolute; top: -2px; bottom: -2px; left: 50%; width: 2px;
  background: #64748b; opacity: .85; border-radius: 1px;
}
.sb-text {
  font-size: 12.5px; white-space: nowrap; color: var(--ink-2);
  font-variant-numeric: tabular-nums; min-width: 66px;
}
.sb-text.low  { color: #b91c1c; font-weight: 600; }
.sb-text.warn { color: #b45309; }
.sb-text.ok   { color: #15803d; }
.sb-gap {
  color: #b91c1c; font-weight: 600; font-size: 11.5px;
  padding: 1px 5px; border-radius: 999px; background: #fdecec; margin-left: 2px;
}

/* 表格容器内部表格样式 */
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrap th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
.table-wrap td {
  font-size: 13px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
.table-wrap tr:hover td {
  background: #f1f5f9;
}

/* 分页控件 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  gap: 8px;
  flex-wrap: wrap;
}
.pagination-info {
  color: var(--muted);
  font-size: 13px;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pagination-controls button.ghost[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 图片大图查看器 */
.image-viewer {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.image-viewer-header {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px;
}
.image-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 12px;
  min-height: 400px;
}
.image-viewer-img {
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}
.image-viewer .actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px;
}

/* 长名称截断提示 */
.tip {
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  display: inline-block;
}
