/* ============================================================
   WLS ERP — 界面样式
   浅色商务风：深色侧边栏 + 浅灰内容区，弱边框 + 低饱和色块
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #6b7a90;
  --line: #e5eaf3;
  --line-2: #eef2f8;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eaf1ff;
  --green: #0f9d6e;
  --green-soft: #e6f7f1;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --violet: #6d4aff;
  --violet-soft: #efeaff;
  --side: #0e1a2b;
  --side-2: #16253a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.2px; }
::selection { background: #cfe0ff; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b6c2d6; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------ 登录页 ------------------------------ */
.login-wrap { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }

.login-brand {
  position: relative;
  padding: 64px 56px;
  color: #e8eefb;
  background: radial-gradient(1200px 600px at 10% 10%, #1e3a8a 0%, #0e1a2b 55%, #0a1524 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  right: -180px; bottom: -220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, .38), transparent 62%);
}
.login-brand .brand-mark { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 600; letter-spacing: .4px; }
.login-brand h1 { font-size: 40px; line-height: 1.25; margin: 0 0 18px; color: #fff; letter-spacing: -.6px; }
.login-brand p.lead { color: #9fb2cd; max-width: 430px; margin: 0 0 34px; font-size: 15px; }
.login-feats { display: grid; gap: 14px; position: relative; z-index: 1; }
.login-feats div { display: flex; gap: 10px; align-items: flex-start; color: #c4d3e8; font-size: 13.5px; }
.login-feats i { color: #6ea8ff; font-style: normal; }
.login-foot { color: #6b81a0; font-size: 12px; position: relative; z-index: 1; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 28px; font-size: 13px; }
.login-tip {
  margin-top: 22px; padding: 12px 14px; border-radius: 10px;
  background: #f6f8fc; border: 1px dashed #dbe3ef; color: #63708a; font-size: 12.5px;
}
.login-tip b { color: #334155; }

/* ------------------------------ 通用控件 ------------------------------ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #9dbcff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.textarea { resize: vertical; min-height: 72px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7a90' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; font-size: 13px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d5e6; background: #fbfcfe; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { color: var(--red); border-color: #f6d5d5; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px 14px; font-size: 14px; }

/* ------------------------------ 布局 ------------------------------ */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0e1a2b 0%, #0b1523 100%);
  color: #c7d3e5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #0a1220;
}
.side-head { padding: 20px 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side-logo {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 32px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .5px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.side-title { line-height: 1.2; }
.side-title b { color: #fff; font-size: 14px; display: block; letter-spacing: .3px; }
.side-title span { font-size: 11px; color: #6d8099; letter-spacing: .5px; }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.side-nav::-webkit-scrollbar-thumb { background: #24344c; background-clip: content-box; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 10.5px; letter-spacing: 1.2px; color: #55677f; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 2px 0; border-radius: 8px;
  color: #b6c4d8; font-size: 13.5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 16px; height: 16px; opacity: .85; flex: 0 0 16px; }
.nav-item:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-item.active { background: #1d3150; color: #fff; box-shadow: inset 2px 0 0 #4b8bff; }
.nav-item .dot { margin-left: auto; background: #ef4444; color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; line-height: 16px; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; cursor: pointer; }
.user-chip:hover { background: rgba(255,255,255,.05); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  background: #24374f; color: #9dc0ff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}
.user-chip .u-name { color: #e8eefb; font-size: 13px; line-height: 1.2; }
.user-chip .u-role { color: #6d8099; font-size: 11px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.crumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.crumb b { color: var(--ink); font-weight: 600; font-size: 13.5px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.chip-role { font-size: 11.5px; color: #475569; background: #f1f5f9; border-radius: 20px; padding: 3px 10px; }

.content { padding: 24px 26px 44px; max-width: 1480px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

/* ------------------------------ 卡片 / KPI ------------------------------ */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { font-size: 14px; }
.card-head .sub { color: var(--muted); font-size: 11.5px; font-weight: 400; margin-top: 2px; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 8px 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi-grid.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1180px) { .kpi-grid.five { grid-template-columns: repeat(3, 1fr); } }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 25px; font-weight: 650; letter-spacing: -.8px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .foot { margin-top: 8px; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi .ico {
  position: absolute; right: 14px; top: 14px; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.kpi.green .ico { background: var(--green-soft); color: var(--green); }
.kpi.amber .ico { background: var(--amber-soft); color: var(--amber); }
.kpi.violet .ico { background: var(--violet-soft); color: var(--violet); }
.up { color: var(--red); } /* 中式配色：增长为红 */
.down { color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; }

/* ------------------------------ 表格 ------------------------------ */
.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 10px 14px; background: #fafcff; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0;
}
table.tb td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tb tbody tr:hover { background: #fafcff; }
table.tb tbody tr:last-child td { border-bottom: none; }
table.tb .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tb .mono { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.t-main { font-weight: 500; color: var(--ink); }
.t-sub { color: var(--muted); font-size: 11.5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 20px;
  background: #f1f5f9; color: #475569; white-space: nowrap;
}
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.green { background: var(--green-soft); color: #0b7a57; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: #52627a; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.toolbar .grow { flex: 1; }
.search-box { position: relative; min-width: 210px; }
.search-box input { padding-left: 32px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #94a3b8; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tab {
  padding: 11px 12px; font-size: 13px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; color: var(--muted); font-size: 12.5px; gap: 10px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; opacity: .5; margin-bottom: 8px; }

/* ------------------------------ 弹窗 ------------------------------ */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 16px; z-index: 100; overflow-y: auto;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
  animation: pop .18s ease; overflow: hidden;
}
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1040px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 20px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: #fbfcfe; }
.x-close { border: none; background: none; font-size: 20px; line-height: 1; color: #94a3b8; cursor: pointer; padding: 0 4px; }
.x-close:hover { color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* 订单明细编辑 */
.items-editor { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.items-editor table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items-editor th { background: #f8fafd; color: var(--muted); font-weight: 500; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.items-editor td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.items-editor .input, .items-editor .select { padding: 6px 8px; font-size: 12.5px; border-radius: 7px; }
.items-editor tfoot td { background: #fbfcfe; font-weight: 600; border-bottom: none; padding: 10px; }
.line-del { color: #94a3b8; cursor: pointer; border: none; background: none; font-size: 15px; }
.line-del:hover { color: var(--red); }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.detail-grid .k { color: var(--muted); font-size: 11.5px; }
.detail-grid .v { font-size: 13.5px; font-weight: 500; margin-top: 2px; word-break: break-all; }

.timeline { border-left: 2px solid var(--line); padding-left: 14px; }
.timeline .t-item { position: relative; padding-bottom: 14px; font-size: 12.5px; }
.timeline .t-item::before {
  content: ""; position: absolute; left: -20px; top: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: #cbd5e1; border: 2px solid #fff;
}
.timeline .t-item.on::before { background: var(--brand); }
.timeline .t-time { color: var(--muted); font-size: 11.5px; }

/* ------------------------------ 图表 ------------------------------ */
.chart-box { width: 100%; }
.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

.bar-line { display: grid; gap: 10px; }
.bar-line .bl-row { display: grid; grid-template-columns: 1fr 64px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-line .bl-track { background: #f1f5f9; border-radius: 6px; height: 8px; overflow: hidden; grid-column: 1; }
.bar-line .bl-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.bar-line .bl-label { display: flex; justify-content: space-between; grid-column: 1; font-size: 12px; margin-bottom: -4px; }
.bar-line .bl-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ------------------------------ 提示 ------------------------------ */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; }
.toast {
  min-width: 240px; max-width: 380px; background: #0f172a; color: #e8eefb;
  padding: 11px 14px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 12px 30px -8px rgba(15, 23, 42, .45);
  animation: pop .18s ease; display: flex; gap: 8px; align-items: flex-start;
}
.toast.ok { background: #0b3b2e; color: #d1fae5; }
.toast.err { background: #4c1111; color: #fee2e2; }

.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid #dbe3ef; border-top-color: var(--brand);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  display: flex; gap: 8px; align-items: flex-start;
  background: #fffaf0; border: 1px solid #f6e3bd; color: #8a5a0b;
  padding: 10px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 14px;
}
.notice.blue { background: #f4f8ff; border-color: #d7e5ff; color: #1e40af; }

.muted { color: var(--muted); }
.mono-num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hidden { display: none !important; }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 232px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
