/* ===== 全局变量 ===== */
:root {
  --primary: #17324d;
  --primary-dark: #10283d;
  --accent: #e0a000;
  --work-green: #1f7a5a;
  --ink: #18242f;
  --bg-light: #edf1f3;
  --border: #d8dee3;
  --a4-width: 794px;
  --a4-height: 1123px;
}

* { box-sizing: border-box; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.85);
  outline-offset: 2px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-light);
  color: var(--ink);
  margin: 0;
  padding-bottom: 40px;
}

/* ===== 顶部导航 ===== */
.top-nav {
  background: var(--primary-dark);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(16,40,61,0.2);
  padding: 0.55rem 1rem;
}
.top-nav .navbar-brand { color: #fff !important; }
.brand-lockup { display: inline-flex; align-items: center; gap: 0.65rem; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 1.05rem; font-weight: 700; }
.brand-copy small { margin-top: 0.25rem; color: #cad6df; font-size: 0.68rem; }
.brand-icon { font-size: 1.05rem; color: var(--accent); }

/* ===== Tab 导航 ===== */
.tab-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  padding: 0.5rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tab-bar .nav-pills .nav-link {
  color: #64748b;
  font-weight: 500;
  padding: 0.5rem 1.2rem;
  border-radius: 4px;
  transition: all 0.2s;
}
.tab-bar .nav-pills .nav-link:hover {
  background: #e7eef2;
  color: var(--primary);
}
.tab-bar .nav-pills .nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(23,50,77,0.25);
}

/* ===== 卡片 ===== */
.form-card, .preview-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(24,36,47,0.07);
  margin-top: 1rem;
  overflow: hidden;
}
.form-card .card-header, .preview-card .card-header {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
}
.form-card .card-body {
  padding: 1rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* ===== 表单 ===== */
.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.3rem;
}
.form-control, .form-select {
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23,50,77,0.1);
}
textarea.form-control { resize: vertical; }
.workstream-group .btn {
  min-height: 38px;
  padding: 0.45rem 0.35rem;
  border-radius: 0;
  font-size: 0.82rem;
}
.workstream-group .btn:first-of-type { border-radius: 4px 0 0 4px; }
.workstream-group .btn:last-of-type { border-radius: 0 4px 4px 0; }
.workstream-group .btn-check:checked + .btn {
  border-color: var(--work-green);
  background: var(--work-green);
  color: #fff;
}

/* ===== 报告分区与施工进度台账 ===== */
.report-section {
  padding: 0.8rem 0 0.8rem 0.85rem;
  border-left: 3px solid #c7d2da;
}
.report-section:focus-within { border-left-color: var(--work-green); }
.section-toolbar,
.progress-add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.section-count {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 3px;
  background: #e4eee9;
  color: #176047;
  font-size: 0.72rem;
  font-weight: 700;
}
.progress-add-row { margin: 0.6rem 0; }
.progress-add-row .form-select { min-width: 0; }
.progress-add-row .btn { flex: 0 0 auto; }
.progress-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.progress-table { min-width: 620px; table-layout: fixed; }
.progress-table thead th {
  padding: 0.42rem 0.35rem;
  border-bottom: 1px solid #b8c3cc;
  background: #e9eef1;
  color: #364652;
  font-size: 0.72rem;
  text-align: center;
  white-space: nowrap;
}
.progress-table th:first-child { width: 176px; }
.progress-table th:nth-child(2) { width: 62px; }
.progress-table th:nth-child(3) { width: 84px; }
.progress-table th:nth-child(4),
.progress-table th:nth-child(5),
.progress-table th:nth-child(6) { width: 72px; }
.progress-table th:last-child { width: 34px; }
.progress-table td { padding: 0.3rem; vertical-align: middle; }
.progress-table .progress-work {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 0.3rem;
}
.progress-table .form-control,
.progress-table .form-select { min-height: 30px; padding: 0.2rem 0.35rem; font-size: 0.76rem; }
.progress-table .btn-del { width: 28px; height: 28px; }
.progress-empty { padding: 0.85rem; color: #788690; font-size: 0.78rem; text-align: center; }

/* ===== 列表项（可拖拽） ===== */
.sortable-list .list-group-item {
  border: 1px solid var(--border);
  border-radius: 4px !important;
  margin-bottom: 0.4rem;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafb;
  cursor: grab;
  transition: background 0.2s;
}
.sortable-list .list-group-item:hover { background: #edf4f1; }
.sortable-list .list-group-item:active { cursor: grabbing; }
.sortable-list .list-group-item .drag-handle {
  color: #94a3b8;
  cursor: grab;
  font-size: 0.85rem;
}
.sortable-list .list-group-item input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  outline: none;
}
.sortable-list .list-group-item .btn-del {
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.sortable-list .list-group-item .btn-del:hover { background: #fee2e2; }

/* ===== 装备项 ===== */
.equip-item {
  display: grid;
  grid-template-columns: minmax(85px, 1fr) minmax(90px, 1fr) 64px 58px 74px 30px;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  align-items: center;
}
.equip-item input {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}
.equip-item .form-select { font-size: 0.78rem; padding: 0.25rem 0.35rem; }
.equip-item .btn-del {
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
}

/* ===== A4 预览 ===== */
.preview-body {
  background: #bfc8ce;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
  max-height: calc(100vh - 200px);
  overflow: auto;
}
.a4-page {
  width: var(--a4-width);
  min-height: var(--a4-height);
  flex: 0 0 var(--a4-width);
  zoom: 0.8;
  background: #fff;
  padding: 2.54cm 3.17cm;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-family: "方正仿宋_GBK", "FangSong", "STFangsong", serif;
  font-size: 14pt;
  line-height: 1.8;
  color: #000;
  transform-origin: top center;
  transition: transform 0.3s;
}
.a4-page .doc-title {
  font-family: "方正小标宋_GBK", "STSong", serif;
  font-size: 18pt;
  text-align: center;
  font-weight: bold;
  margin-bottom: 1rem;
}
.a4-page .doc-header {
  font-size: 16pt;
  font-weight: bold;
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
}
.a4-page .doc-body {
  text-indent: 2em;
  text-align: justify;
  white-space: pre-wrap;
  margin-bottom: 0.2rem;
}
.a4-page .doc-date {
  text-align: right;
  margin-top: 2rem;
  font-size: 16pt;
}
.a4-page .doc-empty {
  color: #94a3b8;
  font-style: italic;
}

/* ===== 工程模板卡片 ===== */
.project-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 1rem;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.project-card .card-body { padding: 1rem; }
.project-card .project-name {
  font-weight: 600;
  font-size: 1rem;
  color: #1e293b;
  margin-bottom: 0.3rem;
}
.project-card .project-meta {
  font-size: 0.8rem;
  color: #64748b;
}
.project-card .project-intro {
  color: #475569;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 0.2rem;
}

/* ===== 表格 ===== */
.table { font-size: 0.9rem; }
.table thead th { font-weight: 600; }

/* ===== 进度看板统计卡片 ===== */
.stat-card { border-radius: 6px; }
.stat-label { font-size: 0.8rem; color: #64748b; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: #1e293b; line-height: 1.2; }

/* ===== Flatpickr 中文主题覆盖 ===== */
.flatpickr-input {
  background-color: #fff !important;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== 响应式 ===== */
@media (max-width: 992px) {
  .form-card .card-body,
  .preview-body {
    max-height: none;
  }
  .a4-page {
    transform: none;
    zoom: 0.7;
    transform-origin: top left;
  }
  .preview-body { padding: 0.5rem; }
  [data-aos] {
    opacity: 1 !important;
    transform: none !important;
  }
}
@media (min-width: 1600px) {
  .a4-page { zoom: 0.9; }
}
@media (min-width: 1900px) {
  .a4-page { zoom: 1; }
}
@media (max-width: 768px) {
  .tab-bar .nav-pills .nav-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 576px) {
  .top-nav { padding-inline: 0.65rem; }
  .top-nav .navbar-brand { font-size: 1rem; }
  .top-nav .navbar-brand .brand-icon { font-size: 1.2rem; }
  .top-nav .badge { font-size: 0.7rem; }
  .tab-bar .nav-pills { overflow-x: auto; flex-wrap: nowrap; }
  .tab-bar .nav-pills .nav-link { white-space: nowrap; }
  .a4-page { zoom: 0.45; }
  .top-nav .container-fluid { align-items: flex-start; gap: 0.5rem; }
  .top-nav .container-fluid > .d-flex { justify-content: flex-end; flex-wrap: wrap; }
  .brand-copy small { display: none; }
  .form-card .card-header { flex-wrap: wrap; gap: 0.45rem; }
  .form-card .card-header h5 { font-size: 0.95rem; white-space: nowrap; }
  .form-card .card-header > .d-flex { width: 100%; justify-content: flex-end; }
  .preview-card .card-header h5 { font-size: 0.9rem; white-space: nowrap; }
  .report-section { padding-left: 0.55rem; }
  .section-toolbar { align-items: flex-start; }
  .equip-item {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 56px;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #f8fafb;
  }
  .equip-item .btn-del { justify-self: end; }
}
@media (max-width: 420px) {
  .a4-page { zoom: 0.4; }
  .tab-bar .nav-pills .nav-link { padding: 0.35rem 0.55rem; font-size: 0.8rem; }
}
@media (max-width: 360px) {
  .a4-page { zoom: 0.34; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 打印样式 ===== */
@media print {
  .top-nav, .tab-bar, .form-card, .preview-card .card-header { display: none !important; }
  .preview-body { background: #fff; padding: 0; max-height: none; }
  .a4-page { box-shadow: none; transform: none !important; zoom: 1 !important; }
}
