/* ==========================================================================
   沭宁美居 ERP · 设计系统 —— 紧凑数据型（类传统 ERP）
   主色 #1B6FE0 ｜ 窄侧栏 140px ｜ 全框线表格 ｜ 高密度 ｜ 浅色/深色双主题
   ========================================================================== */

:root {
  /* 品牌色（标准蓝） */
  --primary:        #1B6FE0;
  --primary-600:    #1557B0;
  --primary-700:    #10407F;
  --primary-50:     #EAF2FD;
  --primary-100:    #D6E6FA;
  --primary-200:    #A9CBF5;

  /* 语义色 */
  --success: #16A34A;
  --success-bg: #E7F6EC;
  --warning: #E08A00;
  --warning-bg: #FEF3E2;
  --danger:  #D93025;
  --danger-bg: #FDECEC;
  --info:    #1B6FE0;
  --info-bg: #EAF2FD;
  --purple:  #7C3AED;
  --purple-bg: #F1ECFE;

  /* 中性色 */
  --bg:        #F0F3F7;
  --surface:   #FFFFFF;
  --surface-2: #F5F7FA;
  --zebra:     #FAFBFD;
  --border:    #D4DBE4;
  --border-2:  #E4EAEF;
  --text:      #1B2430;
  --text-2:    #4E5C6B;
  --text-3:    #8B98A6;

  /* 侧栏（深灰蓝） */
  --sidebar-bg:     #1B2430;
  --sidebar-text:   #A6B4C4;
  --sidebar-active: #4C9AFF;
  --sidebar-hover:  rgba(255,255,255,.07);

  /* 尺寸 —— 紧凑 */
  --sidebar-w: 140px;
  --sidebar-mini: 46px;
  --topbar-h: 44px;
  --radius: 4px;
  --radius-sm: 3px;
  --radius-lg: 6px;

  /* 表格密度（可切换） */
  --row-py: 4px;
  --row-px: 8px;
  --table-fs: 12px;
  --table-head-fs: 11.5px;

  --shadow-sm: 0 1px 2px rgba(27, 36, 48, .05);
  --shadow:    0 1px 4px rgba(27, 36, 48, .07);
  --shadow-md: 0 4px 14px rgba(27, 36, 48, .1);
  --shadow-lg: 0 12px 36px rgba(27, 36, 48, .18);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs:    12.5px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 17px;
  --fs-2xl: 21px;
}

/* 舒适密度（备选，html[data-density="relaxed"] 启用） */
html[data-density="relaxed"] {
  --row-py: 9px;
  --row-px: 12px;
  --table-fs: 13px;
  --table-head-fs: 12.5px;
  --topbar-h: 56px;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --fs: 13.5px;
  --fs-sm: 12.5px;
  --fs-md: 14.5px;
  --fs-lg: 15px;
  --fs-xl: 19px;
  --fs-2xl: 25px;
}

/* ---------- 深色主题 ---------- */
[data-theme="dark"] {
  --bg:        #0F141B;
  --surface:   #161D26;
  --surface-2: #1C2530;
  --zebra:     #19212B;
  --border:    #2A3542;
  --border-2:  #222C38;
  --text:      #E4EAF1;
  --text-2:    #9DAABA;
  --text-3:    #6C7885;

  --primary-50:  rgba(27,111,224,.14);
  --primary-100: rgba(27,111,224,.22);
  --primary-200: rgba(27,111,224,.34);

  --success-bg: rgba(22,163,74,.16);
  --warning-bg: rgba(224,138,0,.16);
  --danger-bg:  rgba(217,48,37,.16);
  --info-bg:    rgba(27,111,224,.16);
  --purple-bg:  rgba(124,58,237,.16);

  --sidebar-bg: #0B1017;
  --sidebar-text: #8C99A8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.34);
  --shadow:    0 1px 4px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 36px rgba(0,0,0,.62);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
a { color: var(--primary-600); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: auto;
  background:
    radial-gradient(900px 520px at 12% 8%, rgba(27,111,224,.18), transparent 62%),
    radial-gradient(760px 460px at 88% 92%, rgba(21,87,176,.16), transparent 60%),
    linear-gradient(150deg, #12263F 0%, #1B2430 48%, #0D141C 100%);
}
.login-wrap::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 100%);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 372px;
  background: var(--surface); border-radius: 8px; padding: 32px 30px 28px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.08);
  animation: cardIn .42s cubic-bezier(.16,1,.3,1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.99); } }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-brand .logo {
  width: 40px; height: 40px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 5px 14px rgba(27,111,224,.34);
}
.login-brand h1 { font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.login-brand p { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.login-input {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-2); transition: .16s; font-size: 13px;
}
.login-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-50); }
.login-btn {
  width: 100%; height: 40px; border-radius: 4px; margin-top: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; font-weight: 600; font-size: 13.5px; letter-spacing: .3px;
  transition: transform .16s cubic-bezier(.16,1,.3,1), box-shadow .16s;
  box-shadow: 0 3px 10px rgba(27,111,224,.3);
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(27,111,224,.4); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.login-tip { margin-top: 16px; font-size: 11.5px; color: var(--text-3); text-align: center; line-height: 1.85; }
.login-err {
  margin-top: 12px; padding: 9px 12px; border-radius: 4px; font-size: 12px;
  background: var(--danger-bg); color: var(--danger); display: none;
}
.login-err.show { display: block; animation: shake .34s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* ==========================================================================
   主框架布局
   ========================================================================== */
#app { display: none; height: 100vh; }
#app.show { display: grid; grid-template-columns: var(--sidebar-w) 1fr; transition: grid-template-columns .18s ease; }
#app.mini { grid-template-columns: var(--sidebar-mini) 1fr; }

/* ---------- 侧边栏（窄栏 140px）---------- */
.sidebar {
  background: var(--sidebar-bg); display: flex; flex-direction: column;
  min-width: 0; overflow: hidden; position: relative; z-index: 30;
}
.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 8px;
  padding: 0 11px; flex-shrink: 0; border-bottom: 1px solid rgba(255,255,255,.07);
  white-space: nowrap; overflow: hidden;
}
.sidebar-brand .logo {
  width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
}
.sidebar-brand b { color: #fff; font-size: 13px; font-weight: 600; letter-spacing: .2px; }
.sidebar-brand .ver { font-size: 10px; color: #5B6B7C; margin-left: auto; }

.menu-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0 12px; }
.menu-scroll::-webkit-scrollbar { width: 4px; }
.menu-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 2px; }

.menu-group > .menu-head {
  display: flex; align-items: center; gap: 7px; padding: 7px 11px;
  color: var(--sidebar-text); font-size: 12px; cursor: pointer;
  transition: background .14s, color .14s; white-space: nowrap; overflow: hidden;
  user-select: none;
}
.menu-group > .menu-head:hover { background: var(--sidebar-hover); color: #fff; }
.menu-head .ico { width: 15px; height: 15px; flex-shrink: 0; opacity: .82; }
.menu-head .txt { flex: 1; font-weight: 500; }
.menu-head .arrow { width: 11px; height: 11px; opacity: .45; transition: transform .18s; flex-shrink: 0; }
.menu-group.open > .menu-head .arrow { transform: rotate(90deg); }
.menu-group.open > .menu-head { color: #fff; }

.menu-items { overflow: hidden; max-height: 0; transition: max-height .22s cubic-bezier(.16,1,.3,1); }
.menu-group.open .menu-items { max-height: 900px; }
.menu-item {
  display: flex; align-items: center; gap: 7px; padding: 5.5px 11px 5.5px 28px;
  color: var(--sidebar-text); font-size: 12.5px; cursor: pointer;
  transition: background .14s, color .14s; white-space: nowrap; overflow: hidden;
  position: relative;
}
.menu-item:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.active { background: rgba(76,154,255,.16); color: #fff; font-weight: 500; }
.menu-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--sidebar-active); border-radius: 0 2px 2px 0;
}
.menu-item.single { padding-left: 11px; }
.menu-item.single .ico { width: 15px; height: 15px; flex-shrink: 0; opacity: .82; }
.menu-item .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .45; flex-shrink: 0; }
.menu-item .txt { overflow: hidden; text-overflow: ellipsis; }

/* 折叠态 */
#app.mini .sidebar-brand { justify-content: center; padding: 0; }
#app.mini .sidebar-brand b, #app.mini .sidebar-brand .ver { display: none; }
#app.mini .menu-head { justify-content: center; padding: 9px 0; }
#app.mini .menu-head .txt, #app.mini .menu-head .arrow { display: none; }
#app.mini .menu-items { max-height: 0 !important; }
#app.mini .menu-item { justify-content: center; padding: 8px 0; }
#app.mini .menu-item .txt, #app.mini .menu-item .dot { display: none; }
#app.mini .menu-item.active::before { width: 3px; }

.sidebar-foot {
  flex-shrink: 0; padding: 8px 11px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 10.5px; color: #4C5C6D; white-space: nowrap; overflow: hidden;
}

/* ---------- 主区域 ---------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--surface);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 10px; padding: 0 12px; position: relative; z-index: 20;
}
.icon-btn {
  width: 28px; height: 28px; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; color: var(--text-2); transition: .14s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.crumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); min-width: 0; }
.crumb b { color: var(--text); font-weight: 600; font-size: 13px; }
.crumb .sep { opacity: .4; }

.top-search {
  margin-left: auto; position: relative; width: min(250px, 28vw);
}
.top-search input {
  width: 100%; height: 28px; padding: 0 10px 0 30px; border-radius: 3px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px;
  transition: .16s;
}
.top-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 2px var(--primary-50); }
.top-search .si { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }

.badge-dot {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 9.5px;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  border: 2px solid var(--surface);
}

.user-btn {
  display: flex; align-items: center; gap: 7px; padding: 3px 9px 3px 4px;
  border-radius: 14px; transition: .14s; flex-shrink: 0;
}
.user-btn:hover { background: var(--surface-2); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.user-btn .un { font-size: 12px; color: var(--text); max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 内容区 */
.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 14px 22px; min-width: 0; }
.page { animation: pageIn .22s cubic-bezier(.16,1,.3,1) both; min-width: 0; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; flex-wrap: wrap; }
.page-head h2 { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.page-head .sub { font-size: 12px; color: var(--text-3); }
.page-head .spacer { flex: 1; }

/* ==========================================================================
   组件：卡片 / 按钮 / 表单 / 表格
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 13px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card + .card { margin-top: 10px; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.card-head h3 { font-size: 13.5px; font-weight: 620; }
.card-head .spacer { flex: 1; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: .14s cubic-bezier(.16,1,.3,1); white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: var(--primary); color: var(--primary-600); background: var(--primary-50); }
.btn:active { transform: translateY(0); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  border-color: transparent; color: #fff; box-shadow: 0 2px 7px rgba(27,111,224,.26);
}
.btn-primary:hover { color: #fff; background: linear-gradient(135deg, var(--primary-600), var(--primary-700)); box-shadow: 0 4px 12px rgba(27,111,224,.34); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { color: #fff; background: #B7281F; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; box-shadow: none; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 3px; }
.btn-xs { height: 21px; padding: 0 6px; font-size: 11.5px; border-radius: 3px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-link { color: var(--primary-600); cursor: pointer; font-size: 12px; padding: 1px 4px; border-radius: 3px; }
.btn-link:hover { background: var(--primary-50); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { background: var(--danger-bg); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px 12px; }
.form-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.form-item label .req { color: var(--danger); margin-left: 2px; }
.inp, .sel, .textarea {
  width: 100%; height: 28px; padding: 0 9px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); transition: .14s; font-size: 12.5px;
}
.textarea { height: auto; min-height: 60px; padding: 6px 9px; resize: vertical; line-height: 1.55; }
.inp:focus, .sel:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-50);
}
.inp:disabled, .sel:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.inp.err, .sel.err { border-color: var(--danger); }
.sel { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B98A6' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px; padding-right: 26px; }
.inp[type="checkbox"] { width: auto; height: auto; }
.field-hint { font-size: 11px; color: var(--text-3); }
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 19px;
  transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(15px); }

/* 筛选栏 */
.filter-bar {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 9px;
}
.filter-bar .inp, .filter-bar .sel { width: auto; min-width: 125px; height: 27px; }
.filter-bar .inp.wide { min-width: 195px; }
.filter-bar .spacer { flex: 1; }

/* ==========================================================================
   表格 —— 全框线 + 高密度（核心）
   ========================================================================== */
.table-wrap {
  overflow: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); width: 100%; max-width: 100%;
}
.table-wrap.flex-h { max-height: calc(100vh - 250px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--table-fs); }
table.grid th, table.grid td {
  padding: var(--row-py) var(--row-px); text-align: left;
  border-right: 1px solid var(--border-2); border-bottom: 1px solid var(--border-2);
  white-space: nowrap; vertical-align: middle; line-height: 1.4;
}
table.grid th:last-child, table.grid td:last-child { border-right: none; }
table.grid th {
  background: var(--surface-2); color: var(--text-2); font-weight: 600;
  font-size: var(--table-head-fs); position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  white-space: nowrap;
}
table.grid th:last-child { border-right: none; }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:nth-child(even) { background: var(--zebra); }
table.grid tbody tr:hover, table.grid tbody tr:hover td { background: var(--primary-50); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.center, table.grid th.center { text-align: center; }
table.grid .empty-row td {
  padding: 0 !important; border-right: none; background: var(--surface); text-align: center;
}
.empty-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 26px 12px; }
.empty-cell .ec-ic { width: 30px; height: 30px; color: var(--text-3); opacity: .45; }
.empty-cell .ec-ic svg { width: 30px; height: 30px; }
.empty-cell .ec-t { font-size: 13px; color: var(--text-2); font-weight: 500; }
.empty-cell .ec-h { font-size: 11.5px; color: var(--text-3); }
table.grid td.wrap { white-space: normal; word-break: break-word; min-width: 130px; max-width: 300px; }
table.grid .ellip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
table.grid tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); }

/* 分页（紧贴表格下方） */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.pager .info { font-size: 12px; color: var(--text-3); }
.pager .spacer { flex: 1; }
.pager .pages { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.pager .pg {
  min-width: 25px; height: 25px; padding: 0 6px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; display: flex; align-items: center;
  justify-content: center; transition: .12s; color: var(--text-2);
}
.pager .pg:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-600); }
.pager .pg.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .pg:disabled { opacity: .4; cursor: not-allowed; }

/* 徽章 / 标签（方角，接近传统 ERP） */
.tag {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.tag.gray   { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-2); }
.tag.green  { background: var(--success-bg); color: var(--success); }
.tag.orange { background: var(--warning-bg); color: var(--warning); }
.tag.red    { background: var(--danger-bg);  color: var(--danger); }
.tag.blue   { background: var(--info-bg);    color: var(--info); }
.tag.cyan   { background: var(--primary-50); color: var(--primary-600); }
.tag.purple { background: var(--purple-bg);  color: var(--purple); }

/* ==========================================================================
   工作台
   ========================================================================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 11px; transition: .16s cubic-bezier(.16,1,.3,1); position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary); opacity: .85;
}
.kpi:hover { box-shadow: var(--shadow-md); border-color: var(--primary-200); }
.kpi .top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.kpi .ic {
  width: 22px; height: 22px; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; background: var(--primary-50); color: var(--primary-600); flex-shrink: 0;
}
.kpi .ic svg { width: 13px; height: 13px; }
.kpi .t { font-size: 11.5px; color: var(--text-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .n { font-size: 20px; font-weight: 680; letter-spacing: -.3px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .u { font-size: 11px; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.kpi .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.kpi.accent .ic { background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; }

.home-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; align-items: start; }
.home-grid .full { grid-column: 1 / -1; }

.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 7px; }
.shortcut {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  border-radius: var(--radius); border: 1px solid var(--border-2); background: var(--surface-2);
  cursor: pointer; transition: .16s cubic-bezier(.16,1,.3,1); text-align: center;
}
.shortcut:hover { background: var(--primary-50); border-color: var(--primary-200); }
.shortcut .ic {
  width: 28px; height: 28px; border-radius: 3px; background: var(--surface); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--border);
}
.shortcut .ic svg { width: 14px; height: 14px; }
.shortcut .t { font-size: 11.5px; color: var(--text-2); font-weight: 500; line-height: 1.3; }

.todo-item, .notice-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 7px 3px;
  border-bottom: 1px solid var(--border-2); cursor: pointer; transition: .12s;
}
.todo-item:last-child, .notice-item:last-child { border-bottom: none; }
.todo-item:hover, .notice-item:hover { background: var(--primary-50); border-radius: 3px; padding-left: 7px; }
.todo-item .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--warning); flex-shrink: 0; }
.todo-item .body { min-width: 0; flex: 1; }
.todo-item .ti { font-size: 12.5px; font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-item .tm { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex; align-items: center; gap: 9px; padding: 6px 3px;
  border-bottom: 1px solid var(--border-2); font-size: 12px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row .k { color: var(--text-2); flex-shrink: 0; }
.mini-row .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

.empty-box { text-align: center; padding: 26px 12px; color: var(--text-3); font-size: 12.5px; }
.empty-box svg { width: 30px; height: 30px; margin: 0 auto 8px; opacity: .35; }

/* ==========================================================================
   弹窗 / 提示
   ========================================================================== */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 33, .5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
  animation: fadeIn .16s both;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 580px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: modalIn .2s cubic-bezier(.16,1,.3,1) both;
  border: 1px solid var(--border);
}
.modal.wide { max-width: 900px; }
.modal.narrow { max-width: 410px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 15px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2);
}
.modal-head h3 { font-size: 13.5px; font-weight: 640; flex: 1; }
.modal-body { padding: 14px 15px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 15px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.modal-foot .spacer { flex: 1; }

.toast-wrap { position: fixed; top: 12px; right: 12px; z-index: 2000; display: flex; flex-direction: column; gap: 7px; max-width: 320px; }
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 4px;
  background: var(--surface); box-shadow: var(--shadow-md); border: 1px solid var(--border);
  font-size: 12.5px; animation: toastIn .22s cubic-bezier(.16,1,.3,1) both; line-height: 1.45;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
.toast.out { animation: toastOut .18s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast .ic { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.toast.success .ic { color: var(--success); }
.toast.error .ic { color: var(--danger); }
.toast.warn .ic { color: var(--warning); }
.toast.info .ic { color: var(--info); }
.toast .bar { position: absolute; }

/* 加载 */
.loading-box { display: flex; align-items: center; justify-content: center; padding: 46px 20px; gap: 10px; color: var(--text-3); font-size: 12.5px; }
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-2) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shine 1.4s ease infinite; border-radius: 3px;
}
@keyframes shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 描述列表 */
.desc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 14px; }
.desc-item { min-width: 0; }
.desc-item .k { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.desc-item .v { font-size: 12.5px; font-weight: 550; word-break: break-word; }

/* 标签页 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tab {
  padding: 7px 13px; font-size: 12.5px; color: var(--text-2); cursor: pointer; position: relative;
  transition: .14s; white-space: nowrap; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-600); font-weight: 600; }
.tab.active::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--primary); border-radius: 0;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 空态页 */
.blank-note {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 52px 24px; text-align: center; color: var(--text-3); gap: 10px;
}
.blank-note .ic {
  width: 44px; height: 44px; border-radius: 6px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
}
.blank-note .ic svg { width: 22px; height: 22px; }
.blank-note h3 { font-size: 14px; color: var(--text); font-weight: 600; }
.blank-note p { font-size: 12.5px; line-height: 1.7; max-width: 400px; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1280px) {
  .content { padding: 11px 12px 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px; }
  :root { --row-py: 3.5px; --row-px: 7px; }
}

@media (max-width: 1024px) {
  .top-search { width: 170px; }
  .user-btn .un { display: none; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 130px; }
  /* 侧栏改为抽屉 */
  #app, #app.mini { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 232px; z-index: 200;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.16,1,.3,1);
    box-shadow: var(--shadow-lg);
  }
  #app.drawer-open .sidebar { transform: translateX(0); }
  #app.drawer-open #drawer-mask { display: block; }
  #drawer-mask {
    display: none; position: fixed; inset: 0; background: rgba(15,23,33,.48);
    z-index: 190; animation: fadeIn .16s both;
  }
  #app.mini .sidebar-brand { justify-content: flex-start; padding: 0 11px; }
  #app.mini .sidebar-brand b, #app.mini .sidebar-brand .ver { display: block; }
  #app.mini .menu-head { justify-content: flex-start; padding: 7px 11px; }
  #app.mini .menu-head .txt, #app.mini .menu-head .arrow { display: block; }
  #app.mini .menu-item { justify-content: flex-start; padding: 5.5px 11px 5.5px 32px; }
  #app.mini .menu-item .txt, #app.mini .menu-item .dot { display: block; }
  .top-search { display: none; }
  .kpis { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .modal { max-width: 100%; }
  .filter-bar .inp, .filter-bar .sel { flex: 1; min-width: 0; }
}

@media (max-width: 560px) {
  .content { padding: 9px 9px 18px; }
  .topbar { padding: 0 9px; gap: 7px; }
  .crumb .sep, .crumb .history { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .kpi { padding: 8px 10px; }
  .kpi .n { font-size: 18px; }
  .shortcut-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .login-card { padding: 26px 20px 22px; }
  .modal-body { padding: 12px 12px; }
  .modal-head, .modal-foot { padding: 10px 12px; }
  .form-grid { grid-template-columns: 1fr; }
  table.grid th, table.grid td { padding: 4px 6px; }
}

/* 打印（表格样式与传统 ERP 一致，适合打印单据） */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .filter-bar, .pager, .btn, .icon-btn { display: none !important; }
  #app { display: block !important; grid-template-columns: none !important; height: auto; }
  .content { overflow: visible; padding: 0; }
  .card, .table-wrap { border-color: #999; box-shadow: none; break-inside: avoid; border-radius: 0; }
  table.grid th, table.grid td { white-space: normal; border-color: #999; padding: 5px 7px; }
  table.grid th { position: static; background: #eee; }
  .kpi { break-inside: avoid; }
}
