/* tea.ya1om.com — 茶叶私域 库存 & 客户 demo。简约清晰：白底、细线、一种茶绿强调色 */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --line: #e4e4df;
  --line-strong: #cfcfc8;
  --text: #1f2421;
  --muted: #6d746f;
  --faint: #9a9f9b;
  --accent: #3b7a5a;
  --accent-soft: #e7f1ec;
  --accent-ink: #2b5c43;
  --danger: #c2452d;
  --danger-soft: #fbeae6;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --info-soft: #e9eef6;
  --info: #3c5a8a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 20px rgba(20, 30, 25, .06);
  --sidebar: 220px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.brand .name { font-weight: 600; font-size: 15px; }
.brand .sub { font-size: 11px; color: var(--faint); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.nav button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button:hover { background: var(--bg); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav .badge { margin-left: auto; font-size: 11px; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }
.sidebar .foot { margin-top: auto; font-size: 11px; color: var(--faint); padding: 0 8px; line-height: 1.6; }

.main { flex: 1; min-width: 0; padding: 26px 32px 80px; max-width: 1180px; }
.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: 22px; }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 基础组件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { border-color: #b8b8b0; background: #fafaf8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #e6b3a8; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card .card-head h3 { font-size: 14px; }
.card .card-body { padding: 14px 16px; }
.card .empty { color: var(--faint); text-align: center; padding: 22px 0; font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.kpi:hover { border-color: var(--line-strong); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.5px; }
.kpi .value.warn { color: var(--danger); }
.kpi .hint { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack > * + * { margin-top: 14px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.input, select.input, textarea.input {
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,122,90,.14); }
.input.search { min-width: 220px; }
textarea.input { resize: vertical; min-height: 68px; }

.tabs { display: inline-flex; background: #ecece8; padding: 3px; border-radius: 8px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.tabs button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); margin-right: 4px; white-space: nowrap; }
.tag.green { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tag.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.blue { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.gray { background: #ededea; color: var(--muted); border-color: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; background: #fbfbf9; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fafaf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; font-size: 12px; color: var(--faint); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 4px; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.strong { font-weight: 600; }
.danger-text { color: var(--danger); }
.nowrap { white-space: nowrap; }

.stockbar { display: inline-block; width: 70px; height: 6px; background: #ecece8; border-radius: 3px; overflow: hidden; vertical-align: middle; margin-left: 8px; }
.stockbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.stockbar.low i { background: var(--danger); }
.stockbar.mid i { background: var(--warn); }

.list { display: flex; flex-direction: column; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .row:last-child { border-bottom: 0; }
.list .row.clickable { cursor: pointer; }
.list .row .main-col { flex: 1; min-width: 0; }
.list .row .title { font-weight: 500; }
.list .row .meta { font-size: 12px; color: var(--muted); }
.list .row .right { text-align: right; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 600; flex: 0 0 34px; font-size: 13px; }
.avatar.lg { width: 48px; height: 48px; flex-basis: 48px; font-size: 17px; }

/* ---------- 抽屉 / 弹窗 ---------- */
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(20, 25, 22, .35); z-index: 40; display: none; }
.overlay.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100%;
  background: var(--surface); z-index: 50; box-shadow: -8px 0 30px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer .d-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer .d-head h2 { font-size: 16px; }
.drawer .d-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer .d-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #fbfbf9; flex-wrap: wrap; }
.drawer .d-foot .left { margin-right: auto; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); }
.iconbtn:hover { background: var(--bg); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field .input { width: 100%; }
.field .help { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.checkline { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); }

.section-title { font-size: 12px; color: var(--muted); letter-spacing: .5px; margin: 18px 0 8px; }
.section-title:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.order-lines { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.order-lines .line { display: grid; grid-template-columns: 1fr 90px 90px 28px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.order-lines .line:last-child { border-bottom: 0; }
.order-lines .line .input { padding: 5px 8px; width: 100%; }
.order-lines .head { background: #fbfbf9; font-size: 12px; color: var(--muted); }
.order-lines .foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #fbfbf9; }
.total { font-size: 18px; font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; width: 82px; flex: 0 0 82px; font-size: 12px; padding-top: 1px; }

pre.slip { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; font-family: inherit; font-size: 13px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1f2421; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: all .2s; z-index: 100; pointer-events: none; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.note-banner { background: var(--warn-soft); color: #7a5412; border: 1px solid #efd9ad; border-radius: 8px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 14px; }

.bottomnav { display: none; }

/* ---------- 手机 ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 16px 14px 90px; }
  .page-head h1 { font-size: 19px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .value { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .checkline { padding-top: 0; }
  .drawer { width: 100%; }
  .input.search { min-width: 0; flex: 1; }
  th.hide-m, td.hide-m { display: none; }
  .order-lines .line { grid-template-columns: 1fr 70px 70px 24px; gap: 5px; padding: 7px 6px; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; cursor: pointer; position: relative; }
  .bottomnav button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav button.active { color: var(--accent-ink); }
  .bottomnav .badge { position: absolute; top: 0; right: 22%; font-size: 10px; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 5px; }
}
@media (hover: none) { .btn:hover { background: var(--surface); } .btn.primary:hover { background: var(--accent); } }
