/* ============================================================
   需求追蹤控管系統 · 共用樣式 (RWD + 漢堡選單)
   風格：專業金融/資訊系統藍調
   ============================================================ */
:root {
  --brand: #1f3b5c;
  --brand-2: #2E74B5;
  --accent: #41A5EE;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e6ebf1;
  --text: #2b3440;
  --muted: #8a97a8;
  --ok: #70AD47;
  --warn: #FFC000;
  --danger: #C00000;
  --dev: #ED7D31;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(31, 59, 92, .06);
  --shadow-lg: 0 8px 26px rgba(31, 59, 92, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--brand-2); text-decoration: none; }

/* ---------- 頂部導覽列 ---------- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.navbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px; height: 60px;
  min-width: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px; color: #fff; white-space: nowrap;
  min-width: 0;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center; font-size: 16px;
}
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  color: #eaf2fb; padding: 8px 14px; border-radius: 8px;
  font-size: 14.5px; font-weight: 500; transition: background .15s;
}
.nav-links a:hover { background: rgba(255, 255, 255, .14); }
.nav-links a.active { background: rgba(255, 255, 255, .22); color: #fff; }

.hamburger {
  display: none; margin-left: auto;
  width: 42px; height: 42px; border: none; background: rgba(255, 255, 255, .12);
  border-radius: 9px; cursor: pointer; position: relative;
}
.hamburger span, .hamburger span::before, .hamburger span::after {
  content: ''; position: absolute; left: 11px; width: 20px; height: 2px;
  background: #fff; border-radius: 2px; transition: .25s;
}
.hamburger span { top: 20px; }
.hamburger span::before { top: -6px; }
.hamburger span::after { top: 6px; }
.hamburger.open span { background: transparent; }
.hamburger.open span::before { transform: rotate(45deg); top: 0; }
.hamburger.open span::after { transform: rotate(-45deg); top: 0; }

/* ---------- 版面 ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 18px 60px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; color: var(--brand); }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
  min-width: 0;
}
.card h2 { margin: 0 0 14px; font-size: 17px; color: var(--brand); }
.card h2 .sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }

/* ---------- KPI 卡 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after { content: ''; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: rgba(65, 165, 238, .08); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 700; color: var(--brand); margin-top: 4px; }
.kpi .value small { font-size: 15px; color: var(--muted); font-weight: 500; }

/* ---------- 圖表 ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.chart-box { width: 100%; height: 300px; }

/* ---------- 表單 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--brand); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid #d5dde6; border-radius: 8px; padding: 9px 11px; background: #fff;
  transition: border .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(65, 165, 238, .16);
}
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 按鈕 ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 18px;
  transition: filter .15s, background .15s; display: inline-flex; align-items: center; gap: 6px;
  justify-content: center;
  min-height: 38px;
  text-align: center;
}
.btn-primary { background: var(--brand-2); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: #fff; color: var(--brand-2); border-color: #cdd8e3; }
.btn-ghost:hover { background: #f0f5fb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #eccece; }
.btn-danger:hover { background: #fdf3f3; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ---------- 表格 (控管表) ---------- */
.table-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.table-tools input, .table-tools select {
  min-width: 0;
  font-family: inherit; font-size: 13.5px; padding: 8px 11px; border: 1px solid #d5dde6; border-radius: 8px;
}
.table-tools input { flex: 1 1 220px; }
.table-tools .spacer { flex: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.rtm { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
table.rtm thead th {
  background: var(--brand); color: #fff; font-weight: 600; text-align: left;
  padding: 11px 12px; position: sticky; top: 0; white-space: nowrap; font-size: 12.5px;
}
table.rtm tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.rtm tbody tr:nth-child(even) { background: #f8fafc; }
table.rtm tbody tr:hover { background: #eef5fc; }
table.rtm .pre { white-space: pre-line; color: #455160; }
table.rtm .reqid { font-weight: 700; color: var(--brand-2); white-space: nowrap; }

.rtm-card-list { display: none; }
.rtm-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow);
}
.rtm-card + .rtm-card { margin-top: 12px; }
.rtm-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.rtm-card-title {
  color: var(--brand-2);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.rtm-card-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rtm-card-section {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
}
.rtm-card-label { color: var(--muted); font-weight: 600; }
.rtm-card-text {
  color: #455160;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.rtm-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ---------- 標籤 ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.high { background: #fdeaea; color: var(--danger); }
.tag.mid { background: #fff5da; color: #a9791a; }
.tag.low { background: #eef6e8; color: #4e7a2f; }
.tag.s-approved { background: #e9f4e1; color: #4e7a2f; }
.tag.s-dev { background: #fdeee2; color: #b25e22; }
.tag.s-test { background: #fff5da; color: #a9791a; }
.tag.s-done { background: #e2eefb; color: #235f97; }
.tag.s-hold { background: #eef0f3; color: #6b7684; }
.tag.mode { background: #eaf1f9; color: var(--brand-2); }
.tag.tt-normal { background: #eef6e8; color: #4e7a2f; }
.tag.tt-boundary { background: #fff5da; color: #a9791a; }
.tag.tt-abnormal { background: #fdeaea; color: var(--danger); }

/* ---------- 檢測小工具 ---------- */
.checker-result { margin-top: 16px; }
.score-ring { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.check-list { list-style: none; padding: 0; margin: 14px 0 0; }
.check-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.check-list li .ico { flex: none; width: 22px; text-align: center; }
.check-list li.pass .ico { color: var(--ok); }
.check-list li.fail .ico { color: var(--danger); }
.check-list li .fix { color: var(--muted); font-size: 12.5px; display: block; }

/* ---------- 提示訊息 ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  width: max-content;
  max-width: calc(100vw - 32px);
  background: var(--brand); color: #fff; padding: 12px 22px; border-radius: 10px;
  box-shadow: var(--shadow-lg); opacity: 0; transition: .25s; z-index: 999; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.notice { background: #eef5fc; border: 1px solid #d3e4f5; color: #2a577f; border-radius: 10px; padding: 12px 16px; font-size: 13.5px; margin-bottom: 18px; }
.notice b { color: var(--brand); }

.legend-inline { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend-inline span::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.guide h3 { color: var(--brand); margin: 22px 0 8px; }
.guide code { background: #eef2f7; padding: 2px 6px; border-radius: 5px; font-size: 13px; color: #2a577f; }
.guide pre { background: #1f2b3a; color: #d6e2f0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.guide table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.guide table th, .guide table td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; font-size: 13.5px; }
.guide table th { background: #eef5fc; color: var(--brand); }

/* ---------- RWD ---------- */
@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .container { padding: 22px 14px 54px; }
  .card { padding: 16px; }
  .card h2 .sub { display: block; margin-left: 0; margin-top: 2px; }
  .hamburger { display: block; }
  .brand { font-size: 16px; }
  .nav-links {
    position: fixed; top: 60px; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--brand); padding: 8px 12px 14px;
    box-shadow: var(--shadow-lg); margin-left: 0;
    transform: translateY(-130%); transition: transform .28s ease; z-index: 90;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { padding: 13px 12px; border-radius: 8px; font-size: 15px; }
  .table-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  .table-tools input,
  .table-tools select,
  .table-tools .btn {
    width: 100%;
  }
  .table-tools input {
    grid-column: 1 / -1;
  }
  .table-tools .spacer {
    display: none;
  }
  .desktop-table {
    display: none;
  }
  .rtm-card-list {
    display: block;
  }
  .form-actions .btn {
    flex: 1 1 calc(50% - 10px);
  }
  .chart-box { height: 280px; }
  .guide {
    overflow-x: hidden;
  }
  .guide table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
@media (max-width: 640px) {
  .page-head h1 { font-size: 22px; line-height: 1.35; }
  .page-head p { font-size: 13.5px; }
  .kpi { padding: 15px 16px; }
  .kpi .value { font-size: 26px; }
  .table-tools {
    grid-template-columns: 1fr;
  }
  .table-tools select,
  .table-tools .btn,
  .form-actions .btn {
    min-height: 42px;
  }
  .form-actions {
    flex-direction: column;
  }
  .form-actions .btn {
    width: 100%;
  }
  .rtm-card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .rtm-card-tags {
    justify-content: flex-start;
  }
  .rtm-card-section {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .rtm-card-actions .btn {
    flex: 1 1 calc(50% - 8px);
  }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .container { padding: 18px 10px 50px; }
  .navbar-inner { padding: 0 12px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand .logo { width: 28px; height: 28px; }
  .hamburger { width: 40px; height: 40px; }
  .card { padding: 14px; border-radius: 10px; }
  .chart-box { height: 250px; }
  .rtm-card { padding: 12px; }
  .rtm-card-actions .btn {
    flex-basis: 100%;
  }
  .check-list li {
    gap: 8px;
    font-size: 13.5px;
  }
  .toast {
    bottom: 16px;
    padding: 10px 14px;
  }
}
