/* 衡山精工 · 经营管理 ERP
   与 cottonshoes.cn 后台同一套色板：陶土红 + 深棕 + 米白。
   ERP 的信息密度更高，所以表格更紧、数字全部等宽对齐。 */

:root {
  --brand: #B85E30;
  --brand-600: #A34F26;
  --brand-700: #853C18;
  --brand-050: #FBF1E9;
  --ink: #2B1E17;
  --ink-2: #574840;
  --muted: #8A7970;
  --line: #ECE2D8;
  --line-2: #F4ECE4;
  --bg: #FAF6F0;
  --card: #fff;
  --danger: #C0392B;
  --ok: #2F7A5A;
  --warn: #B26A00;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --num: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.3; }
p { margin: 0; }

/* ---------------- 登录 ---------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 50% -12%, rgba(184, 94, 48, .3), transparent 62%),
    #241A14;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 38px 34px 30px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .38);
}

.login-card .mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #C96B38, #8E4118);
  color: #fff; font-weight: 700; font-size: 18px;
  margin-bottom: 16px;
}

.login-card h1 { font-size: 1.3rem; letter-spacing: .01em; }
.login-card .sub { color: var(--muted); font-size: .86rem; margin: 6px 0 26px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------------- 布局 ---------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: none;
  background: var(--ink);
  color: rgba(255, 255, 255, .68);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 0 12px;
}

.sidebar .logo {
  display: block;
  padding: 0 20px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .02em;
}
.sidebar .logo small {
  display: block;
  color: rgba(255, 255, 255, .38);
  font-weight: 400;
  font-size: .72rem;
  letter-spacing: .08em;
  margin-top: 2px;
}

.nav-group {
  padding: 16px 20px 6px;
  font-size: .68rem;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .3);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 20px;
  color: rgba(255, 255, 255, .7);
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav a.is-active {
  background: rgba(184, 94, 48, .18);
  border-left-color: var(--brand);
  color: #fff;
  font-weight: 600;
  padding-left: 17px;
}
.sidebar nav a .badge {
  background: var(--brand);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 0 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar .foot {
  margin-top: auto;
  padding: 14px 20px 4px;
  font-size: .72rem;
  color: rgba(255, 255, 255, .3);
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.12rem; }
.topbar .sub { font-size: .78rem; color: var(--muted); }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: .84rem; color: var(--muted); }

.content { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2 { font-size: .95rem; letter-spacing: .01em; }
.card-head .sub { font-size: .76rem; color: var(--muted); }
.card-head .grow { margin-left: auto; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------------- KPI ---------------- */

.kpi-band {
  background: linear-gradient(160deg, #2B1E17, #3A2A20 60%, #2B1E17);
  border-radius: 14px;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  color: #F6EFE8;
  position: relative;
  overflow: hidden;
}
.kpi-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(115deg, rgba(0,0,0,.85), transparent 65%);
  pointer-events: none;
}
.kpi { padding: 0 20px; border-left: 1px solid rgba(255,255,255,.1); position: relative; z-index: 1; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi span { display: block; font-size: .72rem; letter-spacing: .08em; color: #B49C8C; }
.kpi strong {
  display: block;
  font-family: var(--num);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.kpi em { display: block; font-style: normal; font-size: .72rem; color: #A08B7C; margin-top: 4px; }
.kpi em.up { color: #7FC7A6; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: .88rem; background: #fff; }
table.data th {
  text-align: left;
  padding: 9px 14px;
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .02em;
  color: var(--muted);
  background: #FCF8F3;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #FDFAF6; }
table.data tfoot td { background: #FCF8F3; font-weight: 600; border-top: 1px solid var(--line); }

.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.strong { color: var(--ink); font-weight: 600; }
.nowrap { white-space: nowrap; }
.cell-sub { display: block; font-size: .74rem; color: var(--muted); }

/* ---------------- 状态 ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  border-radius: 20px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--line-2);
  color: var(--muted);
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.draft { background: #F1EDE8; color: #7A6A60; }
.pill.confirmed { background: #E9F3EE; color: var(--ok); }
.pill.void { background: #FBECEA; color: var(--danger); }
.pill.low { background: #FFF3E0; color: var(--warn); }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1.5px solid transparent;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease;
}
.btn:hover { background: var(--brand-600); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-700); background: #fff; }
.btn-danger { background: #fff; border-color: #EBCDC9; color: var(--danger); }
.btn-danger:hover { background: #FBECEA; color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brand-700);
  font: inherit;
  font-size: .84rem;
  cursor: pointer;
}
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------------- 工具条 ---------------- */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

.search {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.search input {
  border: 0;
  outline: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: .88rem;
  min-width: 210px;
  background: none;
}
.search button {
  border: 0;
  background: none;
  padding: 8px 13px;
  color: var(--muted);
  font: inherit;
  font-size: .84rem;
  cursor: pointer;
  border-left: 1px solid var(--line);
}
.search button:hover { color: var(--brand-700); }

.select {
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  font: inherit;
  font-size: .88rem;
  background: #fff;
  color: var(--ink-2);
}

.seg { display: inline-flex; background: #F1E9E0; border-radius: 9px; padding: 3px; gap: 2px; }
.seg a {
  padding: 5px 13px;
  border-radius: 7px;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 500;
}
.seg a.is-on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(43,30,23,.08); }

/* ---------------- 表单 ---------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.form-grid .full { grid-column: 1 / -1; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field input[type=text], .field input[type=password], .field input[type=number],
.field input[type=date], .field input[type=email], .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: .9rem;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(184, 94, 48, .12);
}
.field textarea { min-height: 74px; resize: vertical; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.field .err { font-size: .78rem; color: var(--danger); margin-top: 4px; }

.check { display: flex; align-items: center; gap: 7px; margin: 4px 0 14px; }
.check label { margin: 0; font-weight: 500; font-size: .86rem; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}
.form-actions .grow { flex: 1; }

/* ---------------- 明细编辑器 ---------------- */

.lines { width: 100%; border-collapse: collapse; font-size: .86rem; }
.lines th {
  text-align: left;
  padding: 8px 8px;
  font-size: .74rem;
  color: var(--muted);
  background: #FCF8F3;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.lines td { padding: 5px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.lines select, .lines input {
  width: 100%;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 7px;
  padding: 6px 8px;
  font: inherit;
  font-size: .86rem;
}
.lines select:hover, .lines input:hover { border-color: var(--line); }
.lines select:focus, .lines input:focus { outline: none; border-color: var(--brand); }
.lines .col-qty { width: 96px; }
.lines .col-price { width: 110px; }
.lines .col-amount { width: 110px; text-align: right; font-family: var(--num); }
.lines .col-del { width: 34px; text-align: center; }
.lines td:first-child { width: 58%; }
.lines select.js-product { max-width: 560px; }
.lines tfoot td { padding: 10px 8px; border-top: 1px solid var(--line); font-weight: 600; }

.line-del {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.line-del:hover { background: #FBECEA; color: var(--danger); }

/* ---------------- 图表 ---------------- */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--num); font-size: 9px; fill: #A08B7C; }

/* ---------------- 排行 ---------------- */

.rank { display: flex; flex-direction: column; gap: 11px; }
.rank-item { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.rank-item .label { font-size: .84rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item .value { font-family: var(--num); font-size: .82rem; color: var(--muted); }
.rank-track { display: block; grid-column: 1 / -1; height: 5px; border-radius: 999px; background: #F2E9E0; overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #C96B38, #9C4A20); }

/* ---------------- 空态 / 提示 ---------------- */

.empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: .88rem; }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; font-weight: 600; }

.flash {
  padding: 11px 15px;
  border-radius: 9px;
  font-size: .86rem;
  background: #FBF1E9;
  border-left: 3px solid var(--brand);
  color: var(--ink);
}
.flash.ok { background: #EDF6F1; border-left-color: var(--ok); }
.flash.error { background: #FBECEA; border-left-color: var(--danger); }

/* ---------------- 备注 ---------------- */

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
}

.note-head { display: flex; align-items: center; gap: 8px; }
.note-head .grow { flex: 1; }

.note-date {
  font-family: var(--num);
  font-size: .76rem;
  color: var(--brand-700);
  background: var(--brand-050);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}

.note-title { font-size: .98rem; font-weight: 600; line-height: 1.45; }

.note-body {
  font-size: .86rem;
  color: var(--ink-2);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.note-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: .74rem;
  color: var(--muted);
}

.note-mini { display: flex; flex-direction: column; }
.note-mini .row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line-2);
}
.note-mini .row:last-child { border-bottom: 0; }
.note-mini .row time { font-family: var(--num); font-size: .74rem; color: var(--muted); flex: none; }
.note-mini .row span { font-size: .86rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field.note-content textarea { min-height: 260px; }

/* ---------------- 分页 ---------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-2);
  font-size: .82rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.pager .grow { flex: 1; }
.pager a, .pager span.cur {
  min-width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 8px;
  color: var(--ink-2);
  background: #fff;
}
.pager a:hover { border-color: var(--brand); color: var(--brand-700); }
.pager span.cur { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 详情 ---------------- */

.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.doc-no { font-family: var(--num); font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.doc-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.doc-meta div span { display: block; font-size: .74rem; color: var(--muted); }
.doc-meta div strong { font-weight: 600; color: var(--ink); font-size: .9rem; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 12px 0 8px; }
  .sidebar .logo { padding-bottom: 10px; margin-bottom: 4px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar nav a { padding: 6px 12px; border-left: 0; border-bottom: 2px solid transparent; }
  .sidebar nav a.is-active { border-bottom-color: var(--brand); padding-left: 12px; }
  .nav-group, .sidebar .foot { display: none; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 11px 14px; position: static; }
  .kpi-band { grid-template-columns: 1fr 1fr; gap: 16px 0; padding: 16px; }
  .kpi:nth-child(3) { border-left: 0; padding-left: 0; }
  .kpi strong { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
