/* ============ 钓鱼易耗品管理工具 样式 ============ */
:root {
  --primary: #0e7490;
  --primary-dark: #155e75;
  --primary-soft: #ecfeff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --in: #059669;
  --out: #dc2626;
  --bg: #f3f6f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", 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; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }

/* ============ 布局 ============ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}
.brand a { font-size: 17px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand a:hover { text-decoration: none; }

.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a {
  padding: 7px 14px; border-radius: 8px; color: var(--muted);
  font-weight: 500; text-decoration: none;
}
.topnav a:hover { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }
.topnav a.active { background: var(--primary); color: #fff; }

.topright { display: flex; align-items: center; gap: 10px; }
.topright .user { color: var(--muted); font-size: 14px; }

.main {
  flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 22px 20px 90px;
}

/* 移动端底部导航 */
.bottomnav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; text-decoration: none;
}
.bottomnav a .ic { font-size: 20px; line-height: 1; }
.bottomnav a.active { color: var(--primary); }
.bottomnav a:hover { text-decoration: none; }

/* ============ 通用组件 ============ */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 9px 16px; line-height: 1.2;
  text-decoration: none; white-space: nowrap; transition: .15s;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover { background: #b45309; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: #fca5a5; }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.panel-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--border); background: #fafbfc; }
.panel > .list-plain { margin: 0; }

.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 116, 144, .12); }

.form-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.form-narrow { max-width: 560px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.req { color: var(--danger); }
.hint-text { color: var(--muted); font-weight: 400; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.form-inline { display: flex; gap: 10px; padding: 14px 16px; align-items: center; }
.inline { display: inline; }
.inline-flex { display: flex; gap: 8px; align-items: center; }
.form-inline-input { max-width: 220px; }

.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin: 4px 0; cursor: pointer; }

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.stat-card.stat-danger { border-color: #fca5a5; background: var(--danger-soft); }
.stat-num { font-size: 30px; font-weight: 800; }
.stat-card.stat-danger .stat-num { color: var(--danger); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ============ 列表 ============ */
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: none; }
.item-link { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text); text-decoration: none; }
.item-link:hover { background: var(--primary-soft); text-decoration: none; }
.item-name { font-weight: 600; }
.item-meta { color: var(--muted); font-size: 13px; flex: 1; }
.item-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item-arrow { color: var(--muted); }
.dot-danger { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-in { background: #ecfdf5; color: var(--in); }
.badge-out { background: var(--danger-soft); color: var(--out); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #f1f5f9; color: var(--muted); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }

/* ============ 筛选栏 ============ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
}
.filter-bar .form-control { width: auto; min-width: 140px; flex: 1 1 160px; }
.result-count { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* ============ 物料卡片网格 ============ */
.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.material-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.material-card.card-warn { border-color: #fca5a5; }
.card-photo { display: block; height: 160px; background: #f1f5f9; overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title-row { display: flex; align-items: center; gap: 8px; }
.card-title { font-weight: 700; color: var(--text); font-size: 15px; }
.card-title:hover { color: var(--primary); text-decoration: none; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.remain { font-weight: 700; font-size: 14px; }
.remain-danger { color: var(--danger); }
.specs { display: flex; flex-wrap: wrap; gap: 5px; }
.spec { background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted); }
.spec b { color: var(--text); font-weight: 600; margin-right: 3px; }
.spec-more { color: var(--primary); border-color: #bae6fd; background: #f0f9ff; }
.loc { color: var(--muted); font-size: 12px; }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

/* ============ 规格行（表单） ============ */
.spec-row { display: flex; gap: 8px; margin-bottom: 8px; }
.spec-row .spec-name { flex: 1 1 40%; }
.spec-row .spec-value { flex: 1 1 60%; }
.spec-row .spec-del { flex: 0 0 auto; }

/* ============ 照片上传 ============ */
.photo-upload { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.photo-upload #photo-preview {
  width: 160px; height: 120px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border); background: #f1f5f9;
}
.photo-actions { display: flex; flex-direction: column; gap: 8px; }
.photo-actions input[type="file"] { display: none; }

/* ============ 详情页 ============ */
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; margin-bottom: 18px; }
.detail-photo img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; }
.detail-info { display: flex; flex-direction: column; gap: 14px; }
.detail-stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.detail-stat.remain-danger { border-color: #fca5a5; background: var(--danger-soft); }
.detail-stat.remain-danger .stat-num { color: var(--danger); }
.specs-lg .spec { font-size: 14px; padding: 5px 12px; }
.specs-lg { margin: 14px 16px; }

.kv { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kv th, .kv td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }
.kv th { width: 110px; color: var(--muted); font-weight: 600; background: #fafbfc; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.nowrap { white-space: nowrap; }
.text-in { color: var(--in); font-weight: 600; }
.text-out { color: var(--out); font-weight: 600; }

/* ============ 分页 ============ */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 18px 0; }
.pagination .page {
  min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  font-size: 14px; text-decoration: none;
}
.pagination .page:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .page.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ 提示条 ============ */
.toasts { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 100; width: min(480px, 90vw); display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); background: #fff; }
.toast-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.toast-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }

/* ============ 登录页 ============ */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #e0f2fe 0%, #cffafe 50%, #f0fdfa 100%); }
.login-box { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; }
.login-logo { font-size: 46px; text-align: center; }
.login-box h1 { text-align: center; margin-top: 8px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 18px; }
.login-box .form-panel { box-shadow: none; border: none; padding: 0; }

/* ============ 灯箱 ============ */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .85);
  align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.clickable { cursor: pointer; }

/* ============ 可搜索下拉 ============ */
.combo { position: relative; }
.combo-dropdown {
  display: none;
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.combo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: var(--primary-soft); }
.combo-item-name { font-weight: 600; }
.combo-item-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.combo-empty { padding: 14px; text-align: center; color: var(--muted); }

/* ============ 物料清单表格 ============ */
.material-table td { vertical-align: middle; }
.material-table .specs { max-width: 320px; }
.mat-link { color: var(--text); font-weight: 700; }
.mat-link:hover { color: var(--primary); text-decoration: none; }
tr.row-warn td { background: #fff7f7; }
tr.row-warn .mat-link { color: var(--danger); }
.col-actions { width: 128px; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .topnav { display: none; }
  .topright .user { display: none; }
  .bottomnav { display: flex; }
  .main { padding: 16px 14px 96px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .filter-bar .form-control { min-width: 100%; }
  .stat-num { font-size: 24px; }
  .photo-upload #photo-preview { width: 100%; height: 200px; }
}
