/* 家庭物品管理系统 - 移动端优先样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(15, 23, 42, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

.app-shell { max-width: 720px; margin: 0 auto; min-height: 100vh; }

/* ---------- 顶部栏 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, .25);
}
.header-inner {
  height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-logo { font-size: 22px; }
.user-chip {
  font-size: 13px; background: rgba(255,255,255,.18);
  padding: 4px 10px; border-radius: 999px; max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 闪存提示 ---------- */
.flash-wrap { padding: 10px 16px 0; }
.flash {
  padding: 11px 14px; border-radius: 10px; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  animation: slideDown .25s ease;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 主体 ---------- */
.app-main { padding: 14px 14px calc(84px + var(--safe-bottom)); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 720px; z-index: 60;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 2px 7px; color: var(--muted); font-size: 11px;
}
.tab .tab-icon { font-size: 21px; line-height: 1.2; }
.tab.active { color: var(--primary); font-weight: 600; }

/* ---------- 通用区块 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.section-title {
  font-size: 15px; font-weight: 700; margin: 0 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title .more { font-size: 13px; font-weight: 400; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 34px 12px; }
.empty-icon { font-size: 44px; display: block; margin-bottom: 8px; opacity: .75; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border: 1px solid transparent;
  border-radius: 10px; background: var(--primary); color: #fff;
  font-weight: 600; cursor: pointer; line-height: 1;
}
.btn:active { opacity: .85; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: #f3f4f6; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 48px; font-size: 16px; }

/* 悬浮新增按钮 */
.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-bottom));
  z-index: 55; width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 28px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(37,99,235,.4);
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* 图片上传 */
.upload-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.upload-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #f1f3f5; }
.upload-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-add {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  border: 1.5px dashed #cbd5e1; color: var(--muted); font-size: 12px; cursor: pointer;
}
.upload-add .plus { font-size: 26px; line-height: 1; }
.upload-remove, .upload-remove-label {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer;
}
.upload-remove-label input { display: none; }
.upload-item.removed { opacity: .35; }
input[type=file] { display: none; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 14px; }
.stat {
  background: #fff; border-radius: 12px; padding: 12px 6px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 20px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat.c1 .stat-num { color: var(--primary); }
.stat.c2 .stat-num { color: #7c3aed; }
.stat.c3 .stat-num { color: #0891b2; }
.stat.c4 .stat-num { color: #db2777; }

/* 提醒条 */
.alert-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: 0; }
.alert-icon { font-size: 20px; }
.alert-body { flex: 1; min-width: 0; }
.alert-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.badge-gray { background: #f3f4f6; color: var(--muted); }

/* 条形统计 */
.bar-row { margin-bottom: 11px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-track { height: 7px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg,#3b82f6,#60a5fa); }

/* ---------- 搜索与筛选 ---------- */
.search-box { display: flex; gap: 8px; margin-bottom: 12px; }
.search-box .input { flex: 1; }
.filter-scroll { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 13px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; white-space: nowrap; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 物品卡片 ---------- */
.item-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.item-card {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); display: block; color: var(--text);
}
.item-cover { position: relative; width: 100%; aspect-ratio: 1.25; background: #f1f3f5; overflow: hidden; }
.item-cover img { width: 100%; height: 100%; object-fit: cover; }
.fav-btn {
  position: absolute; top: 7px; right: 7px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center;
  font-size: 15px; z-index: 2;
}
.item-info { padding: 10px 11px 12px; }
.item-name { font-weight: 700; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.item-qty { margin-top: 7px; font-weight: 700; color: var(--primary); font-size: 14px; }

/* ---------- 详情页 ---------- */
.detail-cover { width: 100%; aspect-ratio: 1.3; object-fit: cover; border-radius: 12px; background: #f1f3f5; }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.kv-list { margin: 0; }
.kv-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv-row:last-child { border-bottom: 0; }
.kv-key { width: 88px; flex: 0 0 88px; color: var(--muted); }
.kv-val { flex: 1; word-break: break-all; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

/* ---------- 管理列表 ---------- */
.manage-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.manage-row:last-child { border-bottom: 0; }
.manage-icon {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px;
  background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.manage-body { flex: 1; min-width: 0; }
.manage-name { font-weight: 600; }
.manage-sub { font-size: 12px; color: var(--muted); }
.manage-actions { display: flex; gap: 6px; }

/* ---------- 登录页 ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(160deg, #eff6ff 0%, #f4f6f9 42%); }
.auth-hero { text-align: center; padding: 52px 20px 26px; }
.auth-hero .logo {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 20px;
  background: linear-gradient(135deg,#2563eb,#60a5fa);
  display: flex; align-items: center; justify-content: center; font-size: 38px;
  box-shadow: 0 10px 24px rgba(37,99,235,.28);
}
.auth-hero h1 { margin: 0; font-size: 22px; }
.auth-hero p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.auth-card {
  background: #fff; margin: 0 18px; padding: 22px 18px;
  border-radius: 18px; box-shadow: 0 8px 30px rgba(15,23,42,.08);
}
.auth-footer { text-align: center; font-size: 13px; color: var(--muted); padding: 20px; }
.demo-tip {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 100; display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 720px; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(20px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }

/* ---------- 响应式（桌面端） ---------- */
@media (min-width: 721px) {
  .app-main { padding-left: 22px; padding-right: 22px; }
  .modal-mask { align-items: center; }
  .modal { border-radius: 18px; }
}
