/* ================================================================
   Mobile Layout System — MiaojieFinance
   Bottom-tab navigation, card-based, touch-optimized
   ================================================================ */

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

:root {
  --m-primary: #1e6dd5;
  --m-primary-light: #e3f0ff;
  --m-primary-dark: #144e9c;
  --m-success: #10b981;
  --m-warning: #f59e0b;
  --m-danger: #ef4444;
  --m-bg: #f0f4f8;
  --m-card: #ffffff;
  --m-border: #e5eaf0;
  --m-text: #1a2b42;
  --m-text-sub: #6b7d93;
  --m-text-muted: #9eaab8;
  --m-radius: 12px;
  --m-radius-sm: 8px;
  --m-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --m-tab-height: 56px;
  --m-header-height: 52px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--m-bg);
  color: var(--m-text);
  margin: 0;
  padding: 0;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Top Header ─────────────────────────────────────────────────── */
.m-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--m-header-height);
  background: var(--m-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(30,109,213,0.2);
}
.m-header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.m-header-title i { font-size: 20px; }
.m-header-actions {
  display: flex; align-items: center; gap: 12px;
}
.m-header-actions a, .m-header-actions button {
  color: #fff; background: none; border: none;
  font-size: 20px; padding: 4px; cursor: pointer;
  position: relative;
  opacity: 0.9;
}
.m-header-actions a:hover, .m-header-actions button:hover { opacity: 1; }
.m-header .m-notif-dot {
  position: absolute; top: 0; right: -2px;
  width: 8px; height: 8px;
  background: var(--m-danger);
  border-radius: 50%;
  border: 2px solid var(--m-primary);
}

/* ── Bottom Tab Bar ─────────────────────────────────────────────── */
.m-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--m-tab-height);
  background: var(--m-card);
  border-top: 1px solid var(--m-border);
  display: flex;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--m-text-muted);
  font-size: 11px;
  font-weight: 500;
  gap: 2px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.m-tab i { font-size: 22px; transition: transform 0.15s; min-height: 24px; }
.m-tab.active { color: var(--m-primary); font-weight: 700; }
.m-tab.active i { transform: scale(1.1); }
.m-tab:hover { color: var(--m-primary); }
.m-tab.m-tab-center {
  position: relative;
}
.m-tab.m-tab-center i {
  width: 44px; height: 44px;
  background: var(--m-primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(30,109,213,0.35);
  margin-top: -12px;
}
.m-tab.m-tab-center span { margin-top: 2px; }

/* ── Content Area ───────────────────────────────────────────────── */
.m-content {
  padding-top: calc(var(--m-header-height) + 12px);
  padding-bottom: calc(var(--m-tab-height) + 16px);
  padding-left: 14px;
  padding-right: 14px;
  min-height: 100vh;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.m-card {
  background: var(--m-card);
  border-radius: var(--m-radius);
  box-shadow: var(--m-shadow);
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--m-border);
}
.m-card-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--m-border);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
  background: #fafcff;
}
.m-card-body { padding: 14px; }
.m-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--m-border);
  display: flex; gap: 8px;
  background: #fafcff;
}

/* ── Stat Cards ─────────────────────────────────────────────────── */
.m-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.m-stat {
  background: var(--m-card);
  border-radius: var(--m-radius);
  padding: 14px;
  box-shadow: var(--m-shadow);
  border: 1px solid var(--m-border);
  text-align: center;
}
.m-stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.m-stat-label {
  font-size: 11px;
  color: var(--m-text-sub);
  margin-top: 2px;
  font-weight: 500;
}
.m-stat-primary .m-stat-value { color: var(--m-primary); }
.m-stat-success .m-stat-value { color: var(--m-success); }
.m-stat-warning .m-stat-value { color: var(--m-warning); }
.m-stat-danger .m-stat-value { color: var(--m-danger); }

/* ── List Items ─────────────────────────────────────────────────── */
.m-list-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--m-border);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.m-list-item:last-child { border-bottom: none; }
.m-list-item:active { background: var(--m-primary-light); }
.m-list-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.m-list-icon.blue { background: #e3f0ff; color: var(--m-primary); }
.m-list-icon.green { background: #d1fae5; color: var(--m-success); }
.m-list-icon.orange { background: #fef3c7; color: var(--m-warning); }
.m-list-icon.red { background: #fee2e2; color: var(--m-danger); }
.m-list-info { flex: 1; min-width: 0; }
.m-list-title {
  font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-list-sub {
  font-size: 12px; color: var(--m-text-sub); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-list-right { text-align: right; flex-shrink: 0; }

/* ── Buttons ────────────────────────────────────────────────────── */
.m-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--m-radius-sm);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.m-btn:active { transform: scale(0.96); }
.m-btn-primary { background: var(--m-primary); color: #fff; }
.m-btn-primary:hover { background: var(--m-primary-dark); color: #fff; }
.m-btn-success { background: var(--m-success); color: #fff; }
.m-btn-warning { background: var(--m-warning); color: #fff; }
.m-btn-danger { background: var(--m-danger); color: #fff; }
.m-btn-outline {
  background: transparent;
  border: 1.5px solid var(--m-border);
  color: var(--m-text);
}
.m-btn-outline:hover { border-color: var(--m-primary); color: var(--m-primary); }
.m-btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 6px; min-height: 36px; }
.m-btn-block { width: 100%; }
.m-btn-lg { padding: 14px 24px; font-size: 16px; border-radius: var(--m-radius); }

/* ── Badges ─────────────────────────────────────────────────────── */
.m-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.m-badge-primary { background: var(--m-primary-light); color: var(--m-primary); }
.m-badge-success { background: #d1fae5; color: #065f46; }
.m-badge-warning { background: #fef3c7; color: #92400e; }
.m-badge-danger { background: #fee2e2; color: #991b1b; }
.m-badge-gray { background: #f1f5f9; color: #475569; }

/* ── Forms ──────────────────────────────────────────────────────── */
.m-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--m-border);
  border-radius: var(--m-radius-sm);
  font-size: 15px;
  background: var(--m-card);
  color: var(--m-text);
  outline: none;
  transition: border-color 0.15s;
}
.m-input:focus { border-color: var(--m-primary); box-shadow: 0 0 0 3px rgba(30,109,213,0.1); }
.m-input::placeholder { color: var(--m-text-muted); }
.m-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--m-text);
  margin-bottom: 6px;
}
.m-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--m-border);
  border-radius: var(--m-radius-sm);
  font-size: 15px;
  background: var(--m-card);
  color: var(--m-text);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7d93' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.m-select:focus { border-color: var(--m-primary); }

/* ── Delivery Order Card ────────────────────────────────────────── */
.m-order-card {
  background: var(--m-card);
  border-radius: var(--m-radius);
  border: 1px solid var(--m-border);
  box-shadow: var(--m-shadow);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.m-order-card:active { box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.m-order-head {
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--m-border);
  background: #fafcff;
}
.m-order-head .m-order-no {
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px; color: var(--m-text-sub);
}
.m-order-body { padding: 12px 14px; }
.m-order-customer {
  font-size: 15px; font-weight: 700;
  margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-order-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 12px; color: var(--m-text-sub);
}
.m-order-meta i { margin-right: 3px; }
.m-order-actions {
  padding: 8px 14px;
  display: flex; gap: 8px;
  border-top: 1px solid var(--m-border);
  background: #fafcff;
}

/* ── Qty Control ────────────────────────────────────────────────── */
.m-qty-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--m-border);
}
.m-qty-row:last-child { border-bottom: none; }
.m-qty-name { font-size: 14px; font-weight: 500; flex: 1; }
.m-qty-unit { font-size: 12px; color: var(--m-text-sub); margin-left: 4px; }
.m-qty-ctrl {
  display: flex; align-items: center; gap: 8px;
}
.m-qty-btn {
  width: 44px; height: 44px;
  border: 2px solid var(--m-border);
  border-radius: 50%;
  background: var(--m-card);
  font-size: 20px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--m-primary);
  transition: all 0.12s;
}
.m-qty-btn:active { background: var(--m-primary-light); border-color: var(--m-primary); }
.m-qty-val {
  width: 50px; text-align: center;
  font-size: 18px; font-weight: 700;
  color: var(--m-text);
}
.m-qty-val.changed { color: var(--m-danger); }

/* ── Section Title ──────────────────────────────────────────────── */
.m-section {
  font-size: 15px;
  font-weight: 700;
  margin: 16px 0 8px;
  display: flex; align-items: center; gap: 6px;
  color: var(--m-text);
}
.m-section i { color: var(--m-primary); }

/* ── Filter Pills ───────────────────────────────────────────────── */
.m-pills {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.m-pills::-webkit-scrollbar { display: none; }
.m-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--m-card);
  color: var(--m-text-sub);
  border: 1px solid var(--m-border);
  cursor: pointer;
  transition: all 0.15s;
}
.m-pill.active {
  background: var(--m-primary);
  color: #fff;
  border-color: var(--m-primary);
}

/* ── Photo Grid ─────────────────────────────────────────────────── */
.m-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.m-photo-thumb {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--m-radius-sm);
  border: 1px solid var(--m-border);
}
.m-photo-add {
  width: 100%; aspect-ratio: 1;
  border: 2px dashed var(--m-border);
  border-radius: var(--m-radius-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--m-text-muted);
  font-size: 12px; gap: 4px;
  cursor: pointer;
}
.m-photo-add i { font-size: 24px; }

/* ── Empty State ────────────────────────────────────────────────── */
.m-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--m-text-muted);
}
.m-empty i { font-size: 48px; display: block; margin-bottom: 12px; opacity: 0.5; }
.m-empty p { font-size: 14px; margin: 0; }

/* ── Toast ──────────────────────────────────────────────────────── */
.m-toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(26,43,66,0.92); color: #fff;
  padding: 10px 20px; border-radius: 20px;
  font-size: 14px; font-weight: 500;
  z-index: 999; white-space: nowrap;
  animation: mToastIn 0.25s ease;
}
@keyframes mToastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Loading ────────────────────────────────────────────────────── */
.m-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.m-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--m-border);
  border-top-color: var(--m-primary);
  border-radius: 50%;
  animation: mSpin 0.7s linear infinite;
}
@keyframes mSpin { to { transform: rotate(360deg); } }

/* ── Modal / Bottom Sheet ───────────────────────────────────────── */
.m-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4);
  display: none;
  animation: mFadeIn 0.2s ease;
}
.m-overlay.show { display: block; }
@keyframes mFadeIn { from { opacity: 0; } to { opacity: 1; } }

.m-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 201;
  background: var(--m-card);
  border-radius: 16px 16px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  display: none;
  animation: mSlideUp 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-sheet.show { display: block; }
@keyframes mSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.m-sheet-handle {
  width: 36px; height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 10px auto;
}
.m-sheet-title {
  padding: 4px 16px 12px;
  font-size: 17px; font-weight: 700;
  border-bottom: 1px solid var(--m-border);
  display: flex; align-items: center; justify-content: space-between;
}
.m-sheet-body { padding: 16px; }
.m-sheet-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f1f5f9; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--m-text-sub); cursor: pointer;
}
