/* ============================================================
   商业街/写字楼综合管理平台 — 共享样式（原内联于 base.html，已抽取为静态资源）
   抽取目的：避免每页重复下载 CSS，移动端弱网下首屏更快、流量更省（见审计 #426）。
   Cache-bust：通过 ?v= 版本号强制刷新（STATIC_VERSION 在 app.py 中维护）。
   ============================================================ */
:root {
    /* 统一品牌色板：群青 / 豆黄 / 纸白（与全服务器其它项目一致） */
    --primary: #153472;          /* 群青 */
    --primary-dark: #0f2552;
    --primary-darker: #0b1c40;
    --primary-light: #e3e9f2;    /* 群青浅染 */
    --primary-lighter: #eef2f7;
    --accent: #FFDF70;           /* 豆黄 */
    --accent-ink: #6b5410;
    --success: #0f9d58;
    --warning: #d99a2b;          /* 暖琥珀 */
    --danger: #c0392b;           /* 暖红 */
    --text: #1f2937;
    --text-secondary: #5b6472;
    --text-muted: #9aa3b2;
    --border: #e3e0d6;           /* 暖灰，贴合纸白 */
    --bg: #F2ECDE;               /* 纸白 */
    --card-bg: #ffffff;
    --glass: rgba(255, 255, 255, 0.8);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 50px rgba(15, 23, 42, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    /* 移动端：禁止横向溢出导致误触缩放 */
    overflow-x: hidden;
}

/* ===== 导航栏 ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 60%, #1e4d8b 100%);
    color: white;
    padding: 0 40px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}
.navbar-brand { display: flex; align-items: center; gap: 14px; }
.navbar-icon {
    width: 42px; height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.navbar h1 {
    font-size: 20px; font-weight: 700; letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.navbar nav { display: flex; align-items: center; gap: 4px; }
.navbar nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 8px 18px;
    font-size: 14px; font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.25s ease;
    position: relative;
}
.navbar nav a:hover, .navbar nav a.active { color: #fff; background: rgba(255, 255, 255, 0.15); }
.navbar nav a.logout { margin-left: 10px; color: rgba(255, 255, 255, 0.7); border: 1px solid rgba(255, 255, 255, 0.2); }
.navbar nav a.logout:hover { color: #fff; background: rgba(255, 255, 255, 0.2); }

/* ===== 主容器 ===== */
.container { max-width: 1320px; margin: 0 auto; padding: 28px 36px; }

/* ===== 消息提示 ===== */
.flash-success {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7); color: #166534;
    padding: 14px 20px; border-radius: var(--radius);
    border-left: 4px solid var(--success);
    margin-bottom: 16px; font-size: 14px; font-weight: 500;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}
.flash-error {
    background: linear-gradient(135deg, #fef2f2, #fee2e2); color: #991b1b;
    padding: 14px 20px; border-radius: var(--radius);
    border-left: 4px solid var(--danger);
    margin-bottom: 16px; font-size: 14px; font-weight: 500;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

/* ===== 日期栏 ===== */
.date-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; padding: 14px 20px;
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.date-bar-left { display: flex; align-items: center; gap: 12px; }
.date-bar-icon {
    width: 36px; height: 36px; background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.date-bar-date { font-size: 15px; font-weight: 600; color: var(--text); }
.date-bar-user { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg); border-radius: var(--radius-lg);
    padding: 28px; margin-bottom: 24px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    transition: all 0.3s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 22px; padding-bottom: 16px;
    border-bottom: 2px solid var(--primary-lighter);
}
.card-header h2 {
    font-size: 17px; font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 10px;
}
.card-header p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; border: none; border-radius: var(--radius);
    cursor: pointer; font-size: 14px; font-weight: 500;
    text-decoration: none; transition: all 0.25s ease; line-height: 1.5;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: white; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3); }
.btn-success:hover { box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4); transform: translateY(-1px); }
.btn-outline { background: white; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-lighter); }
.btn-sm { padding: 5px 14px; font-size: 12px; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-danger-outline { background: white; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; border-color: #dc2626; }
.btn-success-outline { background: white; color: #059669; border: 1px solid #a7f3d0; }
.btn-success-outline:hover { background: #ecfdf5; border-color: #059669; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 7px; font-weight: 600;
    color: var(--text-secondary); font-size: 13px; letter-spacing: 0.3px;
}
.form-control {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 14px; transition: all 0.2s ease;
    background: white; color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
.form-control:disabled { background: #f8fafc; cursor: not-allowed; }
.form-control::placeholder { color: var(--text-muted); }

/* ===== 表格 ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); }
th {
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    font-weight: 600; color: var(--text-secondary);
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px;
}
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--primary-lighter); }
tbody tr:last-child td { border-bottom: none; }

/* ===== 网格布局 ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; }

/* ===== 统计卡片 ===== */
.stat-card {
    background: white; border-radius: var(--radius-lg); padding: 24px;
    border: 1px solid var(--border); box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 18px;
    transition: all 0.3s ease; position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--primary), #4f7fc4); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--success), #4fb286); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--danger), #d98076); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--warning), #e8c06a); }
.stat-card:nth-child(5)::before { background: linear-gradient(90deg, var(--accent), #e6c84d); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 56px; height: 56px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; flex-shrink: 0;
}
.stat-icon.blue { background: linear-gradient(135deg, var(--primary-light), #bfdbfe); }
.stat-icon.green { background: linear-gradient(135deg, #f0fdf4, #bbf7d0); }
.stat-icon.orange { background: linear-gradient(135deg, #fffbeb, #fde68a); }
.stat-icon.red { background: linear-gradient(135deg, #fef2f2, #fecaca); }
.stat-icon.purple { background: linear-gradient(135deg, #fdf6dd, #f3e2a8); }
.stat-info { flex: 1; min-width: 0; overflow: hidden; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ===== 徽章 ===== */
.badge {
    display: inline-flex; align-items: center; padding: 4px 12px;
    border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 1.5; letter-spacing: 0.2px;
}
.badge-default { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #f0fdf4; color: #166534; }
.badge-warning { background: #fffbeb; color: #b45309; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }

/* ===== 登录页 ===== */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #0b1c40 0%, #153472 40%, #1e4d8b 72%, #2a5a9e 100%);
    position: relative; overflow: hidden;
}
.login-wrapper::before {
    content: ''; position: absolute; width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(42, 90, 158, 0.20), transparent 70%);
    top: -200px; right: -100px; animation: float 8s ease-in-out infinite;
}
.login-wrapper::after {
    content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.25), transparent 70%);
    bottom: -100px; left: -50px; animation: float 10s ease-in-out infinite reverse;
}
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, -30px) scale(1.05); } }
.login-card {
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px);
    padding: 50px 44px; border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 440px;
    position: relative; z-index: 1; border: 1px solid rgba(255, 255, 255, 0.3);
}
.login-header { text-align: center; margin-bottom: 36px; }
.login-logo {
    width: 72px; height: 72px; background: linear-gradient(135deg, var(--primary), #1e4d8b);
    border-radius: 20px; display: flex; align-items: center; justify-content: center;
    font-size: 36px; margin: 0 auto 18px; box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}
.login-header h2 { font-size: 24px; color: var(--text); font-weight: 700; }
.login-header p { font-size: 14px; color: var(--text-muted); margin-top: 6px; }
.login-btn {
    width: 100%; padding: 13px; font-size: 16px; font-weight: 600; margin-top: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border: none; border-radius: var(--radius); cursor: pointer;
    transition: all 0.3s ease; box-shadow: 0 4px 16px rgba(21, 52, 114, 0.35);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(21, 52, 114, 0.45); }
.remember-row {
    display: flex; align-items: center; gap: 8px; margin: 14px 2px 4px;
    font-size: 13px; color: var(--text-2, #555); cursor: pointer; user-select: none;
}
.remember-row input { width: 16px; height: 16px; accent-color: var(--primary, #153472); }
.login-hint { margin: 12px 2px 0; font-size: 12px; color: #8a94a6; line-height: 1.5; }

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6); z-index: 1000;
    align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: white; border-radius: var(--radius-xl); padding: 36px;
    width: 92%; max-width: 580px; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn { from { transform: translateY(-30px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; padding-bottom: 18px; border-bottom: 2px solid var(--primary-lighter); }
.modal-header h3 { font-size: 18px; color: var(--text); font-weight: 700; }
.modal-close {
    width: 36px; height: 36px; border: none; background: var(--bg); cursor: pointer;
    font-size: 18px; color: var(--text-muted); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 56px; margin-bottom: 14px; }
.empty-state p { font-size: 14px; }

/* ===== 交易额高亮 ===== */
.amount-highlight {
    font-size: 20px; font-weight: 700; color: var(--primary);
    background: var(--primary-lighter); padding: 10px 20px; border-radius: var(--radius);
    display: inline-flex; align-items: center; gap: 8px;
}

/* ===== 录入按钮组 ===== */
.action-buttons {
    display: flex; gap: 14px; margin-top: 28px; padding: 24px;
    background: linear-gradient(135deg, var(--primary-lighter), #e9eef6);
    border-radius: var(--radius-lg); border: 1px dashed var(--primary);
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) { .grid-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .container { padding: 12px; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    .navbar { padding: 0 12px; height: 56px; }
    .navbar h1 { font-size: 14px; }
    .navbar nav { gap: 2px; }
    .navbar nav a { padding: 5px 8px; font-size: 11px; border-radius: 6px; }
    .navbar nav a.logout { margin-left: 4px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-icon { width: 44px; height: 44px; font-size: 22px; }
    .stat-value { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat-label { font-size: 11px; }
    .card { padding: 16px; border-radius: var(--radius); }
    .card-header { margin-bottom: 14px; padding-bottom: 12px; }
    .card-header h2 { font-size: 15px; }
    .action-buttons { flex-direction: column; }
    /* 看板表格 → 卡片模式 */
    table thead { display: none; }
    table, tbody, tr, td { display: block; }
    tr { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; padding: 14px; box-shadow: var(--shadow-sm); }
    tr:hover { background: var(--primary-lighter); }
    td { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
    td:last-child { border-bottom: none; }
    td::before { content: attr(data-label); font-weight: 600; color: var(--text-secondary); font-size: 12px; flex-shrink: 0; margin-right: 12px; }
    td:first-child::before { content: none; }
    td:first-child { justify-content: flex-start; font-size: 15px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 2px solid var(--primary-lighter); }
    .photo-cell .btn-photo-view { font-size: 13px; padding: 6px 16px; }
    .photo-modal { max-width: 95%; padding: 18px; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .photo-grid .photo-card img { height: 120px; }
    .btn { font-size: 13px; padding: 8px 14px; }
}
@media (max-width: 480px) {
    .container { padding: 8px; }
    .navbar { height: 50px; padding: 0 8px; }
    .navbar h1 { font-size: 13px; }
    .navbar nav a { padding: 4px 6px; font-size: 11px; }
    .navbar-icon { width: 32px; height: 32px; font-size: 16px; }
    .date-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
    .photo-grid { grid-template-columns: 1fr; }
    .stat-card { flex-direction: column; text-align: center; gap: 8px; }
    .modal { padding: 20px; }
}

/* ============================================================
   移动端体验增强（审计 #428）：大点按区 / 底部操作栏 / 防误触
   ============================================================ */

/* 输入框 ≥16px：避免 iOS Safari 聚焦时自动放大页面（误触/抖动） */
input, select, textarea { font-size: 16px; }

/* 触控目标最小尺寸：移动端按钮/链接点按区 ≥44px，降低误触 */
@media (max-width: 768px) {
    .btn, .navbar nav a, .modal-close { min-height: 44px; }
    .form-control { padding: 12px 14px; min-height: 44px; }
    .action-buttons .btn { width: 100%; justify-content: center; font-size: 15px; padding: 13px; }
}

/* 底部悬浮操作栏：页面在移动端可将主操作按钮放入 .bottom-action-bar，
   固定在视口底部、常驻可见，避免长页面滑动找按钮。可选使用。 */
.bottom-action-bar {
    position: sticky;
    bottom: 0;
    left: 0; right: 0;
    display: none;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    z-index: 200;
}
.bottom-action-bar .btn { flex: 1; justify-content: center; }
@media (max-width: 768px) {
    .bottom-action-bar { display: flex; }
    /* 启用底部栏时，给主体留出空间，避免被遮挡 */
    body.has-bottom-bar .container { padding-bottom: 84px; }
}

/* 防误触：危险操作二次确认弹窗（配合 JS confirm 或 modal 使用） */
.btn-danger-outline, .btn[onclick*="delete"], .btn[onclick*="remove"] { touch-action: manipulation; }
a, button { touch-action: manipulation; }
