:root {
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --ink: #2b2118;
  --muted: #8a7d6c;
  --line: #e8dfd0;
  --brand: #d97724;
  --brand-dark: #a8530f;
  --brand-soft: #f7e7d2;
  --ok: #2e8b57;
  --warn: #c98a2d;
  --danger: #c2453d;
  --info: #3e6fa8;
  --dark: #241a12;
  --shadow: 0 2px 12px rgba(43, 33, 24, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: 76px;
}
a { color: var(--brand-dark); text-decoration: none; }
h1, h2, h3 { line-height: 1.3; }
h2 { font-size: 21px; margin: 18px 0 12px; letter-spacing: .5px; }
h3 { font-size: 16px; margin: 18px 0 10px; color: #3d3022; }
.muted { color: var(--muted); font-size: 13px; }
.muted-sm { color: var(--muted); font-size: 12px; }
.center { text-align: center; }
.hidden { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff;
  font-size: 15px; font-weight: 800;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.logo-lg { width: 52px; height: 52px; font-size: 26px; border-radius: 15px; }
.userbox { display: flex; align-items: center; gap: 8px; }
.uname { font-size: 13px; color: var(--muted); }
.role-badge { font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.role-boss { background: var(--brand-soft); color: var(--brand-dark); }
.role-wh { background: #e6eef7; color: var(--info); }
.inline { display: inline; }

.topnav {
  display: none;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 10px; gap: 4px; overflow-x: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; color: var(--muted); font-size: 14px;
  white-space: nowrap; border-bottom: 3px solid transparent;
}
.nav-item.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 700; }
.nav-ico { font-size: 16px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -3px 14px rgba(43,33,24,.07);
}
.bottomnav .nav-item {
  flex: 1 0 auto; flex-direction: column; gap: 2px;
  padding: 8px 10px; font-size: 11px; border-bottom: none;
  border-radius: 10px; margin: 4px 2px;
}
.bottomnav .nav-item.active { background: var(--brand-soft); }
.bottomnav .nav-ico { font-size: 20px; }

.container { max-width: 980px; margin: 0 auto; padding: 8px 14px 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 10px; }
.page-head h2 { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.doc-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 15px; margin: 10px 0; box-shadow: var(--shadow);
}
.doc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.doc-meta { color: var(--muted); font-size: 12px; }
.doc-body .line { padding: 3px 0; }
.cost-line { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--brand-dark); font-size: 13px; }
.note { margin-top: 6px; }

.grid-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 12px 0; }
.stat-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 12px 12px; text-align: center; box-shadow: var(--shadow);
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand), #e9a14d);
}
.stat-num { font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat-link { font-size: 12px; }
.quick-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 8px; color: var(--ink); font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.quick-card:active { transform: scale(.97); }
.quick-ico {
  font-size: 28px; width: 54px; height: 54px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft);
}
.card-link {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 15px; color: var(--ink); box-shadow: var(--shadow);
}
.card-link-title { font-weight: 700; margin-bottom: 4px; color: var(--brand-dark); }
.empty-guide ol { margin: 6px 0 8px 20px; padding: 0; }
.empty-guide li { margin: 3px 0; }
.stock-summary {
  background: var(--brand-soft); border: 1px solid #f0d5b3; border-radius: 12px;
  padding: 10px 12px; font-size: 13px; margin: 10px 0; color: var(--brand-dark); font-weight: 600;
}
.sticky-save { position: sticky; bottom: 82px; z-index: 5; background: var(--bg); padding: 10px 0 4px; border-radius: 12px; }
.btn-lg { padding: 13px 22px; font-size: 16px; border-radius: 12px; width: 100%; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 5px 13px; font-size: 13px; box-shadow: var(--shadow); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #6b5d4b; margin-bottom: 4px; font-weight: 600; }
.field label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); font-weight: 400; }
input, select, textarea {
  width: 100%; padding: 10px 11px; font-size: 15px;
  border: 1.5px solid #ddd2c0; border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(217,119,36,.15); }
input[type="checkbox"] { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { max-width: 220px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid #ddd2c0; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; cursor: pointer; font-family: inherit;
  font-weight: 600;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.btn-danger { color: var(--danger); border-color: #ecc9c4; background: #fff7f5; }
.btn-ghost { border: none; background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: #e1f2e8; color: var(--ok); }
.badge-warn { background: #fbeeda; color: var(--warn); }
.badge-danger { background: #fbe4e2; color: var(--danger); }
.badge-info { background: #e5edf7; color: var(--info); }
.badge-muted { background: #efebe2; color: var(--muted); }
.warn-text { color: var(--warn); font-size: 12px; }

.alert { padding: 11px 14px; border-radius: 12px; margin: 10px 0; font-size: 14px; }
.alert-err { background: #fbe4e2; color: var(--danger); border: 1px solid #f0c4be; }
.alert-ok { background: #e1f2e8; color: var(--ok); border: 1px solid #bcddca; }
.alert-info { background: #e5edf7; color: var(--info); border: 1px solid #cbdced; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 10px 0; }
.filter-bar select { width: auto; min-width: 130px; }
.filter-bar input { width: auto; }
.filter-bar label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

.tbl { overflow-x: auto; margin: 8px 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
th, td { padding: 10px 11px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fbf7ef; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: none; }

.row-tpl { display: none; }
.row-line {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: #fbf7ef; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; margin: 8px 0;
}
.row-line .row-product { grid-column: 1 / -1; }
.row-line .row-del { grid-column: 1 / -1; width: 100%; }
.date-lbl { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.date-lbl input { padding: 7px 8px; font-size: 13px; }

.pricing-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.pricing-row:last-child { border-bottom: none; }
.pricing-info { flex: 1 1 220px; }
.pricing-form { display: flex; gap: 8px; align-items: center; }
.pricing-form input { width: 140px; }

.batch-line { font-size: 12px; color: var(--muted); padding: 2px 0; }
.mini summary { cursor: pointer; color: var(--brand-dark); font-size: 13px; font-weight: 600; }
.mini { margin-top: 4px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(155deg, #241a12 0%, #4a3017 55%, #7c3f12 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 22px; padding: 32px 26px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.login-logo { margin-bottom: 12px; }
.login-card h1 { margin: 0 0 4px; color: var(--brand-dark); font-size: 24px; letter-spacing: 1px; }
.login-card .muted { margin-bottom: 20px; }

@media (min-width: 900px) {
  .topnav {
    position: fixed; left: 0; top: 0; bottom: 0; width: 190px;
    display: flex; flex-direction: column; gap: 2px;
    background: var(--dark); border: none;
    padding: 76px 12px 20px; overflow-y: auto;
  }
  .topnav .nav-item {
    color: #c9b7a1; border-bottom: none; border-radius: 11px;
    padding: 12px 13px; margin: 2px 0;
  }
  .topnav .nav-item.active { background: rgba(217,119,36,.2); color: #ffd9a8; }
  .app { padding-left: 190px; }
  .bottomnav { display: none; }
  body { padding-bottom: 20px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-cards { grid-template-columns: repeat(4, 1fr); }
  .row-line { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .row-line .row-product { grid-column: auto; }
  .row-line .row-del { grid-column: auto; width: auto; }
  .container { padding-top: 14px; }
  .sticky-save { position: static; padding: 0; background: transparent; }
  .btn-lg { width: auto; }
}
