/* ==========================================================================
   光和项目管理系统 ghpm —— 全局样式
   手写 CSS（不引 Tailwind CDN）：公司家宽/车间弱网下 CDN 不可达会导致整页样式崩塌
   ========================================================================== */

:root {
  /* 主色 */
  --c-primary: #1B4F9C;
  --c-primary-light: #3A72C9;
  --c-accent: #E8823A;
  /* 背景 */
  --bg-page: #F4F6FA;
  --bg-card: #FFFFFF;
  --bg-soft: #EEF1F7;
  /* 文字 */
  --tx-main: #1F2937;
  --tx-muted: #6B7280;
  --tx-inv: #FFFFFF;
  /* 功能色 */
  --ok: #2E9E5B;
  --warn: #E3A008;
  --danger: #D64545;
  --info: #2F6FD0;
  /* 边框/阴影/圆角 */
  --bd: #E3E8F0;
  --bd-strong: #D3DAE6;
  --shadow-sm: 0 1px 3px rgba(27, 79, 156, .06);
  --shadow-md: 0 4px 16px rgba(27, 79, 156, .10);
  --shadow-lg: 0 8px 32px rgba(27, 79, 156, .14);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --font: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--tx-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 顶栏 ── */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 20px;
  background: linear-gradient(90deg, #1B4F9C 0%, #2C63B8 100%);
  color: var(--tx-inv);
  box-shadow: var(--shadow-md);
}
.topnav .brand {
  font-size: 16px; font-weight: 600; letter-spacing: .5px; white-space: nowrap;
}
.topnav .brand small { opacity: .75; font-weight: 400; margin-left: 8px; font-size: 12px; }
.topnav nav { display: flex; gap: 4px; flex: 1; }
.topnav nav a {
  color: rgba(255, 255, 255, .82);
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 14px; transition: background .15s, color .15s;
}
.topnav nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.topnav nav a.active { background: rgba(255, 255, 255, .20); color: #fff; font-weight: 500; }
.topnav .user {
  display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap;
}
.topnav .user .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.topnav .user .logout {
  color: rgba(255, 255, 255, .8); cursor: pointer; font-size: 12px; padding: 4px 8px;
  border-radius: var(--r-sm); background: rgba(255, 255, 255, .10); border: none;
}
.topnav .user .logout:hover { background: rgba(255, 255, 255, .2); }

/* ── 布局 ── */
.wrap { max-width: 1440px; margin: 0 auto; padding: 18px 20px 60px; }
.section { margin-bottom: 22px; }
.section-title {
  font-size: 15px; font-weight: 600; margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--c-primary);
}

/* ── 卡片 ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bd);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card-hover { transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-primary-light);
}

/* ── 统计数字卡 ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat {
  background: var(--bg-card); border: 1px solid var(--bd); border-radius: var(--r-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 70px; height: 70px; border-radius: 50%; background: var(--bg-soft);
}
.stat .label { font-size: 12px; color: var(--tx-muted); margin-bottom: 6px; }
.stat .value {
  font-family: var(--font-mono); font-size: 28px; font-weight: 600;
  color: var(--c-primary); line-height: 1.1;
}
.stat .sub { font-size: 12px; color: var(--tx-muted); margin-top: 4px; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid var(--bd-strong);
  background: #fff; color: var(--tx-main); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
}
.btn-primary:hover { background: #17437F; }
.btn-danger { color: var(--danger); border-color: #F0C0C0; }
.btn-danger:hover { background: #FDF2F2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── 表单 ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--tx-muted); }
.input, select.input, textarea.input {
  padding: 8px 11px; border: 1px solid var(--bd-strong); border-radius: var(--r-sm);
  font-size: 13px; font-family: inherit; background: #fff; color: var(--tx-main);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none; border-color: var(--c-primary-light);
  box-shadow: 0 0 0 3px rgba(58, 114, 201, .14);
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar .field { margin-bottom: 0; min-width: 130px; }

/* ── 徽章 / 健康灯 ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 18px; background: var(--bg-soft); color: var(--tx-muted);
}
.badge-primary { background: #E7EEFA; color: var(--c-primary); }
.badge-ok { background: #E6F5EC; color: var(--ok); }
.badge-warn { background: #FDF4E0; color: var(--warn); }
.badge-danger { background: #FCECEC; color: var(--danger); }
.badge-info { background: #E8F0FC; color: var(--info); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(214, 69, 69, .55); }
  50% { opacity: .75; box-shadow: 0 0 0 5px rgba(214, 69, 69, 0); }
}

/* ── 项目卡片网格 ── */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.proj-card { position: relative; padding: 16px 16px 14px; }
.proj-card .head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.proj-card .code {
  font-family: var(--font-mono); font-size: 11px; color: var(--tx-muted);
  background: var(--bg-soft); padding: 2px 6px; border-radius: 4px;
}
.proj-card .name { font-size: 15px; font-weight: 600; margin: 0 0 4px; line-height: 1.35; }
.proj-card .meta { font-size: 12px; color: var(--tx-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.proj-card .foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--bd);
  font-size: 12px; color: var(--tx-muted);
}
.proj-card .health { position: absolute; right: 14px; top: 16px; }
.proj-card .amount { font-family: var(--font-mono); color: var(--c-primary); font-weight: 600; }

/* 进度环 */
.ring { width: 42px; height: 42px; flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: var(--bg-soft); }
.ring .fg { stroke: var(--c-primary); stroke-linecap: round; transition: stroke-dasharray .4s ease; }

/* ── 表格 ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--bd);
}
.table th { color: var(--tx-muted); font-weight: 500; font-size: 12px; background: var(--bg-soft); }
.table tbody tr:hover { background: #FAFBFE; }
.table .num { font-family: var(--font-mono); text-align: right; }

/* ── 任务板三列 ── */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.board-col {
  background: var(--bg-soft); border-radius: var(--r-md); padding: 10px; min-height: 80px;
}
.board-col h4 { margin: 4px 4px 10px; font-size: 13px; color: var(--tx-muted); font-weight: 600; }
.task-card {
  background: #fff; border: 1px solid var(--bd); border-left: 3px solid var(--c-primary-light);
  border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .12s;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card.urgent { border-left-color: var(--danger); }
.task-card.high { border-left-color: var(--accent); }
.task-card.overdue { background: #FFF8F8; }
.task-card .t { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.task-card .m { display: flex; justify-content: space-between; font-size: 11px; color: var(--tx-muted); }

/* ── 甘特容器 ── */
.gantt-wrap { overflow-x: auto; background: #fff; border-radius: var(--r-md); }
.gantt-fallback { padding: 12px; font-size: 13px; color: var(--tx-muted); }
.gantt-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }

/* ── 时间轴 ── */
.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px;
  width: 1px; background: var(--bd-strong);
}
.timeline .item { position: relative; padding: 5px 0; font-size: 12.5px; }
.timeline .item::before {
  content: ""; position: absolute; left: -17px; top: 11px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--c-primary-light);
}
.timeline .item .time { color: var(--tx-muted); font-size: 11px; margin-right: 6px; }

/* ── 甘特微调（frappe-gantt 之上的覆盖） ── */
.gantt .bar { fill: var(--c-primary-light); }
.gantt .bar-progress { fill: var(--c-primary); }
.gantt .today-highlight { fill: rgba(232, 130, 58, .10); }
.gantt-overdue .bar { fill: #EFA9A9; }
.gantt-overdue .bar-progress { fill: var(--danger); }
.gantt-done .bar { fill: #BFE0CC; }
.gantt-done .bar-progress { fill: var(--ok); }
.gantt .bar-label { font-size: 11px; }

/* ── 骨架屏 / 空态 / 错误 ── */
.skeleton {
  background: linear-gradient(90deg, #EEF1F7 25%, #F7F9FC 37%, #EEF1F7 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite;
  border-radius: var(--r-sm); height: 14px; margin: 8px 0;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { padding: 26px; text-align: center; color: var(--tx-muted); font-size: 13px; }
.alert {
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-warn { background: #FDF6E7; border-color: #F2E2BC; color: #8A6510; }
.alert-danger { background: #FCECEC; border-color: #F3C9C9; color: #9E2F2F; }
.alert-info { background: #E9F1FC; border-color: #C8DBF5; color: #1F4E8C; }

/* ── 登录页 ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EEF2F9 0%, #F7F9FC 55%, #EDF1F8 100%);
  padding: 20px;
}
.login-card {
  display: flex; width: 780px; max-width: 100%; background: #fff;
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-brand {
  flex: 1; padding: 40px 34px; color: #fff;
  background: linear-gradient(160deg, #1B4F9C 0%, #2E66BC 60%, #3A72C9 100%);
  display: flex; flex-direction: column; justify-content: center;
}
.login-brand h1 { font-size: 24px; font-weight: 600; margin: 0 0 10px; }
.login-brand p { font-size: 13px; line-height: 1.8; opacity: .85; margin: 6px 0; }
.login-brand .tag {
  margin-top: 20px; font-size: 11px; opacity: .7; border-top: 1px solid rgba(255, 255, 255, .25);
  padding-top: 12px;
}
.login-form { flex: 1; padding: 40px 34px; }
.login-form h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.login-form .hint { font-size: 12px; color: var(--tx-muted); margin-bottom: 22px; }
.login-form .btn-primary { width: 100%; justify-content: center; margin-top: 8px; }

/* ── 弹窗 ── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 30, 48, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 88vh; overflow: auto; padding: 20px 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── 响应式 ── */
@media (max-width: 980px) {
  .board { grid-template-columns: 1fr; }
  .login-card { flex-direction: column; width: 420px; }
  .login-brand { padding: 26px; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .topnav { height: auto; flex-wrap: wrap; padding: 8px 12px; }
  .topnav nav { order: 3; width: 100%; overflow-x: auto; }
  .wrap { padding: 14px 12px 40px; }
}
