/* 年終自評表網頁系統 */
:root {
  --bg: #F2F3F5;
  --paper: #FFFFFF;
  --ink: #1D2125;
  --ink-2: #474E57;
  --muted: #6B7380;
  --line: #D5D9DE;
  --line-strong: #1D2125;
  --field: #B4BBC4;
  --brand: #FF6900;         /* 公司 LOGO 的橘色（取自 LOGO 向量檔） */
  --brand-strong: #D65800;  /* 同色系加深：用在輸入框外框，白底上比較清楚 */
  --accent: #23466B;
  --accent-hover: #1A3654;
  --accent-soft: #E8EEF5;
  --ok: #1B6E3E;   --ok-soft: #E2F2E8;
  --warn: #8F5400; --warn-soft: #FFF1D4;
  --err: #B42318;  --err-soft: #FDE9E7;
  --draft: #7F5A00; --draft-soft: #FFF3C7;
  --font: "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Heiti TC", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; }
[hidden] { display: none !important; }

/* ---------- 上方列 ---------- */
.topbar { background: #1D2125; color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 0 20px; min-height: 56px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 12px; line-height: 1.2; padding: 8px 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #D3D8DE; text-decoration: none; padding: 8px 14px; border-radius: 6px; font-size: 15px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who-name { font-weight: 600; }
.who-meta { color: #A9B1BB; font-size: 12.5px; }
.logout { color: #fff; border: 1px solid rgba(255,255,255,.32); padding: 4px 12px; border-radius: 6px; text-decoration: none; font-size: 13px; }
.logout:hover { background: rgba(255,255,255,.1); }
.testbar { background: var(--warn-soft); color: #6E4100; text-align: center; font-size: 13px; padding: 6px 12px; }

/* ---------- 版面 ---------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 20px 130px; }
.page-head { margin: 0 0 16px; }
.page-head h1 { font-size: 22px; margin: 0 0 6px; }
.page-head h1 small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 10px; }
.page-sub { margin: 0; color: var(--ink-2); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb { margin: 0 0 6px; font-size: 14px; }
.crumb a { text-decoration: none; }
.pdf-link { margin-left: 6px; }
.muted { color: var(--muted); font-size: 13.5px; }

/* ---------- 訊息 ---------- */
.flashes { margin-bottom: 14px; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 10px; font-size: 15px; border: 1px solid; }
.flash-ok { background: var(--ok-soft); color: #14502D; border-color: #B5DEC4; }
.flash-warn { background: var(--warn-soft); color: #6E4100; border-color: #EFD39A; }
.flash-error { background: var(--err-soft); color: #86180F; border-color: #F3C1BC; }
.flash-info { background: var(--accent-soft); color: var(--accent); border-color: #C7D6E8; }
.error-box { background: var(--err-soft); color: #86180F; border: 1px solid #F3C1BC; border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; }
.error-box ul { margin: 6px 0 0; padding-left: 20px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: var(--draft-soft); color: var(--draft); }
.badge.none { background: #ECEEF1; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.tag { font-size: 11.5px; border: 1px solid var(--line); color: var(--ink-2); border-radius: 4px; padding: 0 5px; margin-left: 4px; font-weight: 400; }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 22px; border-radius: 6px;
       border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--field); }
.btn.ghost:hover { background: #F6F7F8; }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; background: var(--accent-soft); color: var(--accent); }
.btn.small:hover { background: #DCE5F0; }
.btn.small.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- 登入 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 760px; display: grid; grid-template-columns: 270px minmax(0, 1fr); background: #fff;
              border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
              box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.07); }
.login-brand { display: flex; align-items: center; justify-content: center; padding: 44px 24px; background: #FAFAF9; border-right: 1px solid var(--line); }
.login-brand img { display: block; height: auto; }
.login-brand .logo-v { width: 118px; }
.login-brand .logo-h { display: none; width: 220px; max-width: 78%; }
.login-main { padding: 44px 44px 30px; }
.login-head { margin-bottom: 6px; }
.login-head h1 { font-size: 22px; margin: 0; letter-spacing: .04em; }
.login-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.login-form label { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.login-form input { width: 100%; height: 44px; border: 1px solid var(--field); border-radius: 8px; padding: 0 12px; font: inherit; font-size: 16px; }
.login-form input:focus { outline: 2px solid var(--brand-strong); outline-offset: 0; border-color: var(--brand-strong); }
.login-form .btn { margin-top: 24px; height: 46px; font-size: 16px; letter-spacing: .2em; }
.login-form .btn.primary { background: var(--ink); }
.login-form .btn.primary:hover { background: #000; }
.form-error { margin-top: 12px; color: var(--err); background: var(--err-soft); border-radius: 6px; padding: 8px 12px; font-size: 14px; }
.login-foot { color: var(--muted); font-size: 13px; margin: 18px 0 0; }
@media (max-width: 760px) {
  .login-card { grid-template-columns: 1fr; max-width: 420px; }
  .login-brand { padding: 30px 24px 26px; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-brand .logo-v { display: none; }
  .login-brand .logo-h { display: block; }
  .login-main { padding: 24px 24px 22px; }
  .login-head, .login-foot { text-align: center; }
}

/* ---------- 自評表（仿 DOC 檔：A4 橫向、左右兩欄） ---------- */
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 26px 38px 34px;
         box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.06); }
.paper-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.doc-title { font-size: 20px; font-weight: 700; }
.doc-id { color: var(--muted); font-size: 13px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 46px; }

.fill-row { font-size: 16px; margin: 2px 0 12px; display: flex; align-items: flex-end; }
.fill-row .fill { display: inline-block; min-width: 210px; border-bottom: 1px solid var(--ink); padding: 0 10px 1px; font-weight: 600; }
.q { font-size: 16px; margin: 18px 0 10px; }

.score-wrap { overflow-x: auto; }
.score { width: 100%; min-width: 430px; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.score th, .score td { border: 1px solid var(--line-strong); text-align: center; vertical-align: middle; padding: 4px 3px; }
.score thead th { font-weight: 400; line-height: 1.35; height: 56px; }
.score th.item { width: 15.5%; font-weight: 400; }
.score .avg { width: 10.5%; border-left: 3px double var(--line-strong); font-weight: 700; }
.score tbody tr { height: 48px; }
.score select.sel { width: 100%; height: 36px; font: inherit; font-size: 16px; text-align: center; text-align-last: center; color: var(--ink);
                    border: 1px solid var(--field); border-radius: 5px; background-color: #fff; cursor: pointer; padding: 0 1px; }
.score select.sel:hover { border-color: var(--ink-2); }
.score select.sel:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.score select.missing { border-color: var(--err); box-shadow: 0 0 0 2px var(--err-soft); }
.score .row-ro td:not(.avg) { background: #FAFAFB; }
.score .sv { display: flex; align-items: center; justify-content: center; height: 34px; border-radius: 4px; font-size: 16px; }
.score output { font-size: 16px; font-variant-numeric: tabular-nums; }
/* 分數底色＝下方評分說明的淡色版 */
.v5 { background-color: #E8DAF3 !important; }
.v4 { background-color: #FFD9D9 !important; }
.v3 { background-color: #DCEBD2 !important; }
.v2 { background-color: #FFF8B5 !important; }
.v1 { background-color: #FFFEE6 !important; }
.table-note { font-size: 12.5px; color: var(--muted); margin: 8px 0 18px; line-height: 1.65; }

.legend { width: 100%; border-collapse: collapse; font-size: 13px; font-weight: 700; line-height: 1.45; }
.legend td { border: 1px solid #000; padding: 6px 7px; vertical-align: middle; }
.legend .lg-n { width: 6%; text-align: center; }
.legend .lg-en { width: 22%; }
.legend .lg-zh { width: 10%; }

.qa { margin-bottom: 24px; }
.qa h2 { font-size: 16px; margin: 0 0 4px; font-weight: 700; }
.qa h2 .num { font-weight: 400; margin-right: 6px; }
.qa .desc, .qa textarea, .qa .answer, .qa .counter { margin-left: 2em; width: calc(100% - 2em); }
.qa .desc { margin-top: 0; margin-bottom: 8px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.qa textarea { display: block; min-height: 150px; resize: vertical; font: inherit; font-size: 15px; line-height: 1.7; padding: 10px 12px;
               border: 1px solid var(--field); border-radius: 6px; background: #fff; color: var(--ink); }
.qa textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.qa textarea.missing { border-color: var(--err); box-shadow: 0 0 0 2px var(--err-soft); }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 3px; }
.answer { white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; min-height: 64px;
          font-size: 15px; line-height: 1.7; background: #FCFCFD; }
.answer.empty { color: var(--muted); }

/* ---------- 下方固定按鈕列 ---------- */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
             box-shadow: 0 -6px 18px rgba(0,0,0,.06); }
.actionbar-inner { max-width: 1320px; margin: 0 auto; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.ab-status { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ab-status strong { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ab-note { color: var(--muted); font-size: 13px; }
.ab-buttons { display: flex; gap: 10px; }

.dlg { border: 0; border-radius: 12px; padding: 24px 26px 20px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 24px 60px rgba(0,0,0,.28); color: var(--ink); }
.dlg::backdrop { background: rgba(20,24,28,.45); }
.dlg h2 { margin: 0 0 10px; font-size: 19px; }
.dlg p { margin: 8px 0; }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- 同仁列表 ---------- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 18px; display: flex; flex-direction: column; min-width: 140px; }
.stat-n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-n small { font-size: 15px; color: var(--muted); font-weight: 400; }
.stat-l { font-size: 13px; color: var(--muted); }
.stat-warn { border-color: #EFD39A; background: var(--warn-soft); flex-direction: row; align-items: center; gap: 10px; }
.stat-warn .stat-n { color: var(--warn); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { height: 38px; border: 1px solid var(--field); border-radius: 6px; padding: 0 12px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
.toolbar input { min-width: 240px; flex: 0 1 320px; }
.group-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; overflow: hidden; }
.group-head { display: flex; justify-content: space-between; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line); background: #FAFBFC; }
.group-head h2 { margin: 0; font-size: 16px; }
.group-count { font-size: 13px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.list { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.list th, .list td { padding: 9px 14px; border-bottom: 1px solid #EDEFF2; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list td.st { white-space: normal; }
.list td.st .badge { margin: 1px 0; }
.list th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: #FAFBFC; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .actions { text-align: right; }
.list .actions .btn { margin-left: 4px; }
.mono { font-variant-numeric: tabular-nums; }
.empty-filter { color: var(--muted); text-align: center; padding: 30px 0; }
.message-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; max-width: 760px; }
.message-card h1 { font-size: 21px; margin: 0 0 10px; }
.message-card h1 small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 10px; }

/* ---------- 小螢幕 ---------- */
@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .who-meta { display: none; }
  .brand { gap: 8px; }
  .brand-logo { height: 26px; }
  .brand-title { font-size: 15px; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .wrap { padding: 16px 12px 150px; }
  .paper { padding: 18px 12px 22px; }
  .fill-row .fill { min-width: 160px; }
  .score { font-size: 12px; min-width: 0; }
  .score th, .score td { padding: 3px 1px; }
  .score thead th { height: 48px; }
  .score th.item { width: 17%; }
  .score .avg { width: 12%; }
  /* 手機：下拉選單沒選時顯示小箭頭，選了以後只顯示數字；字級 16px 避免 iPhone 自動放大畫面 */
  .score select.sel { font-size: 16px; height: 40px; padding: 0; -webkit-appearance: none; appearance: none;
                      background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B7380'/%3E%3C/svg%3E") no-repeat center / 10px 6px; }
  .score select.sel.v1, .score select.sel.v2, .score select.sel.v3, .score select.sel.v4, .score select.sel.v5 { background-image: none; }
  .score tbody tr { height: 50px; }
  .qa textarea { font-size: 16px; }
  .toolbar input, .toolbar select { font-size: 16px; height: 42px; }
  .list { min-width: 0; table-layout: auto; }
  .list col { width: auto !important; }
  .list .hide-m { display: none; }
  .list th, .list td { padding: 9px 8px; }
  .group-head { padding: 10px 12px; }
  .stat { min-width: 0; flex: 1 1 40%; padding: 10px 14px; }
  .score output, .score .sv { font-size: 14px; }
  .legend { font-size: 12px; }
  .legend .lg-en { display: none; }
  .legend .lg-zh { width: 14%; }
  .qa .desc, .qa textarea, .qa .answer, .qa .counter { margin-left: 0; width: 100%; }
  .actionbar-inner { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .ab-buttons .btn { flex: 1; }
  .toolbar input { min-width: 0; flex: 1 1 100%; }
}
@media print {
  .topbar, .actionbar, .flashes, .crumb { display: none !important; }
  body { background: #fff; }
  .paper { box-shadow: none; border: 0; padding: 0; }
}
