/**
 * 工地通 · 公共布局样式（现代简约蓝 v2）
 * ------------------------------------------------------------
 * 设计基调：浅色侧边栏 + 品牌蓝 #2f6bff 强调，圆角卡片、柔和阴影。
 *
 * 用法：各业务页面 <style> 中引入
 *   <link rel="stylesheet" href="../libs/layout.css">
 *   或 <link rel="stylesheet" href="/web/libs/layout.css">
 *
 * 注意：页面特有样式（表格、弹窗、按钮等）仍保留在各页面 <style> 中。
 */

:root {
  --blue: #2f6bff;
  --blue-d: #1f5af0;
  --blue-l: #eef3ff;
  --ink: #1a2332;
  --muted: #8a94a6;
  --line: #eef0f4;
  --bg: #f5f7fa;
  --card: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

/* 全局滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6dbe4; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b9c1cf; }

/* 布局骨架 */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏（浅色 + 品牌蓝强调） */
.sidebar {
  width: 224px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 0 16px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 16px rgba(31, 41, 55, 0.04);
  display: flex;
  flex-direction: column;
}
.sidebar-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 18px 16px;
  color: #fff;
  background: linear-gradient(135deg, #2f6bff 0%, #1f4ec0 100%);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}
.nav-item {
  display: block;
  padding: 12px 22px;
  color: #5a6b85;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: #f3f6ff; color: var(--blue); }
.nav-item.active {
  background: var(--blue-l);
  color: var(--blue);
  border-left: 3px solid var(--blue);
  font-weight: 600;
}
.nav-item .icon { margin-right: 8px; }

/* 侧边栏底部退出区 */
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.logout-item { color: #ef4444; }
.logout-item:hover { background: #fff1f0; color: #dc2626; }

/* 主内容区 */
.main { flex: 1; padding: 24px; overflow-y: auto; }

/* 页面标题 */
.page-title { font-size: 22px; font-weight: 700; color: var(--ink); }
.breadcrumb { font-size: 12px; color: #9ca3af; margin-bottom: 4px; }
.breadcrumb span { color: #6b7280; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* 用户信息 / 退出按钮 */
.user-info { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 14px; color: #6b7280; }
.logout-btn {
  padding: 6px 16px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.logout-btn:hover { background: #dc2626; }

/* 主按钮 */
.btn-primary {
  padding: 10px 20px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(47, 107, 255, 0.22);
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--blue-d); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(47, 107, 255, 0.28); }
.btn-primary:active { transform: translateY(0); }

/* 全局按钮交互 */
button { transition: all 0.15s ease; }
button:active { transform: scale(0.97); }

/* 表格行悬停效果 */
tbody tr:hover td { background: #f6f9ff; }

/* 输入框聚焦效果 */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}

/* 卡片进入动画 */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.content-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(31, 41, 55, 0.05);
  overflow-x: auto;
  animation: fadeInUp 0.3s ease;
}

/* ===== 全局统一：加载状态 ===== */
.web-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: #9ca3af;
}
.web-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: web-spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes web-spin {
  to { transform: rotate(360deg); }
}
.web-loading .loading-text { font-size: 14px; }

/* ===== 全局统一：空状态 ===== */
.web-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #9ca3af;
}
.web-empty .empty-icon { font-size: 48px; margin-bottom: 16px; }
.web-empty .empty-text { font-size: 15px; margin-bottom: 4px; }
.web-empty .empty-tip { font-size: 13px; color: #d1d5db; }

/* ===== 全局统一：导出按钮 ===== */
.btn-export {
  padding: 10px 20px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
  transition: all 0.15s;
}
.btn-export:hover { background: #059669; transform: translateY(-1px); }

/* ===== 响应式优化 ===== */
@media (max-width: 1024px) {
  .sidebar { width: 190px; }
  .nav-item { padding: 11px 16px; font-size: 13px; }
  .main { padding: 16px; }
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    padding: 10px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    box-shadow: none;
  }
  .sidebar-title { display: none; }
  .nav-item {
    padding: 8px 14px;
    font-size: 12px;
    border-left: none !important;
    border-bottom: 2px solid transparent;
  }
  .nav-item:hover,
  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--blue);
  }
  .sidebar-footer { display: none; }
  .main { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-title { font-size: 18px; }
}

@media (max-width: 480px) {
  .main { padding: 8px; }
  .page-title { font-size: 16px; }
  .nav-item { padding: 6px 10px; font-size: 11px; }
}

/* 弹窗响应式 */
@media (max-width: 768px) {
  .modal, .detail-content {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 20px 16px !important;
  }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-row { grid-template-columns: 1fr !important; }
  .stats-row, .cashflow-row { grid-template-columns: repeat(2, 1fr) !important; }
  .chart-row { grid-template-columns: 1fr !important; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { width: 100% !important; }
}
