/* ============================================================
   天麟泰安智能巡检系统 v2.0 · 统一设计系统
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --text: #1f2937;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --bg: #f3f4f6;
    --card: #ffffff;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
    --nav-h: 60px;
    --bottom-h: 64px;
    --font: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- 顶部导航 ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--nav-h); z-index: 100;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; display: flex; align-items: center; padding: 0 16px;
    box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.topbar .brand {
    font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px;
}
.topbar .brand i { font-size: 20px; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(255,255,255,.16);
    padding: 5px 12px; border-radius: 999px; color: #fff;
}
.topbar .user-chip i { font-size: 14px; }

/* ---------- 桌面侧边栏 ---------- */
.sidebar {
    display: none;
}
.sidebar a {
    display: flex; align-items: center; gap: 12px; padding: 13px 18px; color: var(--text-2);
    border-radius: 10px; margin-bottom: 4px; font-size: 15px; transition: all .15s;
}
.sidebar a i { width: 20px; text-align: center; }
.sidebar a:hover { background: #eef2ff; color: var(--primary); }
.sidebar a.active { background: var(--primary); color: #fff; box-shadow: var(--shadow); }

/* ---------- 主内容区 ---------- */
.main {
    padding: calc(var(--nav-h) + 16px) 16px calc(var(--bottom-h) + 24px);
    max-width: 1100px; margin: 0 auto;
}
.main-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.main-sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 16px;
}
.card-title {
    font-size: 16px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.card-title i { color: var(--primary); }

/* ---------- 网格统计 ---------- */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
}
.stat-item {
    background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px;
    text-align: center; position: relative; overflow: hidden;
}
.stat-item .num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-item .lbl { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.stat-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary);
}
.stat-item.green::before { background: var(--success); }
.stat-item.green .num { color: var(--success); }
.stat-item.orange::before { background: var(--warning); }
.stat-item.orange .num { color: var(--warning); }
.stat-item.red::before { background: var(--danger); }
.stat-item.red .num { color: var(--danger); }

/* ---------- 进度条 ---------- */
.progress {
    height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 8px 0;
}
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 999px; transition: width .4s; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all .15s; color: #fff; background: var(--primary); line-height: 1.4;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-warning { background: var(--warning); }
.btn-info    { background: var(--info); }
.btn-ghost   { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); filter: none; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn i { font-size: 14px; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group label .req { color: var(--danger); }
.form-group .tip { font-size: 12px; color: var(--text-3); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="tel"], input[type="email"], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: var(--font); background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s; appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select {
    background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 10px center/16px;
    padding-right: 34px;
}
textarea { min-height: 80px; resize: vertical; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
.table th { background: #f8fafc; font-weight: 600; color: var(--text-2); }
.table tr:hover td { background: #f8fafc; }
.table .thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-blue { background: #dbeafe; color: var(--primary-dark); }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f3f4f6; color: var(--text-2); }

/* ---------- 上传/水印相机 ---------- */
.upload-item { margin-bottom: 18px; }
.upload-item .lbl { font-size: 14px; font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.upload-preview {
    width: 100%; min-height: 200px; background: #f8fafc; border: 1.5px dashed var(--border);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin-bottom: 8px; position: relative; background-size: cover; background-position: center;
}
.upload-preview img { width: 100%; height: auto; }
.upload-preview .ph { color: var(--text-3); font-size: 13px; text-align: center; padding: 20px; }
.upload-actions { display: flex; gap: 8px; }
.upload-actions .btn { flex: 1; }

/* 水印相机弹层 */
.camera-modal {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1000;
    align-items: flex-end; justify-content: center;
}
.camera-modal.show { display: flex; }
.camera-sheet {
    background: #fff; width: 100%; max-width: 640px; max-height: 90vh; border-radius: 16px 16px 0 0;
    display: flex; flex-direction: column; overflow: hidden; animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.camera-head { padding: 14px 16px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.camera-head h3 { font-size: 16px; flex: 1; }
.camera-body { flex: 1; overflow: auto; padding: 16px; background: #0b1020; }
.camera-body video { width: 100%; border-radius: 10px; }
.camera-stage { position: relative; }
.camera-stage canvas { width: 100%; border-radius: 10px; display: block; }
.camera-meta {
    background: rgba(255,255,255,.07); border-radius: 8px; padding: 10px 12px; margin-top: 10px;
    font-size: 12px; color: #cbd5e1; line-height: 1.8;
}
.camera-foot { padding: 12px 16px; display: flex; gap: 10px; border-top: 1px solid var(--border); }
.camera-foot .btn { flex: 1; }
.camera-head .btn.on { background: #f59e0b !important; color: #fff !important; }

/* ---------- 标签选择器 ---------- */
.tag-choose { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-choose .opt {
    border: 1.5px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px;
    cursor: pointer; color: var(--text-2); background: #fff; transition: all .15s; user-select: none;
}
.tag-choose .opt.on { border-color: var(--primary); color: var(--primary); background: #eff6ff; font-weight: 600; }

/* ---------- 分组列表 ---------- */
.list-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 15px; }
.list-item .sub { font-size: 13px; color: var(--text-2); }

/* ---------- 底部导航 ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-h); z-index: 100;
    background: #fff; border-top: 1px solid var(--border); display: flex;
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text-3); font-size: 11px;
}
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a span { line-height: 1; }

/* ---------- 提示消息 ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: var(--primary-dark); border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty i { font-size: 42px; margin-bottom: 10px; opacity: .4; }

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

/* ---------- 弹窗 ---------- */
.modal-mask {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1500;
    align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 420px; max-height: 85vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-box .modal-h { padding: 16px 18px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-box .modal-b { padding: 18px; }
.modal-box .modal-f { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- 分段选择器 ---------- */
.seg { display: flex; background: #e5e7eb; border-radius: 10px; padding: 3px; gap: 3px; }
.seg a {
    flex: 1; text-align: center; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 14px;
}
.seg a.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- 桌面端适配 ---------- */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .app-layout { display: flex; min-height: 100vh; }
    .sidebar {
        display: block; width: 230px; position: fixed; top: var(--nav-h); bottom: 0; left: 0;
        background: #fff; border-right: 1px solid var(--border); padding: 18px 12px; overflow: auto;
    }
    .main { margin-left: 230px; max-width: none; padding-bottom: 40px; }
    .main-inner { max-width: 1100px; margin: 0 auto; }
    .camera-modal { align-items: center; }
    .camera-sheet { border-radius: 16px; }
}

@media (min-width: 992px) {
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}