:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --brand: #0f766e; --brand-d: #0b5e57; --accent: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Noto Sans TC", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: #fff; padding: 12px 22px; flex-wrap: wrap; gap: 10px;
}
.brand { font-size: 18px; font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: #e6fffb; font-weight: 500; }
main { max-width: 1180px; margin: 22px auto; padding: 0 18px; }
footer { text-align: center; color: var(--muted); padding: 28px; font-size: 12px; }

/* 統計卡 */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 20px; min-width: 110px; text-align: center;
}
.stat-card.highlight { border-color: var(--accent); }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* 表單 / 篩選 */
.filters, .row, .stack { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.stack { flex-direction: column; max-width: 640px; }
.stack .row { margin-bottom: 0; }
input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
input { min-width: 160px; }
textarea { width: 100%; resize: vertical; }

.btn {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 14px; color: var(--ink);
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; padding: 2px 4px; }
.btn-link.danger, .danger { color: var(--accent); }
.inline { display: inline; } .right { float: right; }

/* 表格 */
.grid { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { background: #f0f3f6; font-size: 12px; color: var(--muted); }
.grid tbody tr:hover { background: #fafbfc; }
.grid.sm th, .grid.sm td { padding: 7px 9px; font-size: 13px; }
.row-new { background: #fff8f1; }
.dim { opacity: .5; }
.empty { text-align: center; color: var(--muted); padding: 20px; }
.ops { white-space: nowrap; }

.tag { display: inline-block; background: #e0f2f1; color: var(--brand-d);
  padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 5px; }

/* 狀態色 */
.status { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px;
  background: #eef2f7; color: #374151; }
.status-未結標 { background: #fef3c7; color: #92400e; }
.status-已得標, .status-完成 { background: #dcfce7; color: #166534; }
.status-未得標, .status-逾期 { background: #fee2e2; color: #991b1b; }
.status-結案 { background: #e0e7ff; color: #3730a3; }
.status-進行中 { background: #dbeafe; color: #1e40af; }

/* 明細頁 */
.back { display: inline-block; margin-bottom: 10px; }
.detail-head h1 { margin: 6px 0; font-size: 22px; }
.detail-head .meta { display: flex; gap: 12px; align-items: center; color: var(--muted); flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; width: 90px; padding: 5px 0; vertical-align: top; }
.kv td { padding: 5px 0; }
.inline-form { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.note { border-left: 3px solid var(--brand); background: #f8fafb; padding: 8px 12px; margin-bottom: 10px; border-radius: 0 6px 6px 0; }
.note-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.note-body { margin-top: 4px; white-space: pre-wrap; }
.muted { color: var(--muted); }

/* TFDA 資料集狀態卡 */
.tfda-status { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.ds-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.ds-card span { font-weight: 700; color: var(--brand-d); }

@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
