/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green: #0f6e56; --green-light: #e1f5ee; --green-dark: #085041;
  --blue: #185fa5; --blue-light: #e6f1fb;
  --amber: #854f0b; --amber-light: #faeeda;
  --red: #a32d2d; --red-light: #fcebeb;
  --text: #2c2c2a; --text-secondary: #5f5e5a; --text-muted: #888780;
  --bg: #f5f4f0; --white: #fff; --border: rgba(0,0,0,0.08);
  --radius: 12px; --radius-sm: 8px; --radius-xs: 6px;
}
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.6;
  min-height: 100vh;
}

/* ===== Layout ===== */
.app-container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ===== Header ===== */
.app-header {
  background: var(--white); border-bottom: 0.5px solid var(--border);
  padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px);
}
.app-header .logo { font-size: 16px; font-weight: 600; color: var(--green); white-space: nowrap; }
.app-header nav { display: flex; gap: 4px; flex: 1; }
.app-header nav a {
  padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 13px;
  color: var(--text-secondary); text-decoration: none; transition: all 0.15s;
}
.app-header nav a:hover { background: var(--bg); }
.app-header nav a.active { background: var(--green-light); color: var(--green); font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ===== Sections ===== */
.section { display: none; animation: fadeIn 0.3s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.section-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.section-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

/* ===== Cards ===== */
.card { background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text); }

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ===== Metric Cards ===== */
.metric {
  background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border);
  padding: 16px 18px; transition: transform 0.15s, box-shadow 0.15s; cursor: pointer;
}
.metric:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.metric .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.metric .value { font-size: 24px; font-weight: 600; color: var(--text); }
.metric .change { font-size: 12px; margin-top: 4px; }
.up { color: #e24b4a; }
.down { color: #1d9e75; }

/* ===== Badge ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: var(--bg); color: var(--text-secondary); }
.badge-disabled { background: #e8e7e2; color: #9a9890; }

/* ===== Role Tags ===== */
.role-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.role-user { background: var(--blue-light); color: var(--blue); }
.role-admin { background: var(--green-light); color: var(--green); }
.role-ops { background: var(--amber-light); color: var(--amber); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: 7px; font-size: 13px; cursor: pointer;
  border: 0.5px solid; font-weight: 500; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--green); color: var(--white); border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: var(--white); color: var(--text); border-color: rgba(0,0,0,0.2); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--red-light); color: var(--red); border-color: #f7c1c1; }
.btn-danger:hover { background: #f7c1c1; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 24px; font-size: 14px; }

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* 右侧淡出提示 */
  background: linear-gradient(to right, var(--white) 30%, rgba(255,255,255,0)),
              linear-gradient(to right, rgba(255,255,255,0), var(--white) 70%) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%;
  background-attachment: local, scroll;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 10px 14px; color: var(--text-muted); font-weight: 500; border-bottom: 0.5px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 0.5px solid rgba(0,0,0,0.05); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ===== Form ===== */
input, select, textarea {
  border: 0.5px solid rgba(0,0,0,0.2); border-radius: var(--radius-xs); padding: 8px 12px;
  font-size: 12px; color: var(--text); background: var(--white); outline: none; width: 100%;
  font-family: inherit; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: #1d9e75; box-shadow: 0 0 0 3px rgba(29,158,117,0.1); }
label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; font-weight: 500; }
.form-group { margin-bottom: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }

/* ===== Sidebar Layout ===== */
.sidebar-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; min-width: 0; }
.sidebar-layout > div:last-child { min-width: 0; overflow: hidden; }
.sidebar-menu {
  background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border);
  padding: 8px; position: sticky; top: 68px;
}
.sidebar-item { padding: 8px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text-secondary); margin-bottom: 2px; transition: all 0.15s; }
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { background: var(--green-light); color: var(--green); font-weight: 500; }
.sidebar-group { font-size: 11px; color: #b4b2a9; padding: 10px 12px 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Phone Mockup ===== */
.phone-wrap { display: flex; justify-content: center; gap: 32px; flex-wrap: wrap; }
.phone {
  width: 240px; background: var(--white); border-radius: 32px;
  border: 2px solid var(--text); overflow: hidden;
  box-shadow: 0 0 0 6px var(--bg), 0 8px 24px rgba(0,0,0,0.12);
  transition: transform 0.2s;
}
.phone:hover { transform: translateY(-4px); }
.phone-notch { background: var(--text); height: 22px; border-radius: 0 0 12px 12px; width: 80px; margin: 0 auto; }
.phone-screen { padding: 12px; min-height: 400px; }
.phone-label { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ===== Screen UI ===== */
.s-header {
  background: var(--green); color: var(--white); padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 500;
}
.s-tab-bar { display: flex; border-bottom: 0.5px solid var(--border); margin-bottom: 10px; }
.s-tab { flex: 1; text-align: center; padding: 7px 0; font-size: 11px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.s-tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 500; }
.s-product { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 0.5px solid rgba(0,0,0,0.05); }
.s-product:last-child { border-bottom: none; }
.s-product .thumb { width: 36px; height: 36px; background: var(--green-light); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.s-product .pname { font-size: 11px; font-weight: 500; color: var(--text); }
.s-product .pprice { font-size: 10px; color: var(--text-muted); }
.s-product .paction { margin-left: auto; font-size: 10px; background: var(--green); color: var(--white); padding: 3px 8px; border-radius: 4px; white-space: nowrap; cursor: pointer; }
.s-device { background: var(--bg); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.s-device .dname { font-size: 11px; font-weight: 500; }
.s-device .dprice { font-size: 10px; color: var(--text-muted); }
.s-device .dstatus { font-size: 10px; color: #1d9e75; margin-top: 2px; }
.s-btn { width: 100%; padding: 9px; background: var(--green); color: var(--white); border-radius: 8px; text-align: center; font-size: 12px; font-weight: 500; margin-top: 10px; cursor: pointer; border: none; transition: background 0.15s; }
.s-btn:hover { background: var(--green-dark); }
.s-btn-outline { background: var(--white); color: var(--green); border: 0.5px solid var(--green); }
.s-btn-outline:hover { background: var(--green-light); }
.s-chip { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; margin-right: 4px; }

/* ===== Flow ===== */
.flow { display: flex; align-items: center; flex-wrap: wrap; gap: 0; margin: 16px 0; }
.flow-step { display: flex; align-items: center; gap: 6px; }
.flow-step .dot {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 600;
  background: var(--green-light); color: var(--green); flex-shrink: 0;
}
.flow-step .name { font-size: 12px; color: #444441; white-space: nowrap; }
.flow-arrow { color: #b4b2a9; margin: 0 8px; font-size: 14px; font-weight: 600; }

/* ===== Feature List ===== */
.feat-list { list-style: none; }
.feat-list li { padding: 6px 0; border-bottom: 0.5px solid rgba(0,0,0,0.05); font-size: 12px; display: flex; gap: 8px; }
.feat-list li:last-child { border-bottom: none; }
.feat-list li::before { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; background: #1d9e75; margin-top: 5px; flex-shrink: 0; }

/* ===== Device Card ===== */
.device-card {
  border: 0.5px solid var(--border); border-radius: 10px; padding: 14px;
  background: var(--white); transition: all 0.15s;
}
.device-card:hover { border-color: var(--green); }
.device-card .device-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.device-card .device-loc { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.device-progress { height: 4px; background: var(--bg); border-radius: 2px; margin: 6px 0 8px; }
.device-progress-fill { height: 4px; background: #1d9e75; border-radius: 2px; transition: width 0.6s ease; }

/* ===== 格口可视化网格 ===== */
.slot-legend { display:inline-block;width:12px;height:12px;border-radius:3px;vertical-align:-2px;margin-right:3px; }
.locker-device-bar {
  display:flex; align-items:center; justify-content:space-between;
  background:linear-gradient(135deg,#f7f9f8,#eff5f1); border-radius:var(--radius);
  padding:14px 18px; margin-bottom:16px; border:1px solid var(--border);
}
.locker-dev-info { display:flex;align-items:center;gap:10px;font-size:13px; }
.locker-dev-info span:last-of-type { font-size:11px;color:#888780; }
.locker-stats { display:flex;align-items:center;gap:16px; }
.stat-item { text-align:right; }
.stat-label { font-size:11px;color:#888780;display:block;margin-bottom:2px; }
.stat-val { font-size:15px; }
.stat-sub { font-size:10px;color:#aaa;margin-left:6px; }
.stat-divider { width:1px;height:36px;background:var(--border); }
.locker-section { margin-bottom:20px; }
.locker-section-header {
  display:flex;align-items:center;gap:8px;padding:10px 0;border-bottom:1px solid var(--border);
  margin-bottom:12px;flex-wrap:wrap;
}
.section-icon { font-size:16px; }
.section-title { font-weight:600;font-size:14px; }
.section-legend { margin-left:auto;display:flex;gap:10px;font-size:11px;color:#888780;flex-wrap:wrap; }
.section-count { font-size:12px;font-weight:600;color:#888780;background:var(--bg);padding:2px 10px;border-radius:10px; }
.locker-grid-wrap {
  display:grid; gap:6px;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
}
@media (min-width:700px) { .locker-grid-wrap { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); } }
.slot-cell {
  position:relative; aspect-ratio:1; border-radius:8px; cursor:pointer;
  display:flex;align-items:center;justify-content:center;transition:all 0.15s ease;
  border:2px solid transparent; user-select:none; overflow:hidden;
}
.slot-cell:hover { transform:scale(1.08); z-index:2; box-shadow:0 3px 12px rgba(0,0,0,0.15); }
.slot-cell.slot-selected { border-color:#2563eb; transform:scale(1.08); box-shadow:0 0 0 2px rgba(37,99,235,0.25); z-index:2; }
/* 租赁-空闲 */
.slot-idle { background:#e1f5ee; border-color:#9fe1cb; color:#0f6e56; }
/* 租赁-占用 */
.slot-occupied { background:#0f6e56; color:#fff; }
/* 售卖-空柜 */
.slot-empty { background:#faeeda; border-color:#eddcb7; color:#ba7517; }
/* 售卖-有货 */
.slot-stocked { background:#ba7517; color:#fff; }
.slot-num { font-size:11px;font-weight:700;z-index:1;pointer-events:none;letter-spacing:0.5px; }
.slot-dot {
  position:absolute;top:3px;right:3px;width:6px;height:6px;
  border-radius:50%;background:#4ade80;box-shadow:0 0 4px rgba(74,222,128,0.6);
}
.slot-dot.dot-yellow { background:#fbbf24; box-shadow:0 0 4px rgba(251,191,36,0.6); }
@media (max-width:500px) {
  .locker-grid-wrap { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap:4px; }
  .locker-device-bar { flex-direction:column;gap:10px; text-align:center; }
  .locker-stats { justify-content:center; }
  .section-legend { display:none; }
}

/* 设备表格：保证窄屏可水平滚动 */
#device-table { min-width: 900px; }

/* ===== Timeline ===== */
.timeline { padding-left: 16px; border-left: 1.5px solid var(--green-light); }
.tl-item { position: relative; padding-bottom: 16px; padding-left: 14px; }
.tl-item::before { content: ""; position: absolute; left: -6px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #1d9e75; border: 2px solid var(--white); }
.tl-item .tl-title { font-size: 12px; font-weight: 500; color: var(--text); }
.tl-item .tl-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== Info Row ===== */
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 0.5px solid rgba(0,0,0,0.05); font-size: 12px; }
.info-row:last-child { border-bottom: none; }
.info-row .lk { color: var(--text-muted); }
.info-row .lv { color: var(--text); font-weight: 500; }

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius); padding: 24px;
  max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2); animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ===== Charts ===== */
.chart-area { width: 100%; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin: 8px 0; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; border-radius: 3px 3px 0 0; transition: height 0.4s ease; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  padding: 12px 20px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--white); transform: translateX(120%); transition: transform 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast.show { transform: translateX(0); }
.toast-success { background: #1d9e75; }
.toast-error { background: #e24b4a; }
.toast-info { background: #185fa5; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Product Filter Bar ===== */
.product-filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 12px 16px; background: var(--bg); border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.filter-item { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.filter-item label { font-size: 10px; color: var(--text-muted); margin-bottom: 0; font-weight: 400; }
.filter-item input, .filter-item select { font-size: 12px; padding: 6px 10px; height: 32px; }
.filter-date { min-width: 220px; }
.filter-actions { flex-direction: row; align-items: flex-end; gap: 6px; min-width: auto; }
.filter-actions .btn { height: 32px; white-space: nowrap; }

/* ===== Upload Area ===== */
.upload-area {
  border: 1.5px dashed rgba(0,0,0,0.15); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; cursor: pointer; transition: all 0.15s;
  position: relative; background: #fafaf9;
}
.upload-area:hover { border-color: var(--green); background: var(--green-light); }
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.upload-preview { position: relative; display: inline-block; }
.upload-preview img { max-width: 100%; max-height: 160px; border-radius: 6px; object-fit: cover; }
.upload-remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  background: var(--red); color: #fff; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 12px; cursor: pointer;
  line-height: 1;
}

/* ===== Form Section Title ===== */
.form-section-title {
  font-size: 12px; font-weight: 600; color: var(--text); margin: 16px 0 10px;
  padding-bottom: 6px; border-bottom: 0.5px solid var(--border);
}
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }

/* ===== Required Mark ===== */
.required-mark { color: #e24b4a; font-weight: 500; }

/* ===== Product Table Image ===== */
.product-thumb {
  width: 42px; height: 42px; border-radius: 6px; object-fit: cover;
  border: 0.5px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #b4b2a9;
}

/* ===== Loading ===== */
.loading { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--green-light); border-top-color: var(--green); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Marketing Center ===== */
.marketing-tabs {
  display: flex; gap: 0; margin-bottom: 14px;
  border-bottom: 2px solid var(--border);
}
.marketing-tab {
  padding: 8px 18px; font-size: 12px; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s; white-space: nowrap;
}
.marketing-tab:hover { color: var(--text); }
.marketing-tab.active {
  color: var(--green); border-bottom-color: var(--green); font-weight: 500;
}

/* 活动类型选择卡片 */
.mk-type-selector {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.mk-type-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s; text-align: center; background: var(--white);
}
.mk-type-card:hover { border-color: var(--green); background: var(--green-light); }
.mk-type-card.selected {
  border-color: var(--green); background: var(--green-light);
  box-shadow: 0 0 0 3px rgba(15,110,86,0.1);
}
.mk-type-icon { font-size: 28px; }
.mk-type-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mk-type-desc { font-size: 10px; color: var(--text-muted); }

/* 关联商品多选列表 */
.mk-product-list {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px;
  border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-xs);
  min-height: 44px; align-items: center; background: #fafaf9;
}
.mk-product-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px;
  cursor: pointer; transition: all 0.15s;
  border: 0.5px solid var(--border); background: var(--white);
  user-select: none;
}
.mk-product-chip:hover { border-color: var(--green); }
.mk-product-chip.selected {
  background: var(--green-light); color: var(--green);
  border-color: var(--green); font-weight: 500;
}
.mk-product-chip .chip-check {
  display: none; font-size: 10px;
}
.mk-product-chip.selected .chip-check { display: inline; }

/* 营销活动表格操作按钮 */
#marketing-table .btn-sm { font-size: 10px; padding: 3px 8px; }

/* 响应式：类型选择卡片 */
@media (max-width: 768px) {
  .mk-type-selector { grid-template-columns: 1fr; }
  .marketing-tabs { overflow-x: auto; white-space: nowrap; }
  .marketing-tab { font-size: 11px; padding: 6px 12px; }
}

/* ===== Responsive ===== */

/* ≥1200px: 大屏优化 */
@media (min-width: 1200px) {
  .app-container { max-width: 1280px; }
}

/* ≤1200px: 中等屏幕 */
@media (max-width: 1200px) {
  .app-container { max-width: 100%; padding: 20px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .phone-wrap { gap: 24px; }
}

/* ≤1024px: 小平板 */
@media (max-width: 1024px) {
  .app-container { padding: 16px; }
  
  /* sidebar 自适应 */
  .sidebar-layout { grid-template-columns: 1fr; }
  .sidebar-menu {
    position: static; display: flex; flex-wrap: wrap; gap: 2px;
    padding: 6px; border-radius: var(--radius);
    overflow-x: auto; white-space: nowrap;
  }
  .sidebar-group { display: none; }
  .sidebar-item {
    margin-bottom: 0; white-space: nowrap; flex-shrink: 0;
    padding: 6px 12px; font-size: 12px; border-radius: 6px;
  }
  
  /* 表单两列/三列变一列 */
  .form-row-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  
  /* 筛选栏 */
  .product-filter-bar { flex-direction: column; }
  .filter-item { width: 100%; }
  .filter-date { min-width: auto; }
  
  /* 流程步骤 */
  .flow { flex-wrap: wrap; justify-content: center; gap: 4px; }
  .flow-arrow { margin: 0 4px; }
  
  /* 设备表格：水平滚动提示 */
  #device-table { min-width: 800px; }
}

/* ≤768px: 手机横屏/小平板 */
@media (max-width: 768px) {
  /* Header */
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 6px; }
  .app-header .logo { font-size: 14px; }
  .app-header nav { order: 3; width: 100%; overflow-x: auto; display: flex; flex-wrap: nowrap; }
  .app-header nav a { font-size: 11px; padding: 5px 10px; white-space: nowrap; }
  .header-actions { margin-left: auto; }
  
  /* Grids */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  
  /* 统计卡片缩小 */
  .metric { padding: 12px 14px; }
  .metric .value { font-size: 20px; }
  
  /* 卡片 */
  .card { padding: 14px; }
  
  /* 手机模型 */
  .phone-wrap { gap: 12px; }
  .phone { width: 160px; border-radius: 24px; }
  .phone-screen { min-height: 320px; padding: 8px; }
  .phone-label { font-size: 11px; margin-top: 10px; }
  
  /* 流程 */
  .flow { flex-direction: column; align-items: flex-start; }
  .flow-arrow { transform: rotate(90deg); margin: 2px 12px; }
  
  /* 时间线 */
  .grid-3 { gap: 12px; }
  
  /* 弹窗 */
  .modal { padding: 16px; max-width: 95vw; max-height: 85vh; }
  .modal-footer { flex-wrap: wrap; }
  
  /* 按钮 */
  .btn { padding: 6px 14px; font-size: 12px; }
  
  /* 表格操作按钮 */
  td .btn-sm { padding: 3px 7px; font-size: 10px; }
  
  /* 管理后台搜索区 */
  #admin-devices .card > div:first-child { flex-direction: column; align-items: flex-start !important; }
  #admin-devices .card > div:first-child > div:last-child { width: 100%; }
  #admin-search-device { width: 100% !important; }
  #admin-filter-status, #admin-filter-type { width: 48% !important; }
}

/* ===== 系统权限 ===== */

/* 菜单树 */
.menu-tree { padding: 4px 0; }
.menu-tree-node { margin-bottom: 2px; }
.menu-tree-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius-xs); cursor: pointer; transition: all 0.15s;
  border: 0.5px solid transparent;
}
.menu-tree-header:hover { background: var(--bg); }
.menu-tree-header.level-1 { background: var(--green-light); border-color: #9fe1cb; margin-bottom: 4px; }
.menu-tree-header.level-2 { background: var(--blue-light); border-color: #85b7eb; }
.menu-tree-header.level-3 { background: #fafaf9; border-color: var(--border); }
.menu-tree-expand {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted); transition: transform 0.2s;
  flex-shrink: 0;
}
.menu-tree-expand.expanded { transform: rotate(90deg); }
.menu-tree-icon { font-size: 14px; flex-shrink: 0; }
.menu-tree-name { font-size: 12px; font-weight: 500; flex: 1; }
.menu-tree-tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 500; white-space: nowrap;
}
.menu-tree-tag.l1 { background: var(--green-light); color: var(--green); }
.menu-tree-tag.l2 { background: var(--blue-light); color: var(--blue); }
.menu-tree-tag.l3 { background: var(--amber-light); color: var(--amber); }
.menu-tree-minlevel {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  font-size: 9px; background: var(--red-light); color: var(--red);
}
.menu-tree-actions { display: flex; gap: 4px; flex-shrink: 0; }
.menu-tree-children { padding-left: 24px; }

/* 菜单勾选列表 */
.menu-check-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 240px; overflow-y: auto; padding: 8px;
  border: 0.5px solid rgba(0,0,0,0.15); border-radius: var(--radius-xs);
  background: #fafaf9;
}
.menu-check-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  border-radius: 4px; cursor: pointer; font-size: 11px; transition: background 0.15s;
  user-select: none;
}
.menu-check-item:hover { background: var(--bg); }
.menu-check-item input[type="checkbox"] { width: auto; accent-color: var(--green); }
.menu-check-item.child { padding-left: 32px; font-size: 10px; color: var(--text-secondary); }

/* 岗位等级标签 */
.level-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
}
.level-l1 { background: var(--red-light); color: var(--red); }
.level-l2 { background: var(--amber-light); color: var(--amber); }
.level-l3 { background: var(--blue-light); color: var(--blue); }
.level-l4 { background: var(--green-light); color: var(--green); }
.level-l5 { background: var(--bg); color: var(--text-muted); }

/* 员工卡片内联 */
.emp-position-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 500;
}

/* 响应式：菜单树 */
@media (max-width: 768px) {
  .menu-tree-children { padding-left: 12px; }
  .menu-tree-header { padding: 6px 8px; gap: 4px; }
  .menu-tree-name { font-size: 11px; }
  .menu-check-list { max-height: 180px; }
}

/* ===== Refund ===== */
.refund-amount-input {
  position: relative; display: flex; align-items: center;
}
.refund-currency {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; font-weight: 600; color: var(--text); z-index: 1;
  pointer-events: none;
}
.refund-hint {
  font-size: 10px; color: var(--text-muted); margin-top: 4px;
}
.refund-summary {
  background: var(--amber-light); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 10px;
}
.refund-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 500;
  background: #fcebeb; color: #a32d2d;
}

/* ≤480px: 小屏手机 */
@media (max-width: 480px) {
  .app-container { padding: 10px; }
  .section-title { font-size: 15px; }
  .section-sub { font-size: 11px; margin-bottom: 16px; }
  
  /* Header 紧凑 */
  .app-header { padding: 8px 10px; }
  .app-header nav a { font-size: 10px; padding: 4px 8px; }
  .header-actions .badge { font-size: 10px !important; padding: 2px 8px !important; }
  
  /* 统计卡片更紧凑 */
  .metric { padding: 10px 12px; border-radius: var(--radius-sm); }
  .metric .label { font-size: 10px; }
  .metric .value { font-size: 18px; }
  .metric .change { font-size: 10px; }
  
  /* 卡片 */
  .card { padding: 12px; border-radius: var(--radius-sm); }
  .card-title { font-size: 13px; margin-bottom: 10px; }
  
  /* 表格 */
  th, td { padding: 6px 8px; font-size: 10px; }
  
  /* 弹窗 */
  .modal { padding: 12px; border-radius: var(--radius-sm); }
  .modal-title { font-size: 14px; margin-bottom: 12px; }
  
  /* 手机模型更小 */
  .phone { width: 140px; border-radius: 20px; }
  .phone-screen { min-height: 260px; padding: 6px; }
  .s-header { padding: 6px 8px; font-size: 10px; }
  .s-tab { font-size: 9px; padding: 5px 0; }
  .s-device { padding: 6px; }
  .s-btn { padding: 6px; font-size: 10px; }
  
  /* 流程 */
  .flow-step .dot { width: 22px; height: 22px; font-size: 10px; }
  .flow-step .name { font-size: 10px; }
  
  /* 特征列表 */
  .feat-list li { font-size: 10px; padding: 4px 0; }
  
  /* 图表 */
  .bar-chart { height: 80px; gap: 4px; }
  
  /* 设备统计卡片在480以下仍保持两列 */
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  
  /* 收入/订单统计两列 */
  #admin-orders .grid-2,
  #admin-finance .grid-2 { gap: 8px; }
}
