:root {
  --bg: transparent;
  --surface: rgba(255, 255, 255, 0.9);
  --ink: #1e293b;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #1d4ed8;
  --accent: #f59e0b;
  --line: #e2e8f0;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--ui-bg, #f8fafc);
}

.container {
  max-width: 1100px;
  margin: 28px auto 64px;
  padding: 0 20px;
}

/* ===== 頁首 ===== */
.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

/* ===== 頁籤 toolbar ===== */
.review-toolbar {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 24px;
  overflow-x: auto;
}

.tab {
  padding: 12px 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ===== 清單容器 ===== */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== 審核卡片 – 完全複製 history-item 風格 ===== */
.review-item.history-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.02);
  overflow: hidden;
}

.review-item.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

/* 覆寫 details > summary 的預設箭頭 */
.review-item.history-item > summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  cursor: pointer;
}
.review-item.history-item > summary::-webkit-details-marker { display: none; }

/* 展開時 chevron 旋轉 90° */
.review-item.history-item[open] .history-chevron {
  transform: rotate(90deg);
  color: var(--brand);
}

/* ===== history-item 共用子元件 ===== */
.history-summary-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.history-summary-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.history-summary-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-summary-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

.history-summary-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-summary-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.history-hours {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.history-hours-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}

.history-hours-lbl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}

.history-chevron {
  color: #94a3b8;
  transition: transform 0.25s ease, color 0.25s ease;
  display: flex;
}

/* ===== Badge ===== */
.history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: #1f2937;
}

.history-badge.in {
  background: #dbeafe;
  color: #1d4ed8;
}

.history-badge.out {
  background: #fef3c7;
  color: #b45309;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
}

.status-badge.pending  { background: #fef3c7; color: #92400e; }
.status-badge.approved { background: #dcfce7; color: #166534; }
.status-badge.rejected { background: #fee2e2; color: #991b1b; }

/* ===== 展開後的審核區塊 ===== */
.review-detail {
  padding: 24px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lbl {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}

textarea { min-height: 68px; resize: vertical; }

.review-link-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  color: inherit;
  text-decoration: none;
}

@media (max-width: 900px) {
  .review-link-card {
    align-items: flex-start;
  }

  .history-summary-right {
    gap: 12px;
  }
}

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn.primary:hover { background: #1e40af; }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,0.04); }

/* ===== 附件連結 ===== */
.attachment-links { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-link {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  text-decoration: none;
  font-size: 12px;
}
.attachment-link:hover { background: #e5e7eb; }

/* ===== 狀態歷程 ===== */
.status-history { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}
.history-status { display: inline-block; font-weight: 700; margin-right: 10px; }
.history-meta   { font-size: 12px; color: var(--muted); }
.history-reason { margin-top: 4px; white-space: pre-wrap; font-size: 13px; }

/* ===== Misc ===== */
.msg    { min-height: 20px; font-size: 14px; font-weight: 600; color: #10b981; }
.muted  { color: var(--muted); }

/* ===== 重新整理按鈕 ===== */
#btnReviewRefresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .review-grid { grid-template-columns: 1fr; }
  .history-summary-right { flex-wrap: wrap; gap: 12px; }
}
