/* 商铺微单元安全管理系统 - 样式 */
:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #273449;
    --border: #334155;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --red: #ef4444;
    --orange: #f97316;
    --yellow: #eab308;
    --green: #22c55e;
    --blue: #3b82f6;
    --primary: #3b82f6;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 0 20px 24px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sidebar-logo .icon { font-size: 24px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    color: var(--text);
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary);
}

.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* 主内容区 */
.main {
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover { border-color: var(--primary); }

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-card.red .stat-value { color: var(--red); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.blue .stat-value { color: var(--blue); }

/* 卡片容器 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* 四色分级分布 */
.color-distribution {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.color-bar {
    flex: 1;
    text-align: center;
    padding: 16px 8px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.color-bar .count { font-size: 28px; font-weight: 700; display: block; }
.color-bar .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.color-bar .pct { font-size: 11px; color: var(--text-secondary); }

.color-bar.red .count { color: var(--red); }
.color-bar.orange .count { color: var(--orange); }
.color-bar.yellow .count { color: var(--yellow); }
.color-bar.green .count { color: var(--green); }

/* 表格 */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(15, 23, 42, 0.5);
}

tr:hover td { background: rgba(59, 130, 246, 0.05); }

/* 徽标 */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-orange { background: rgba(249, 115, 22, 0.15); color: var(--orange); }
.badge-yellow { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.badge-green { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.badge-gray { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-card-hover); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* 进度条 */
.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-fill.red { background: var(--red); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.green { background: var(--green); }
.progress-fill.blue { background: var(--blue); }

/* 业态分布 - 表格+饼图并排 */
.biz-dist-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.biz-table-wrap {
    flex: 1;
    min-width: 0;
    max-height: 420px;
    overflow-y: auto;
}
.biz-table-wrap table {
    font-size: 12px;
}
.biz-table-wrap th,
.biz-table-wrap td {
    padding: 5px 8px;
}
.biz-chart-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.biz-chart-wrap canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 380px;
}
@media (max-width: 768px) {
    .biz-dist-layout {
        flex-direction: column;
    }
    .biz-chart-wrap {
        width: 100%;
        max-height: 300px;
    }
}

/* 双列布局 */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* 评分卡片 */
.score-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.score-item {
    background: var(--bg);
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.score-item .dim-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.score-item .dim-value {
    font-size: 22px;
    font-weight: 700;
}

.score-item .dim-max {
    font-size: 11px;
    color: var(--text-muted);
}

/* 搜索框 */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.search-bar input, .search-bar select {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
}

/* 巡检清单 */
.checklist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.checklist-item:hover { border-color: var(--primary); }
.checklist-item.selected { border-color: var(--primary); background: rgba(59,130,246,0.1); }

.checklist-item .dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    flex-shrink: 0;
}

.checklist-item .dot.normal { background: var(--green); border-color: var(--green); }
.checklist-item .dot.abnormal { background: var(--red); border-color: var(--red); }

.checklist-item .item-text { flex: 1; font-size: 13px; }
.checklist-item .item-cat {
    font-size: 11px; color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-card);
    border-radius: 4px;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .sidebar-nav { display: flex; overflow-x: auto; padding: 0 10px; }
    .sidebar-nav a { padding: 10px 14px; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
    .main { margin-left: 0; padding: 16px; }
    .two-col, .three-col { grid-template-columns: 1fr; }
    .score-grid { grid-template-columns: repeat(2, 1fr); }
    .checklist-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 风险热力图 */
.heatmap-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.heatmap-bar .district-name { width: 110px; font-size: 12px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.heatmap-bar .bar-track {
    flex: 1;
    height: 24px;
    background: var(--bg);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.heatmap-bar .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--red));
    border-radius: 4px;
    transition: width 0.5s;
}

.heatmap-bar .bar-label { font-size: 12px; color: var(--text-secondary); width: 80px; text-align: right; }

/* 通知/弹窗 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; }

.hidden { display: none !important; }

/* 链接 */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Tooltip */
.has-tooltip { cursor: help; border-bottom: 1px dotted var(--text-muted); }

/* 巡检拍照区 */
.photo-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.2s;
}

.photo-area:hover { border-color: var(--primary); }

.photo-area .icon { font-size: 40px; margin-bottom: 8px; }
.photo-area .text { color: var(--text-muted); font-size: 13px; }

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.photo-preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ===== 响应式适配 ===== */
@media (max-width: 768px) {
    body { font-size: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .two-col { grid-template-columns: 1fr; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 0; }
    .sidebar-nav a { flex: 1; min-width: 80px; padding: 8px 6px; font-size: 11px; text-align: center; }
    .sidebar .nav-icon { margin-right: 2px; }
    .main { margin-left: 0; padding: 12px; }
    .card { padding: 12px; }
    .table-wrap { overflow-x: auto; }
    table { font-size: 11px; }
    th, td { padding: 6px 4px; }
    .biz-dist-layout { flex-direction: column; }
    .biz-chart-wrap { max-height: 200px; }
    .modal-content { width: 95%; margin: 5% auto; }
    .page-header h1 { font-size: 20px; }
    .subtitle { font-size: 11px; }
    nav { flex-wrap: wrap; }
    nav a { font-size: 12px; padding: 6px 8px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 8px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 10px; }
    .color-bar { flex-direction: column; align-items: flex-start; gap: 2px; }
    .search-box { width: 100%; }
    .info-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
    .sidebar, nav { display: none; }
    .main { margin-left: 0; padding: 0; }
    .card { break-inside: avoid; border: 1px solid #ccc; }
    body { background: #fff; color: #000; }
}

/* 角色徽标 */
.badge-superadmin { background:#fce7f3; color:#9d174d; padding:2px 8px; border-radius:4px; font-size:11px; display:inline-block; }
.badge-admin { background:#dbeafe; color:#1e40af; padding:2px 8px; border-radius:4px; font-size:11px; display:inline-block; }
.badge-manager { background:#fef3c7; color:#92400e; padding:2px 8px; border-radius:4px; font-size:11px; display:inline-block; }
.badge-inspector { background:#dcfce7; color:#166534; padding:2px 8px; border-radius:4px; font-size:11px; display:inline-block; }
.badge-viewer { background:#f3f4f6; color:#4b5563; padding:2px 8px; border-radius:4px; font-size:11px; display:inline-block; }
