:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e4e8ec;
  --text: #17202a;
  --text-2: #5b6772;
  --muted: #8a95a1;
  --primary: #118555;
  --primary-2: #0c6b43;
  --danger: #d64545;
  --warn: #d97706;
  --info: #2563eb;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(17,133,85,.12); }
.textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f7a4f, #0b3d2b);
}
.login-card {
  width: 380px;
  background: var(--surface);
  border-radius: 12px;
  padding: 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card .input { margin-bottom: 12px; }
.login-hint { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  background: #12231b;
  color: #d8e6de;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.logo-text { font-size: 15px; font-weight: 600; line-height: 1.3; }
.logo-text small { display: block; font-size: 11px; color: rgba(255,255,255,.5); font-weight: 400; margin-top: 2px; }
.nav-group { font-size: 11px; color: rgba(255,255,255,.42); padding: 12px 8px 6px; letter-spacing: .5px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: #c9d9d0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 16px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; font-size: 11px; color: rgba(255,255,255,.4); line-height: 1.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title { font-size: 18px; font-weight: 700; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right .select { width: auto; min-width: 160px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }

.content { padding: 22px; overflow: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 18px; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input { width: 220px; }
.toolbar .spacer { flex: 1; }
.filter-bar { padding: 10px 18px; gap: 12px; }
.filter-bar .fitem { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.filter-bar .fitem .input { width: 180px; }
.filter-bar .fitem .select { width: auto; min-width: 130px; }
.upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-preview { width: 72px; height: 72px; border: 1px dashed var(--border); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.03); }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .ph { font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.upload-thumbs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.up-thumb { position: relative; width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 15px; text-align: center; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; font-size: 12px; padding: 0; }
.p-thumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.05); color: var(--muted); font-size: 14px; font-weight: 600; border: 1px solid var(--border); }
.p-thumb img { width: 100%; height: 100%; object-fit: cover; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; background: var(--surface); padding: 7px 14px; font-size: 12px; cursor: pointer; color: var(--text-2); }
.segmented button.active { background: var(--primary); color: #fff; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th { text-align: left; padding: 10px 14px; background: #f8fafb; color: var(--text-2); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: #fafcfb; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.num { text-align: right; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill-on { background: rgba(17,133,85,.12); color: var(--primary); }
.pill-off { background: #eef1f4; color: var(--muted); }
.pill-soldout { background: rgba(214,69,69,.1); color: var(--danger); }
.pill-warn { background: rgba(217,119,6,.12); color: var(--warn); }
.pill-info { background: rgba(37,99,235,.1); color: var(--info); }
.pill-danger { background: rgba(214,69,69,.1); color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.low-stock { color: var(--danger); font-weight: 700; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-card { padding: 16px 18px; }
.kpi-label { font-size: 12px; color: var(--text-2); }
.kpi-value { font-size: 26px; font-weight: 700; margin: 6px 0 4px; }
.kpi-trend { font-size: 12px; color: var(--primary); }
.kpi-trend.down { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* modal */
.modal-wrap { position: fixed; inset: 0; z-index: 100; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal { position: relative; width: 560px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px); margin: 30px auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.info-list { font-size: 13px; }
.info-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.info-row .k { color: var(--muted); width: 90px; flex-shrink: 0; }
.info-row .v { flex: 1; word-break: break-all; }
.timeline { margin-top: 8px; }
.timeline .step { position: relative; padding: 0 0 14px 20px; }
.timeline .step::before { content: ""; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline .step .title { font-size: 13px; }
.timeline .step .time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: #17202a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .logo-text, .nav-group, .nav-item span { display: none; }
  .nav-item { justify-content: center; }
  .two-col, .kpi-grid { grid-template-columns: 1fr; }
}

/* ===== 移动端适配（≤768px） ===== */
.menu-btn { display: none; }
.sidebar-mask { display: none; }
@media (max-width: 768px) {
  .menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px;
    background: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0;
  }
  .app { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 236px; z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 36px rgba(0,0,0,.35); }
  body.sidebar-open .sidebar-mask {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 190;
  }
  .main { width: 100%; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .content { padding: 14px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .two-col { grid-template-columns: 1fr; gap: 14px; }
  .login-card { width: calc(100vw - 32px); padding: 28px 24px; }
  .toolbar, .filter-bar { padding: 12px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .fitem { width: 100%; flex-wrap: wrap; }
  .filter-bar .fitem .input, .filter-bar .fitem .select { width: 100%; }
  .toolbar .input { width: 100%; }
  .modal { width: calc(100vw - 24px); }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .row-actions { flex-wrap: wrap; }
}
