/* ==========================================================================
   鸟撞数据详情 · 样式
   配色与工作台（/static/styles.css）保持一致，避免两个页面像两个产品。
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --panel: #ffffff;
  --line: #d8e2dc;
  --line-soft: #e9f0eb;
  --text: #17211d;
  --muted: #61706a;
  --faint: #9aaba3;
  --green: #1f5f4a;
  --green-mid: #2e7d5b;
  --green-soft: #e3f0ea;
  --red: #9c2f2f;
  --red-soft: #f8eaea;
  --amber: #916b1e;
  --amber-soft: #fbf2dd;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
  --shadow: 0 1px 2px rgba(23, 33, 29, .05), 0 8px 24px rgba(23, 33, 29, .05);
}

* { box-sizing: border-box; }

/* 关键：.routes-grid / .panel 等设置了 display，会盖掉 [hidden] 的默认 display:none */
[hidden] { display: none !important; }


html { -webkit-text-size-adjust: 100%; }

/* body 的字体、行高、配色、两栏栅格全部来自 /static/styles.css。
   这里曾经写过 body{font:15px/1.6}，导致本页比工作台小一号、行距也更松，
   从工作台点进来会有"整页缩了一下"的错觉。别再写回来。 */

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
/* 顶栏、侧边栏、面板外壳统一由 /static/styles.css + /static/workspace.css 提供，
   本页不再自己写 position/padding/背景，否则会跟工作台差一层。 */

/* ---------- 主体 ---------- */

/* ---------- 工具条 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 300px;
  flex: 1 1 300px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 15px;
  pointer-events: none;
}

input, select, button, textarea {
  font: inherit;
  color: inherit;
}

.search input {
  width: 100%;
  padding: 9px 12px 9px 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfdfc;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input:focus {
  border-color: var(--green-mid);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(46, 125, 91, .13);
}
.search input::placeholder { color: var(--faint); }

.select select {
  padding: 9px 30px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfdfc url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4.5 6 8.5 10 4.5' fill='none' stroke='%2361706a' stroke-width='1.5' stroke-linecap='round'/></svg>") no-repeat right 10px center;
  appearance: none;
  cursor: pointer;
}
.select select:focus { border-color: var(--green-mid); outline: none; box-shadow: 0 0 0 3px rgba(46, 125, 91, .13); }

/* 按钮配色统一走 workbench 的 .ghost / .primary，本页只补键盘焦点环 */
button:focus-visible { outline: 2px solid var(--green-mid); outline-offset: 2px; }

.link { font-size: 13px; color: var(--muted); padding: 6px 2px; white-space: nowrap; }
.link:hover { color: var(--green); }

/* ---------- 状态行 ---------- */

#message {
  margin: 0 0 14px;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}
#message.error { color: var(--red); font-weight: 600; }

/* ---------- 标签页（分段控件） ---------- */

.tabs {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  gap: 2px;
  padding: 4px;
  margin-bottom: 14px;
  background: #e9f0eb;
  border-radius: 11px;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  padding: 7px 16px;
  border-radius: 8px;
  white-space: nowrap;
}
.tabs button:hover { background: rgba(255, 255, 255, .6); color: var(--green); }
.tabs button.is-active {
  background: #fff;
  color: var(--green);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(23, 33, 29, .1);
}

.tab-note {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(97, 112, 106, .12);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  min-height: 240px;
  border-radius: var(--radius);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 14px;
  background: #f0f5f2;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f6faf8; }

/* 首列（记录编号）横向冻结 */
thead th:first-child,
tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}
thead th:first-child { z-index: 3; background: #f0f5f2; }
tbody tr:hover td:first-child { background: #f6faf8; }

/* 记录编号按钮：看起来像可点的短编号，而不是 UUID */
tbody td:first-child button {
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
}
tbody td:first-child button:hover { background: #d2e8dd; }

.dash { color: #b9c7bf; }

/* 状态小标签 */
.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  background: #eef4f0;
  color: var(--muted);
  white-space: nowrap;
}
.chip--green { background: var(--green-soft); color: var(--green); }
.chip--amber { background: var(--amber-soft); color: var(--amber); }
.chip--red { background: var(--red-soft); color: var(--red); }

/* 空表提示 */
.empty-cell {
  padding: 44px 16px !important;
  text-align: center;
  color: var(--muted);
  white-space: normal;
}

/* ---------- 路线与轨迹 ---------- */

.routes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 15.5px;
  letter-spacing: -.005em;
}

.card p { margin: 4px 0; color: var(--muted); font-size: 13px; }

.card .track {
  width: 100%;
  height: auto;
  margin: 12px 0;
  background: #f0f5f2;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.card button {
  margin-top: 8px;
  font-size: 13px;
  padding: 0 12px;
  background: var(--green-soft);
  color: var(--green);
}

/* ---------- 原 Excel 主表 ---------- */

.reference { padding: 16px 18px 18px; }
.reference .table-wrap { max-height: calc(100vh - 340px); }
.reference table { font-size: 12.5px; }
.reference td { max-width: 260px; }

/* ---------- 详情弹窗 ---------- */

dialog {
  width: min(1080px, 94vw);
  max-height: 88vh;
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 40, 30, .28);
  color: var(--text);
  overflow: hidden;
}

dialog::backdrop { background: rgba(15, 40, 30, .45); backdrop-filter: blur(2px); }

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-title { font-size: 13px; color: var(--muted); letter-spacing: .03em; }

.icon-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  line-height: 1.4;
}
.icon-btn:hover { background: var(--red-soft); border-color: #e6c9c9; color: var(--red); }

#detailBody {
  max-height: calc(88vh - 53px);
  overflow: auto;
  padding: 20px 26px 30px;
}

#detailBody h2 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
#detailBody h2 + p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

#detailBody h3 {
  margin: 26px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--text);
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 18px;
}

.fields > div {
  padding: 10px 12px;
  background: #f8fbf9;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  min-width: 0;
}

.fields strong {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .03em;
}

.fields > div > div { font-size: 13.5px; overflow-wrap: anywhere; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

label input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
label input:focus { border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(46, 125, 91, .13); }

.photos { display: flex; gap: 12px; flex-wrap: wrap; }
.photos a { text-decoration: none; }
.photos figure { margin: 0; }
.photos img {
  width: 168px;
  height: 126px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: #eef4f0;
  display: block;
  transition: transform .12s;
}
.photos a:hover img { transform: scale(1.02); }
.photos figcaption { margin-top: 4px; color: var(--muted); font-size: 12px; text-align: center; }

#researchForm { margin: 0; }
/* 表单里的标签长短不一，底对齐才能让输入框排成一条线 */
#researchForm .fields { align-items: end; }

#researchForm > p { margin: 14px 0 0; }
#saveState { color: var(--green); font-size: 13px; min-height: 18px; }

.hint { color: var(--muted); font-size: 12.5px; }
.error { color: var(--red); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  .topbar { padding: 16px 18px 14px; flex-direction: column; gap: 8px; }
  .topbar-side { padding-top: 0; }
  main { padding: 16px 18px 48px; }
  .toolbar { padding: 10px; }
  .search { min-width: 100%; }
  .tabs { width: 100%; overflow-x: auto; }
  .routes-grid { grid-template-columns: 1fr; }
  .table-wrap { max-height: none; }
  tbody td { max-width: 200px; }
  #detailBody { padding: 16px 18px 24px; }
}

/* Keep the original workbench frame on every data view. */
.workspace { min-width:0; width:auto; max-width:none; margin:0; padding:28px; }
.workspace .topbar { position:static; padding:0; margin:0 0 22px; background:transparent; backdrop-filter:none; border:0; }
.workspace .topbar-main { gap:0; }
.workspace .topbar h1 { font-size:28px; }
.workspace .topbar p { font-size:14px; }
.workspace .topbar-side { padding-top:0; }
.workspace .workspace-content { padding:0; }
.workspace .panel,.workspace .card { box-shadow:none; border-radius:8px; border-color:var(--line); }
.workspace .toolbar { margin-bottom:12px; padding:16px; }
.workspace .tabs { display:flex; grid-template-columns:none; gap:8px; margin:16px 0; }
.workspace .tabs button { border-radius:8px; }
.workspace .table-wrap { max-height:66vh; }
.workspace #routes { display:block; }
.sidebar a { text-decoration:none; }
.sidebar .brand { margin-bottom:28px; }
.workspace button,.workspace input,.workspace select,.workspace textarea { font-family:inherit; }
.workspace .fields { grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); }
.workspace .field-label { color:var(--muted); }
@media(max-width:860px){.workspace{padding:16px}.workspace .topbar h1{font-size:23px}.workspace .toolbar{padding:12px}.workspace .tool-group{min-width:0;flex-wrap:wrap}.workspace .search{min-width:0;width:100%}.workspace .tabs{flex-wrap:wrap}.workspace .tabs button{padding:9px 10px;font-size:13px}.workspace .fields{grid-template-columns:1fr}}
.workspace .search-icon{display:none}.workspace table td,.workspace table td button{font-family:inherit;font-variant-numeric:tabular-nums}.workspace .search input{padding-left:12px}

.statistics-panel{padding:22px;margin-bottom:22px}.stat-heading{display:flex;justify-content:space-between;gap:18px;align-items:start;flex-wrap:wrap}.stat-heading h2{margin:0;font-size:21px}.stat-heading p{margin:6px 0;color:var(--muted)}.stat-heading label{font-size:13px}.stat-heading input{width:auto}.stat-heading select{width:auto;padding:7px}.stat-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;margin:20px 0}.stat-chart{min-width:0}.stat-chart h3{font-size:15px;margin:0 0 12px}.stat-bars{max-height:320px;overflow:auto;padding-right:8px}.stat-row{display:grid;grid-template-columns:minmax(85px,42%) 1fr 34px;align-items:center;gap:10px;margin:9px 0;font-size:12px}.stat-row>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.stat-row>div{background:#edf3ef;height:11px;border-radius:3px;overflow:hidden}.stat-row i{display:block;height:100%;background:#28634e}.stat-row strong{text-align:right;font-variant-numeric:tabular-nums}.stat-chart:nth-child(2) i{background:#5c8072}.stat-chart:nth-child(3) i{background:#697b91}.stat-chart:nth-child(4) i{background:#b08448}#statNote{line-height:1.7}@media(max-width:900px){.stat-grid{grid-template-columns:1fr}}

.stat-heading input[type="checkbox"]{appearance:auto;width:16px;height:16px;min-height:0;padding:0;margin:0 5px;vertical-align:middle}.stat-heading .tool-group{align-items:center}

/* Internal research analysis: controls and data quality stay in view. */
.statistics-panel{padding:28px}.stat-heading{margin-bottom:22px}.stat-heading h2{font-size:19px}.stat-heading p{font-size:13px;line-height:1.6}.stat-filters{display:flex;flex-wrap:wrap;align-items:end;gap:12px;padding:18px;background:#f7f7fb;border:1px solid #ededf4;border-radius:12px}.stat-filters label{display:flex;flex-direction:column;gap:6px;color:#6d7185;font-size:12px}.stat-filters select{min-width:116px;max-width:230px;padding:9px 10px;background:#fff;border:1px solid #dfdfeb;border-radius:8px;color:#20243c}.stat-filters button{min-height:37px}.stat-quality{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1px;background:#e8e8f0;border:1px solid #e8e8f0;border-radius:12px;overflow:hidden;margin-top:20px}.stat-quality:empty{display:none}.stat-quality-item{display:flex;flex-direction:column;gap:5px;padding:17px 18px;background:#fff}.stat-quality-item span,.stat-quality-item small{color:#777a8e;font-size:12px}.stat-quality-item strong{font-size:22px;color:#010544;font-weight:650;font-variant-numeric:tabular-nums}.stat-grid{gap:1px;border:1px solid #ececf3;border-radius:12px;overflow:hidden;background:#ececf3}.stat-chart{background:#fff;padding:20px}.stat-chart h3{font-size:14px;color:#252943}.stat-row>div{background:#f0eff6}.stat-row i,.stat-chart:nth-child(n) i{background:#575484}.stat-method{margin-top:18px;color:#6e7186;font-size:13px}.stat-method summary{cursor:pointer}.stat-filters label[hidden]{display:none!important}@media(max-width:800px){.stat-quality{grid-template-columns:repeat(2,minmax(0,1fr))}.stat-grid{grid-template-columns:1fr}.statistics-panel{padding:18px}.stat-filters label{flex:1 1 130px}.stat-filters select{max-width:none;width:100%}}

.stat-records{padding:18px 20px;border:1px solid #ececf3;border-radius:12px;margin-top:20px}.stat-records:empty{display:none}.stat-records h3{font-size:15px;margin:0 0 5px}.stat-records p{font-size:12px;color:#777a8e}.stat-record-row{display:flex;align-items:center;gap:16px;padding:10px 0;border-top:1px solid #f0f0f5;font-size:13px}.stat-record-row>span:last-child{color:#6c7184;overflow-wrap:anywhere}.stat-record-link{padding:0;border:0;background:none;color:#51448b;font-size:13px;text-align:left;cursor:pointer;text-decoration:underline;text-underline-offset:3px}.stat-record-link:focus-visible{outline:2px solid #ce57c1;outline-offset:3px}
