/* ============================================================
   base.css —— 設計系統:純淨現代 App
   白底、圓角卡片、柔和陰影、大量留白。
   質感基準:Linear / 現代 iOS。
   狀態 = 柔和色藥丸(淡色底 + 飽和字 + 信號點),不再用滿版色帶。
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Noto+Sans+TC:wght@400;500;700;900&family=IBM+Plex+Mono:wght@500;600&display=swap");

:root {
  /* 底與面 */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;      /* 次級底:時間軸卡、縮圖底、hover */
  --ink: #171a20;
  --ink-soft: #5b6472;
  --ink-faint: #98a1b0;
  --line: #e7e9ef;           /* 髮絲線 */
  --line-strong: #d3d7e0;    /* 輸入框 / 按鈕邊 */

  /* 主色 */
  --primary: #2e6be6;
  --primary-strong: #2050b8;
  --primary-tint: #ecf2fe;

  --danger: #d92d20;
  --danger-tint: #fdecea;
  --ok: #15803d;
  --warn: #cf4307;

  /* 狀態 8 態:fg(飽和字/信號點) + bg(淡色底) */
  --st-pending: #cf4307;            --st-pending-bg: #ffefe4;
  --st-processing: #1b62d8;         --st-processing-bg: #e9f0fe;
  --st-need_second_round: #b45309;  --st-need_second_round-bg: #fdf3d8;
  --st-need_judgement: #9333ea;     --st-need_judgement-bg: #f6ecfe;
  --st-completed: #15803d;          --st-completed-bg: #e4f6ea;
  --st-returned_to_flow: #0d8599;   --st-returned_to_flow-bg: #e0f5f9;
  --st-scrapped: #3f4753;           --st-scrapped-bg: #eceff3;
  --st-paused: #6c7482;             --st-paused-bg: #f1f3f6;

  /* 字體 */
  --font-body: "Manrope", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* 形 */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 8px rgba(16, 24, 40, .05), 0 12px 32px rgba(16, 24, 40, .12);
  --gap: 16px;
  --tap: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ---------- 頂欄:白底毛玻璃 + 髮絲線 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 10px 20px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #3d7bff, #2456c4);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  border-radius: 11px;
  box-shadow: 0 3px 8px rgba(46, 107, 230, .32);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text b { font-size: 15.5px; font-weight: 800; white-space: nowrap; letter-spacing: .01em; }
.brand-text i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .3em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 6px 14px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.active { background: var(--primary-tint); color: var(--primary-strong); }
.topnav a.btn-new {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 8px 16px;
  box-shadow: 0 2px 6px rgba(46, 107, 230, .35);
  transition: background .15s, transform .12s;
}
.topnav a.btn-new:hover { background: var(--primary-strong); color: #fff; }
.topnav a.btn-new:active { transform: scale(.97); }

/* 舊工業視覺的警示膠帶條:保留節點、視覺退場 */
.hazard-bar { display: none; }

/* ---------- 頁面容器 ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 26px 20px 72px; }
.page-narrow { max-width: 640px; margin: 0 auto; }

h1 { font-size: 23px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 800; margin: 0 0 8px; }

/* ---------- 卡片 / 面板 ---------- */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 20px; }

/* 面板標題列:主色小豎條 = 段落記號 */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { display: flex; align-items: center; gap: 9px; margin: 0; }
.panel-head h2::before {
  content: "";
  width: 4px; height: 15px;
  border-radius: 2px;
  background: var(--primary);
  flex: 0 0 auto;
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-faint); }
.btn:active { transform: scale(.98); }
.btn:disabled { cursor: default; opacity: .55; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b3140; border-color: #2b3140; }
.btn-hazard {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46, 107, 230, .3);
}
.btn-hazard:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-lg { min-height: 54px; font-size: 17px; padding: 12px 22px; border-radius: var(--radius); }
.btn-block { width: 100%; }

/* ---------- 表單 ---------- */
label { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
input:not([type]), input[type=text], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* ≥16 防 iOS 自動放大 */
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 107, 230, .16);
}
.field { margin-bottom: 16px; }
.field.disabled { opacity: .45; }
.required::after { content: " *"; color: var(--danger); }
.field-error input, .field-error select, .field-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(217, 45, 32, .14);
}

/* ---------- 狀態:柔和藥丸(淡底 + 飽和字 + 信號點) ----------
   .status-X 同時掛在 status-tag / cc-band / dl-band 上,
   這裡統一給「淡底 + 狀態字色」,版型各自加。 */
.status-pending { background: var(--st-pending-bg); color: var(--st-pending); }
.status-processing { background: var(--st-processing-bg); color: var(--st-processing); }
.status-need_second_round { background: var(--st-need_second_round-bg); color: var(--st-need_second_round); }
.status-need_judgement { background: var(--st-need_judgement-bg); color: var(--st-need_judgement); }
.status-completed { background: var(--st-completed-bg); color: var(--st-completed); }
.status-returned_to_flow { background: var(--st-returned_to_flow-bg); color: var(--st-returned_to_flow); }
.status-scrapped { background: var(--st-scrapped-bg); color: var(--st-scrapped); }
.status-paused { background: var(--st-paused-bg); color: var(--st-paused); }

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.status-tag::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* ---------- 一般標籤 chip(料號/tags/來源) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}
.chip-warn {
  background: var(--st-need_second_round-bg);
  border-color: transparent;
  color: var(--st-need_second_round);
  font-weight: 700;
}

/* 操作者:人 / AI */
.actor-agent, .actor-human {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
}
.actor-agent { background: var(--primary-tint); color: var(--primary-strong); }
.actor-human { background: transparent; color: var(--ink-faint); border: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  display: flex;
  align-items: center;
  gap: 9px;
  background: #1d2129;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  font-size: 14.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 90vw;
}
.toast::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex: 0 0 auto;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err::before { background: #ff6b5e; }
.toast.ok::before { background: #4ade80; }

/* ---------- 頁腳 ---------- */
.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 12px;
}
.foot-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .28em;
  white-space: nowrap;
}
.foot-theme { margin-left: auto; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.foot-theme:hover { color: var(--primary-strong); text-decoration: underline; }

/* ---------- 進場動效:卡片逐一浮起 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise .34s cubic-bezier(.2, .7, .3, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 手機 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; font-size: 18px; }
  .brand-text { display: none; } /* 手機只留品牌方塊,讓出 nav 空間 */
  .topnav { gap: 2px; }
  .topnav a { padding: 6px 10px; font-size: 14px; }
  .topnav a.btn-new { padding: 8px 12px; font-size: 14px; white-space: nowrap; }
  .page { padding: 18px 12px 72px; }
  h1 { font-size: 20px; }
  .foot { flex-direction: column; align-items: flex-start; gap: 6px; }
}
