:root {
  --primary: #4c6fff;
  --primary-dark: #3b5bef;
  --primary-soft: #eef1ff;
  --danger: #f04452;
  --success: #12b76a;
  --warning: #f79009;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #7a86a1;
  --border: #e7eaf3;
  --sidebar1: #171d33;
  --sidebar2: #0d1122;
  --shadow-sm: 0 1px 3px rgba(26,34,51,.06);
  --shadow-md: 0 6px 20px rgba(26,34,51,.09);
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 212px; color: #9aa3c7;
  background: linear-gradient(175deg, var(--sidebar1) 0%, var(--sidebar2) 100%);
  position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 10;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 1px;
}
.logo::before {
  content: ""; width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #4c6fff, #7c9aff);
  box-shadow: 0 4px 12px rgba(76,111,255,.5);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2 3 7v10l9 5 9-5V7l-9-5zm0 2.3 6.5 3.6L12 11.5 5.5 7.9 12 4.3zM5 9.7l6 3.3v6.7l-6-3.3V9.7zm8 10v-6.7l6-3.3v6.7l-6 3.3z'/%3E%3C/svg%3E") center/22px no-repeat, linear-gradient(135deg, #4c6fff, #7c9aff);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2 3 7v10l9 5 9-5V7l-9-5zm0 2.3 6.5 3.6L12 11.5 5.5 7.9 12 4.3zM5 9.7l6 3.3v6.7l-6-3.3V9.7zm8 10v-6.7l6-3.3v6.7l-6 3.3z'/%3E%3C/svg%3E") center/22px no-repeat, linear-gradient(135deg, #4c6fff, #7c9aff);
}
.logo span {
  background: linear-gradient(90deg, #7c9aff, #56e0c8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sidebar nav { padding: 4px 12px 30px; }
.nav-group {
  padding: 18px 10px 7px; font-size: 11px; color: #525b82; letter-spacing: 2.5px; font-weight: 600;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; color: #9aa3c7; text-decoration: none; font-size: 14px;
  border-radius: 9px; transition: all .16s ease; position: relative;
}
.sidebar a i { font-style: normal; width: 20px; text-align: center; font-size: 15px; filter: grayscale(.3); }
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a:hover i { filter: none; }
.sidebar a.active {
  background: linear-gradient(90deg, var(--primary), #6c8bff);
  color: #fff; box-shadow: 0 4px 14px rgba(76,111,255,.45);
}
.sidebar a.active i { filter: none; }

/* ===== 主区域 ===== */
.main { flex: 1; margin-left: 212px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255,255,255,.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 0 26px; height: 60px; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; }
.topbar h2::before {
  content: ""; display: inline-block; width: 4px; height: 17px; border-radius: 2px;
  background: linear-gradient(180deg, var(--primary), #7c9aff);
  margin-right: 10px;
}
.topbar-right { color: var(--muted); font-size: 13px; display: flex; align-items: center; }
.view { padding: 24px 26px; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 5px 13px 5px 6px; border-radius: 99px; font-size: 13px; font-weight: 500;
}
.user-chip::before {
  content: "👤"; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c9aff);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}

/* ===== 卡片与面板 ===== */
.card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card h3 { font-size: 15px; margin-bottom: 16px; font-weight: 600; display: flex; align-items: center; }
.card h3::before {
  content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--primary); margin-right: 8px; opacity: .8;
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative;
  display: flex; align-items: center; gap: 14px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat .ic {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat .ic.blue { background: #e8edff; }
.stat .ic.green { background: #dcf7e9; }
.stat .ic.orange { background: #ffefd6; }
.stat .ic.red { background: #ffe2e5; }
.stat .ic.purple { background: #efe6ff; }
.stat .ic.cyan { background: #dcf3f7; }
.stat .txt { min-width: 0; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.stat .value.blue { color: var(--primary); }
.stat .value.green { color: var(--success); }
.stat .value.red { color: var(--danger); }
.stat .value.orange { color: var(--warning); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

/* ===== 工具条 ===== */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
input[type="search"], input[type="text"], input[type="number"], input[type="date"], select, textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #c6cfE6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(76,111,255,.15);
}

button {
  padding: 8px 18px; border: none; border-radius: 9px; font-size: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #6c8bff); color: #fff;
  font-family: inherit; font-weight: 500; box-shadow: 0 3px 8px rgba(76,111,255,.3);
  transition: all .16s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(76,111,255,.4); }
button:active { transform: translateY(0); }
button.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--border); box-shadow: none;
}
button.ghost:hover { background: #f6f8fd; border-color: #c6cfe6; box-shadow: var(--shadow-sm); }
button.danger { background: linear-gradient(135deg, var(--danger), #f56673); box-shadow: 0 3px 8px rgba(240,68,82,.3); }
button.danger:hover { box-shadow: 0 5px 14px rgba(240,68,82,.4); }
button.sm { padding: 4px 12px; font-size: 13px; border-radius: 7px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  color: var(--muted); font-weight: 600; font-size: 12px; background: #f7f9fd;
  letter-spacing: .5px;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f5f8ff; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.warn-row td { background: #fff7ed; }
tr.warn-row:hover td { background: #ffefd9; }
.empty { text-align: center; color: var(--muted); padding: 38px 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.tag { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.tag.green { background: #d9f6e6; color: #087a44; }
.tag.red { background: #ffe0e3; color: #c02230; }
.tag.blue { background: #e0e7ff; color: #3450c0; }
.tag.gray { background: #e9ecf4; color: #5a6480; }
.tag.orange { background: #ffeccf; color: #9a5e06; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(18,23,42,.48); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto; animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 18px; width: 560px; max-width: 100%;
  box-shadow: 0 26px 64px rgba(13,17,34,.32); animation: popIn .22s cubic-bezier(.2,.9,.3,1.15);
}
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(12px); } to { opacity: 1; } }
.modal.wide { width: 900px; }
.modal-head {
  padding: 17px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: #f1f4fb; color: var(--muted); font-size: 15px; width: 30px; height: 30px;
  border-radius: 50%; padding: 0; box-shadow: none; line-height: 1;
}
.modal-close:hover { color: var(--text); background: #e3e8f5; box-shadow: none; transform: none; }
.modal-body { padding: 24px; max-height: 65vh; overflow-y: auto; }
.modal-foot { padding: 15px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 56px; }

/* ===== 单据明细 ===== */
.items-table input { width: 100%; padding: 6px 8px; }
.items-table .col-product { min-width: 220px; }
.items-table .col-unit { width: 76px; }
.items-table .col-unit select { padding: 6px 4px; }
.items-table .col-qty { width: 90px; }
.items-table .col-price { width: 110px; }
.items-table .col-amount { width: 100px; }
.order-summary {
  display: flex; gap: 18px; align-items: center; justify-content: flex-end;
  padding-top: 14px; font-size: 14px; flex-wrap: wrap;
}
.order-summary .total { font-size: 20px; font-weight: 700; color: var(--primary); }
.order-summary input { width: 100px; }

/* ===== 图表 ===== */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 190px; padding-top: 10px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bar {
  width: 68%; max-width: 46px; background: linear-gradient(180deg, #8ba2ff, var(--primary));
  border-radius: 7px 7px 0 0; min-height: 2px; position: relative;
  transition: filter .15s, transform .15s;
}
.bar:hover { filter: brightness(1.12); transform: scaleY(1.02); transform-origin: bottom; }
.bar .v { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-label { font-size: 12px; color: var(--muted); }

/* ===== Toast ===== */
#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; }
.toast {
  background: #1a2233; color: #fff; padding: 11px 24px; border-radius: 11px;
  margin-bottom: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.3); animation: slideIn .22s ease;
  font-size: 14px;
}
.toast.error { background: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none; color: var(--muted); border-radius: 9px 9px 0 0; padding: 9px 18px;
  border-bottom: 2px solid transparent; box-shadow: none; font-weight: 500;
}
.tabs button:hover { color: var(--text); background: none; transform: none; box-shadow: none; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ===== 分页条 ===== */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 15px 0 2px; border-top: 1px solid var(--border); margin-top: 10px;
}
.pager-info { font-size: 13px; color: var(--muted); }

/* ===== 新增用户表单（专用，不影响通用弹窗） ===== */
.uform { max-width: 400px; margin: 0 auto; }
.uform-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  padding: 14px; background: linear-gradient(135deg, #eef1ff, #e6f9f0); border-radius: 12px; }
.uform-avatar { width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c9aff);
  color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.uform-head b { font-size: 15px; }
.uform-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.uf-field { display: block; margin-bottom: 14px; }
.uf-field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.uf-field input { width: 100%; padding: 10px 12px; border-radius: 9px; box-sizing: border-box; }
.uf-pwd { position: relative; }
.uf-pwd input { padding-right: 42px; }
.uf-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; opacity: .55; box-shadow: none; }
.uf-eye:hover { opacity: 1; transform: translateY(-50%); box-shadow: none; }
.uf-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.uf-role { border: 2px solid var(--border); border-radius: 11px; padding: 12px;
  cursor: pointer; transition: all .15s; }
.uf-role b { display: block; font-size: 14px; margin-bottom: 4px; }
.uf-role small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.uf-role:hover { border-color: #a5b6ff; }
.uf-role.active { border-color: var(--primary); background: var(--primary-soft); }

/* ===== 商品表格 ===== */
.p-table .p-name { font-weight: 600; color: var(--text); }
.p-table .p-code { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.p-table .p-none { color: #b0b8cc; font-size: 13px; }
.p-table .p-cost { color: var(--muted); }
.p-table .p-sale { color: var(--primary); font-weight: 600; }
.p-table .p-stock { display: inline-block; min-width: 46px; padding: 2px 9px; border-radius: 7px;
  background: #eafbf1; color: #0a7a42; font-weight: 600; }
.p-table .p-stock.low { background: #fff1dc; color: #b25f00; }
.p-table .p-stock.out { background: #ffe2e5; color: #c02230; }
.p-table .ops-col { width: 130px; }
.p-table .ops-col button + button { margin-left: 6px; }
.p-table td { vertical-align: middle; }

/* ===== 多标签页 ===== */
.tabbar { display: flex; gap: 6px; padding: 10px 18px 0;
  border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 7px 15px;
  background: #eaedf6; border: 1px solid var(--border); border-bottom: none;
  border-radius: 9px 9px 0 0; font-size: 13px; cursor: pointer; white-space: nowrap;
  color: var(--muted); user-select: none; transition: all .15s; }
.tab:hover { background: #f2f4fb; color: var(--text); }
.tab.active { background: #fff; color: var(--primary); font-weight: 600; position: relative; }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: #fff; }
.tab { position: relative; }
.tab-x { font-style: normal; font-size: 15px; line-height: 1; padding: 0 3px;
  border-radius: 50%; color: var(--muted); }
.tab-x:hover { background: #ccd4e8; color: var(--text); }
