/* =========================================================================
   江苏高校科技成果转化管理系统 — 公共样式（蓝白科技风）
   ========================================================================= */

:root {
  --primary: #1f6fff;
  --primary-hover: #3d84ff;
  --primary-active: #1559d6;
  --primary-soft: #eaf2ff;
  --primary-deep: #0b2f7a;
  --cyan: #22b8f0;
  --success: #12a77a;
  --warning: #e8901c;
  --danger: #e5484d;
  --danger-soft: #fdecec;

  --bg: #f2f6fc;
  --bg-grad: linear-gradient(180deg, #e8f0fd 0, #f4f7fc 260px);
  --card: #ffffff;
  --border: #dde6f3;
  --border-strong: #c7d5ea;
  --text: #1b2a41;
  --text-2: #4a5b75;
  --text-3: #8392aa;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 10px rgba(22, 64, 140, 0.06), 0 1px 2px rgba(22, 64, 140, 0.04);
  --shadow-lg: 0 18px 48px rgba(11, 36, 90, 0.18);
  --header-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", Roboto, sans-serif;
  --mono: "DIN Alternate", "Bahnschrift", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-repeat: no-repeat;
  min-width: 1280px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 顶部导航 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 28px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(100deg, #082a6b 0%, #0f4bc0 55%, #1b6cf0 100%);
  box-shadow: 0 2px 14px rgba(8, 42, 107, 0.25);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; letter-spacing: 1px; font-weight: 600; }
.brand-text em { font-style: normal; font-size: 10px; letter-spacing: 0.5px; opacity: 0.65; }
.nav { display: flex; gap: 6px; height: 100%; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  transition: color .2s, background .2s;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-link.active { color: #fff; font-weight: 600; background: rgba(255, 255, 255, 0.12); }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 18px; right: 18px; bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, #6fe0ff, #ffffff);
  box-shadow: 0 0 10px rgba(111, 224, 255, 0.8);
}
.source-switch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 14px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s;
}
.source-switch:hover { background: rgba(255, 255, 255, 0.2); }
.source-switch .dot { width: 8px; height: 8px; border-radius: 50%; }
.source-switch.is-mock .dot { background: #ffc857; box-shadow: 0 0 8px #ffc857; }
.source-switch.is-live .dot { background: #3ef0a6; box-shadow: 0 0 8px #3ef0a6; }

/* ---------------------------------------------------------------- 页面框架 */
.page { max-width: 1680px; margin: 0 auto; padding: 20px 28px 36px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-title h1 { margin: 0; font-size: 22px; font-weight: 600; color: var(--primary-deep); }
.page-title p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  position: relative;
  margin: 0;
  padding-left: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-title::before {
  content: "";
  position: absolute;
  left: 0; top: 3px; bottom: 3px;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--primary));
}
.card-sub { color: var(--text-3); font-size: 12px; }
.card-body { padding: 16px 20px; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
}
.btn:hover { color: var(--primary); border-color: var(--primary); }
.btn:focus-visible { outline: 2px solid rgba(31, 111, 255, 0.35); outline-offset: 1px; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { color: #fff; border-color: var(--primary); background: linear-gradient(180deg, #3a82ff, var(--primary)); box-shadow: 0 2px 6px rgba(31, 111, 255, 0.25); }
.btn-primary:hover { color: #fff; border-color: var(--primary-hover); background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-ghost { color: var(--primary); border-color: rgba(31, 111, 255, 0.45); background: var(--primary-soft); }
.btn-ghost:hover { background: #dbe8ff; }
.btn-success { color: #fff; border-color: var(--success); background: var(--success); }
.btn-success:hover { color: #fff; border-color: #17b98a; background: #17b98a; }
.btn-danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.btn-danger:hover { color: #fff; border-color: #f0646a; background: #f0646a; }
.btn-warn-outline { color: var(--warning); border-color: rgba(232, 144, 28, 0.5); background: #fff8ee; }
.btn-warn-outline:hover { color: #fff; border-color: var(--warning); background: var(--warning); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 13px; }
.btn-link { height: auto; padding: 0 4px; border: 0; background: none; color: var(--primary); }
.btn-link:hover { color: var(--primary-hover); border: 0; text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn .ico { font-size: 15px; line-height: 1; }

/* ---------------------------------------------------------------- 表单 */
.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.select { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238392aa' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; }
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: #a9bfe0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 255, 0.12); }
.input::placeholder, .textarea::placeholder { color: #a7b3c6; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.form-item { display: flex; flex-direction: column; min-width: 0; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { margin-bottom: 4px; color: var(--text-2); font-size: 13px; }
.form-item label .req { color: var(--danger); margin-right: 2px; }
.form-item .hint { color: var(--text-3); font-size: 12px; font-weight: normal; margin-left: 4px; }
.form-error { min-height: 20px; color: var(--danger); font-size: 12px; line-height: 20px; }
.form-item.has-error .input,
.form-item.has-error .select,
.form-item.has-error .textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.1); }
.form-section {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 13px;
  font-weight: 600;
}
.form-section small { color: var(--text-3); font-weight: normal; }

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag::before { content: ""; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.tag-none { color: #5f7393; background: #eef2f8; border-color: #dbe3ef; }
.tag-talk { color: #c2730a; background: #fff5e6; border-color: #fde0b3; }
.tag-done { color: #0c8d66; background: #e6f8f1; border-color: #b7ebd8; }
.trl-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--primary-deep);
}
.trl-badge small { font-family: var(--font); font-weight: normal; font-size: 12px; padding: 0 6px; border-radius: 4px; }
.stage-rd { color: #0b87b8; background: #e4f6fd; }
.stage-pilot { color: #1f5fd6; background: #e8f0ff; }
.stage-ind { color: #5b33d6; background: #efeaff; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #edf1f7; white-space: nowrap; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f8fe;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f5f9ff; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.center, .table th.center { text-align: center; }
.table .cell-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.table .cell-title a { color: var(--text); font-weight: 500; }
.table .cell-title a:hover { color: var(--primary); }
.table .muted { color: var(--text-3); }
.th-sort { cursor: pointer; }
.th-sort:hover { color: var(--primary); }
.sort-ind { display: inline-flex; flex-direction: column; vertical-align: middle; margin-left: 4px; line-height: 0; }
.sort-ind i { width: 0; height: 0; border: 4px solid transparent; }
.sort-ind .up { border-bottom-color: #b5c2d6; margin-bottom: 2px; }
.sort-ind .down { border-top-color: #b5c2d6; }
.th-sort.asc .sort-ind .up { border-bottom-color: var(--primary); }
.th-sort.desc .sort-ind .down { border-top-color: var(--primary); }

/* ---------------------------------------------------------------- 分页 */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; flex-wrap: wrap; }
.pagination .summary { color: var(--text-3); }
.pagination .summary b { color: var(--primary); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-2); cursor: pointer;
}
.pager button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.pager button.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.pager button:disabled { cursor: not-allowed; color: #c0c9d8; }
.pager .ellipsis { color: var(--text-3); padding: 0 2px; }
.pager .select { width: 96px; height: 32px; }
.pager .jump { display: flex; align-items: center; gap: 6px; color: var(--text-3); margin-left: 6px; }
.pager .jump .input { width: 56px; height: 32px; text-align: center; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  overflow-y: auto;
  background: rgba(10, 26, 58, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .2s;
}
.modal-mask.show { opacity: 1; }
.confirm-mask { z-index: 1100; align-items: center; }
.modal {
  width: 760px;
  max-width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-8px);
  transition: transform .2s;
}
.modal-mask.show .modal { transform: none; }
.modal-sm { width: 420px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, #f1f6ff, #fff);
}
.modal-header h3 { margin: 0; font-size: 16px; color: var(--primary-deep); }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--text-3); font-size: 20px; cursor: pointer; }
.modal-close:hover { background: #eef3fb; color: var(--text); }
.modal-body { padding: 18px 22px 6px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.confirm-msg { margin: 4px 0 14px; color: var(--text-2); }

.detail-grid { display: grid; grid-template-columns: 110px 1fr 110px 1fr; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 16px; }
.detail-grid dt, .detail-grid dd { margin: 0; padding: 9px 12px; border-bottom: 1px solid #edf1f7; }
.detail-grid dt { background: #f5f8fe; color: var(--text-3); font-size: 13px; }
.detail-grid dd { word-break: break-all; }
.detail-grid .wide { grid-column: 2 / -1; }

/* ---------------------------------------------------------------- Toast */
.toast-host { position: fixed; top: 76px; left: 50%; z-index: 2000; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 560px;
  padding: 10px 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(11, 36, 90, 0.18);
  border-left: 4px solid var(--primary);
  opacity: 0;
  transform: translateY(-10px);
  transition: all .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; background: var(--primary); flex: none; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning); }

/* ---------------------------------------------------------------- Loading / 状态 */
.has-loading { position: relative; }
.loading-layer {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.72);
  border-radius: inherit;
  font-size: 13px;
}
.spinner { width: 30px; height: 30px; border: 3px solid rgba(31, 111, 255, 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.state-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; min-height: 160px; padding: 24px; text-align: center; color: var(--text-3); }
.state-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 22px; background: #eef3fb; color: #9fb0c9; }
.state-error .state-icon { background: var(--danger-soft); color: var(--danger); }
.state-title { color: var(--text-2); font-weight: 600; }
.state-desc { font-size: 12px; max-width: 420px; }
.state-retry { margin-top: 6px; }

#page-banner { margin-bottom: 14px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid #f7c4c6; background: var(--danger-soft); color: #b42d32; }
.banner-text { font-weight: 600; }
.banner-hint { color: #c25a5e; font-size: 13px; }
.banner .btn { margin-left: auto; }
.banner-warning { border-color: #fde0b3; background: #fff6e8; color: #9a5a05; }

/* ---------------------------------------------------------------- 分析页 */
.filter-inline { display: flex; align-items: center; gap: 10px; }
.filter-inline label { color: var(--text-2); white-space: nowrap; }
.filter-inline .select { width: 180px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mt-16 { margin-top: 16px; }
.chart { width: 100%; height: 300px; }
.chart-lg { height: 340px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi {
  position: relative;
  overflow: hidden;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff 0%, #f1f6ff 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.kpi::after { content: ""; position: absolute; right: -24px; top: -24px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(47, 123, 255, 0.08), transparent 70%); }
.kpi-label { color: var(--text-3); font-size: 13px; }
.kpi-value { margin-top: 4px; font-family: var(--mono); font-size: 28px; font-weight: 700; color: var(--primary-deep); }
.kpi-value small { margin-left: 4px; font-family: var(--font); font-size: 13px; font-weight: normal; color: var(--text-3); }

.rank-no { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: #eef2f8; color: var(--text-3); font-size: 12px; font-weight: 700; }
.rank-no.top1 { background: linear-gradient(135deg, #ffcf5c, #f39c12); color: #fff; }
.rank-no.top2 { background: linear-gradient(135deg, #c8d6ea, #8ea3c4); color: #fff; }
.rank-no.top3 { background: linear-gradient(135deg, #f3b98a, #d9823f); color: #fff; }
.rate-bar { display: inline-flex; align-items: center; gap: 8px; min-width: 150px; }
.rate-bar .track { flex: 1; height: 6px; border-radius: 3px; background: #e9eff8; overflow: hidden; }
.rate-bar .fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cyan), var(--primary)); }
.rate-bar span { width: 48px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

@media (max-width: 1440px) {
  .page { padding: 16px 20px 28px; }
  .brand-text em { display: none; }
  .app-header { gap: 20px; padding: 0 20px; }
  .nav-link { padding: 0 14px; }
  .chart { height: 270px; }
}

/* 操作列固定在右侧，窄屏下横向滚动时仍可编辑/删除 */
.table th.col-ops, .table td.col-ops {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -6px 0 8px -6px rgba(22, 64, 140, 0.18);
}
.table th.col-ops { z-index: 3; background: #f5f8fe; }
.table tbody tr:hover td.col-ops { background: #f5f9ff; }

@media (max-width: 1440px) {
  .table th, .table td { padding: 10px 8px; }
  .table .cell-title { max-width: 220px; }
}

/* ---- 权限：只读账号隐藏写操作；生产环境隐藏“重置演示数据” ---- */
body.is-readonly #btn-create,
body.is-readonly #detail-edit,
body.is-readonly [data-act="edit"],
body.is-readonly [data-act="delete"],
body.no-demo-seed #btn-seed { display: none !important; }
