/* 資安及建設科重點工作項目列管系統 */
:root {
  --bg: #f4f6f9; --surface: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #1d4ed8; --primary-d: #1e40af; --primary-l: #eff6ff;
  --expt: #eef4ff; --expt-line: #bfd3fb; --expt-text: #1e40af;
  --act: #ecfbf2; --act-line: #b6e8c9; --act-text: #116a3b;
  --red: #b91c1c; --red-l: #fdecec; --orange: #b45309; --orange-l: #fff4e0;
  --green: #15803d; --green-l: #e7f7ed; --gray-l: #f1f3f5;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
h2 { font-size: 1.08rem; margin: 0; }
.muted { color: var(--muted); } .small { font-size: .84rem; } .mono { font-variant-numeric: tabular-nums; }
.warn { color: var(--orange); } .nowrap { white-space: nowrap; } .pre { white-space: pre-wrap; margin: 0; }
[hidden] { display: none !important; }

/* ---------- 版面 ---------- */
.topbar { height: 56px; background: #0f2a5f; color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: #3b82f6; color: #fff;
  display: inline-grid; place-items: center; font-weight: 800; }
.brand-mark.big { width: 56px; height: 56px; font-size: 1.6rem; border-radius: 14px; margin: 0 auto 12px; }
.topbar .btn-ghost { color: #dbe6ff; border-color: rgba(255,255,255,.3); }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 232px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  padding: 16px 10px; position: sticky; top: 56px; height: calc(100vh - 56px); }
.sidenav a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  color: var(--text); margin-bottom: 2px; }
.sidenav a:hover { background: var(--gray-l); text-decoration: none; }
.sidenav a.active { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.sidenav .ico { width: 20px; text-align: center; }
.nav-group { font-size: .75rem; color: var(--muted); padding: 14px 12px 6px; letter-spacing: .05em; }
.content { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px; }
.card-head .sec-title { margin: 0; }
.sec-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.sec-no { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: .8rem; display: inline-grid; place-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-info { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--gray-l);
  color: var(--muted); font-size: .78rem; text-align: center; font-weight: 600; }

/* ---------- 按鈕 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid #cfd5dd; background: #fff; color: var(--text); font: inherit;
  cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--gray-l); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-danger-ghost { color: var(--red); border-color: #f3c4c4; }
.btn-danger-ghost:hover { background: var(--red-l); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.link-btn { border: 0; background: none; color: var(--act-text); font-size: .8rem; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
form.inline { display: inline; }

/* ---------- 標籤 ---------- */
.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 4px; font-weight: 500; vertical-align: middle; }
.tag-muted { background: #eceff3; color: var(--muted); }
.tag-eval { background: #f3e8ff; color: #7e22ce; }
.pill { display: inline-block; font-size: .78rem; padding: 1px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--gray-l); color: var(--muted); font-weight: 500; }
.pill:empty { display: none; }
.pill-overdue { background: var(--red-l); color: var(--red); font-weight: 600; }
.pill-late { background: var(--orange-l); color: var(--orange); }
.pill-soon { background: #fff7d6; color: #92400e; }
.pill-pending { background: var(--primary-l); color: var(--primary); }
.pill-ontime, .pill-early, .pill-done { background: var(--green-l); color: var(--green); }
.pill-none, .pill-na { background: var(--gray-l); color: var(--muted); }

.status { display: inline-block; font-size: .8rem; padding: 2px 10px; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.status-A, .sdot-A, .stat-A { --c: #6b7280; --cl: #f1f3f5; }
.status-B, .sdot-B, .stat-B { --c: #0369a1; --cl: #e0f2fe; }
.status-C, .sdot-C, .stat-C { --c: #6d28d9; --cl: #ede9fe; }
.status-D, .sdot-D, .stat-D { --c: #b45309; --cl: #fef3c7; }
.status-E, .sdot-E, .stat-E { --c: #be185d; --cl: #fce7f3; }
.status-F, .sdot-F, .stat-F { --c: #4338ca; --cl: #e0e7ff; }
.status-G, .sdot-G, .stat-G { --c: #1d4ed8; --cl: #dbeafe; }
.status-H, .sdot-H, .stat-H { --c: #0f766e; --cl: #ccfbf1; }
.status-I, .sdot-I, .stat-I { --c: #15803d; --cl: #dcfce7; }
.status { color: var(--c); background: var(--cl); }
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-overdue { background: var(--red); } .dot-soon { background: #f59e0b; }

/* ---------- 首頁 ---------- */
.module-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.module-card { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; color: var(--text); box-shadow: var(--shadow); }
.module-card:hover { border-color: var(--primary); text-decoration: none; }
.module-card p { margin: 2px 0 0; font-size: .88rem; }
.module-card.disabled { opacity: .7; border-style: dashed; }
.module-num { font-size: 1.8rem; color: var(--primary); }
.module-stat { margin-left: auto; text-align: right; }
.module-stat b { font-size: 1.8rem; color: var(--primary); } .module-stat span { color: var(--muted); margin-left: 4px; }
.stat-row { display: grid; grid-template-columns: repeat(9, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c);
  border-radius: 8px; padding: 10px 12px; color: var(--text); display: flex; flex-direction: column; }
.stat:hover { text-decoration: none; background: var(--cl); }
.stat-label { font-size: .8rem; color: var(--muted); } .stat-val { font-size: 1.5rem; font-weight: 700; }
.alert-list { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow: auto; }
.alert-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list a { color: var(--text); flex: 1; min-width: 0; }
.alert-list a:hover b { color: var(--primary); }
.al-main { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.al-sub { font-size: .86rem; color: var(--muted); }
.al-right { text-align: right; font-size: .86rem; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; margin: 0; }
.empty-big { text-align: center; padding: 48px 20px; }

/* ---------- 列表 ---------- */
.status-tabs { display: flex; gap: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin;
  margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.status-tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px; }
.status-tabs a:hover { color: var(--text); text-decoration: none; }
.status-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input[type=search] { flex: 1; min-width: 220px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; white-space: nowrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: #f8fafc; font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.row-link { cursor: pointer; } .table tr.row-link:hover td { background: #f8fbff; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { height: 6px; background: var(--gray-l); border-radius: 3px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; }
.progress > div { height: 100%; background: var(--green); }
.kv .progress { width: 100%; display: block; margin-top: 4px; }

/* ---------- 表單 ---------- */
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd5dd; border-radius: 7px; background: #fff; color: var(--text);
  width: 100%; min-height: 38px; }
.filter-bar input, .filter-bar select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93b4f5; outline-offset: 0; border-color: var(--primary); }
input:disabled, select:disabled { background: var(--gray-l); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.span-2 { grid-column: span 2; } .span-full { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 5px; color: #374151; }
em { color: var(--red); font-style: normal; margin-left: 2px; }
.field-err { color: var(--red); font-size: .8rem; margin-top: 3px; }
.has-err input, .has-err select { border-color: var(--red); background: #fffafa; }
.input-unit { display: flex; align-items: center; gap: 6px; } .input-unit span { color: var(--muted); font-size: .9rem; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.readonly { min-height: 38px; display: flex; align-items: center; color: var(--green); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid #cfd5dd; border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; font-weight: 400; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 16px; border-right: 1px solid #cfd5dd; font-size: .92rem; }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--primary); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid #93b4f5; }
.hint { font-size: .84rem; color: var(--muted); margin: 10px 0 0; }
.form-actions { position: sticky; bottom: 0; background: rgba(244,246,249,.94); backdrop-filter: blur(4px);
  padding: 12px 0; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }

/* ---------- 預計 vs 實際 對照表 ---------- */
.cmp-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 4px; }
.cmp-table th, .cmp-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.cmp-table thead th { font-size: .84rem; font-weight: 700; padding: 8px 12px; }
.cmp-table tbody th { font-weight: 500; white-space: nowrap; }
.cmp-table .col-expt { background: var(--expt); }
.cmp-table .col-act { background: var(--act); }
.cmp-table thead .col-expt { color: var(--expt-text); border-bottom: 2px solid var(--expt-line); border-radius: 8px 0 0 0; }
.cmp-table thead .col-act { color: var(--act-text); border-bottom: 2px solid var(--act-line); border-radius: 0 8px 0 0; }
.cmp-table thead .col-expt::before { content: "◷ "; } .cmp-table thead .col-act::before { content: "✓ "; }
.cmp-table td.col-expt, .cmp-table td.col-act { white-space: nowrap; }
.cmp-table .col-diff { width: 110px; white-space: nowrap; }
.cmp-table .col-note { min-width: 260px; width: 34%; }
.cmp-table.view tbody tr.st-overdue th { color: var(--red); }
.tl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; border: 2px solid #cbd5e1; background: #fff; vertical-align: -1px; }
.st-ontime .tl-dot, .st-early .tl-dot, .st-done .tl-dot { background: var(--green); border-color: var(--green); }
.st-late .tl-dot { background: var(--orange); border-color: var(--orange); }
.st-overdue .tl-dot { background: var(--red); border-color: var(--red); }
.st-soon .tl-dot { border-color: #f59e0b; } .st-pending .tl-dot { border-color: var(--primary); }

.items-table th.grp { text-align: center; border-bottom: 1px solid var(--line); color: var(--text); }
.items-table th.sub { font-size: .76rem; text-align: center; }
.items-table th.col-expt, .items-table td.col-expt { background: var(--expt); }
.items-table th.col-act, .items-table td.col-act { background: var(--act); }
.items-table th.col-expt { color: var(--expt-text); } .items-table th.col-act { color: var(--act-text); }
.items-table td.col-expt, .items-table td.col-act { white-space: nowrap; font-size: .88rem; }
.items-table td.na { text-align: center; color: var(--muted); font-size: .84rem; background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f3f4f6 6px, #f3f4f6 12px); }

/* ---------- 明細頁 ---------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; } .kv dd { margin: 0; }
.money-kv dd { font-variant-numeric: tabular-nums; }
.stepper { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px; margin-bottom: 16px; overflow-x: auto; }
.step { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: .82rem; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 7px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step-dot { position: relative; z-index: 1; display: block; width: 16px; height: 16px; margin: 0 auto 6px;
  border-radius: 50%; background: #fff; border: 2px solid #cbd5e1; }
.step.done { color: var(--green); } .step.done .step-dot { background: var(--green); border-color: var(--green); }
.step.done::before, .step.current::before { background: var(--green); }
.step.current { color: var(--primary); font-weight: 700; }
.step.current .step-dot { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px #dbe6ff; }

/* ---------- 其他 ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.flash-success { background: var(--green-l); color: var(--green); }
.flash-error { background: var(--red-l); color: var(--red); }
.flash-info { background: var(--primary-l); color: var(--primary); }
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f2a5f, #1d4ed8); padding: 16px; }
.login-card { background: #fff; width: 100%; max-width: 380px; padding: 32px 28px; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); text-align: center; }
.login-card h1 { font-size: 1.15rem; justify-content: center; }
.login-card label { display: block; text-align: left; font-weight: 600; font-size: .88rem; margin: 18px 0 6px; }
.login-card .btn { margin-top: 16px; padding: 10px; }
.placeholder-banner { display: flex; gap: 16px; align-items: center; background: #fffbeb; border: 1px dashed #f59e0b;
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.placeholder-banner p { margin: 4px 0 0; color: #78350f; }
.ph-icon { font-size: 2rem; }
.ghosted { opacity: .55; pointer-events: none; }
.skel { display: inline-block; height: 10px; border-radius: 5px; background: #e5e7eb; }
.w30 { width: 30%; min-width: 40px; } .w40 { width: 60%; min-width: 60px; } .w60 { width: 80%; min-width: 120px; }

@media (max-width: 1000px) {
  .stat-row { grid-template-columns: repeat(5, 1fr); }
  .grid-2, .grid-info, .module-cards { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidenav { width: 100%; height: auto; position: static; display: flex; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav a { white-space: nowrap; } .nav-group { display: none; }
  .content { padding: 16px; }
  .brand span:last-child { font-size: .9rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: auto; }
}

/* polish */
.sidenav { width: 250px; } .sidenav .tag { white-space: nowrap; margin-left: auto; }
.table td.nw { white-space: nowrap; }
.items-table td:nth-child(2) { min-width: 140px; }
.items-table .row-actions { display: flex; flex-direction: column; gap: 4px; }
.input-unit span { white-space: nowrap; }
.cmp-table + .grid, .grid + .cmp-table { margin-top: 14px; }
.form { counter-reset: sec; }
.form .sec-no::before { counter-increment: sec; content: counter(sec); }
.kv dt { white-space: nowrap; }

/* 辦理情形（粗體／標色）*/
.c-red { color: #c62828; } .c-purple { color: #7b1fa2; } .c-blue { color: #1d4ed8; } .c-green { color: #15803d; }
.rt-wrap { position: relative; }
.rt { min-height: 38px; max-height: 160px; overflow-y: auto; padding: 7px 10px; border: 1px solid #cfd5dd;
  border-radius: 7px; background: #fff; line-height: 1.5; font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.rt:focus { outline: 2px solid #93b4f5; border-color: var(--primary); }
.rt:empty::before { content: attr(data-placeholder); color: #9ca3af; }
.rt-tools { display: none; position: absolute; bottom: calc(100% + 2px); left: 0; z-index: 5; gap: 2px; padding: 3px;
  background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.rt-wrap:focus-within .rt-tools { display: flex; }
.rt-tools button { width: 28px; height: 26px; border: 0; border-radius: 5px; background: none; cursor: pointer; font-size: .85rem; color: var(--text); }
.rt-tools button:hover { background: var(--gray-l); }
.rt-tools .rt-swatch::before { content: ""; display: block; width: 14px; height: 14px; margin: auto; border-radius: 50%; background: var(--sw); }
.rt-view { font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.rt-tall .rt { min-height: 90px; max-height: 300px; }

/* 民國年日期選擇器 */
.rocdate { position: relative; display: inline-flex; align-items: center; width: 100%; max-width: 170px; vertical-align: middle; }
.cmp-table .rocdate { width: 140px; }
.rocdate .roc-text { padding-right: 34px; font-variant-numeric: tabular-nums; background: #fff; }
.rocdate .roc-text.invalid { border-color: var(--red); background: #fffafa; }
.roc-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0;
  border-radius: 5px; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.roc-btn:hover { background: var(--gray-l); color: var(--primary); }
.roc-pop { position: fixed; z-index: 50; width: 272px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 10px; font-size: .9rem; }
.roc-head { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.roc-head select { width: auto; min-height: 30px; padding: 3px 6px; font-size: .88rem; flex: 1; }
.roc-head button, .roc-foot button { border: 0; background: none; cursor: pointer; border-radius: 6px; font: inherit; }
.roc-head button { width: 28px; height: 30px; font-size: 1.1rem; color: var(--muted); }
.roc-head button:hover, .roc-foot button:hover { background: var(--gray-l); }
.roc-week, .roc-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.roc-week span { font-size: .76rem; color: var(--muted); padding: 4px 0; }
.roc-days .day { border: 0; background: none; height: 32px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); }
.roc-days .day.we { color: #b45309; }
.roc-days .day:hover { background: var(--primary-l); }
.roc-days .day.today { box-shadow: inset 0 0 0 1px var(--primary); }
.roc-days .day.sel { background: var(--primary); color: #fff; font-weight: 600; }
.roc-foot { display: flex; justify-content: space-between; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.roc-foot button { padding: 4px 10px; color: var(--primary); }

/* 預估天數 */
.est-days { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .85rem; vertical-align: middle; white-space: nowrap; }
.cmp-table .col-est { background: var(--expt); white-space: nowrap; }
.cmp-table thead .col-est { color: var(--expt-text); border-bottom: 2px solid var(--expt-line); border-radius: 8px 0 0 0; }
.cmp-table thead .col-est + .col-expt { border-radius: 0; }
.est-note { margin-left: 2px; }
.est-days input { width: 64px; min-height: 34px; padding: 5px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.est-days input.neg { color: var(--red); border-color: var(--red); }

/* 階段作業提醒 */
.cmp-table tbody th .stage-hint { white-space: normal; max-width: 300px; margin-top: 3px; font-size: .76rem;
  font-weight: 400; line-height: 1.45; color: #8b939e; }

/* 顯示頁：預估天數、提醒 */
.cmp-table.view .stage-hint { padding-left: 18px; }
.cmp-table.view .col-est { color: var(--muted); }
.est-view { display: inline-block; min-width: 2.2em; text-align: right; color: var(--text); }
.est-view.neg { color: var(--red); }

/* 狀態（自動判斷）*/
.readonly-status { min-height: 38px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-label { line-height: 1.3; }

/* 案件列表：狀態分頁不換行（空間不足時可左右捲動）*/
.status-tabs a { padding: 8px 9px; font-size: .88rem; white-space: nowrap; flex-shrink: 0; gap: 5px; }
.status-tabs .count { min-width: 18px; padding: 0 5px; font-size: .72rem; }
.buy-method { min-width: 120px; max-width: 220px; }

/* 側邊選單摺收 */
.topbar { justify-content: flex-start; gap: 10px; }
.topbar form { margin-left: auto; }
.nav-toggle { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #dbe6ff;
  cursor: pointer; display: grid; place-items: center; margin-left: -8px; }
.nav-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidenav { transition: width .18s ease, padding .18s ease; }
.nav-collapsed .sidenav { width: 60px; padding-left: 8px; padding-right: 8px; overflow: hidden; }
.nav-collapsed .sidenav .nav-text, .nav-collapsed .sidenav .tag, .nav-collapsed .sidenav .nav-group { display: none; }
.nav-collapsed .sidenav a { justify-content: center; padding: 10px 0; }
.nav-collapsed .sidenav .nav-group + a { margin-top: 14px; }
@media (max-width: 760px) {
  .nav-collapsed .sidenav { display: none; }
}

/* 有標籤的可標色欄位：工具列靠右，避免遮住欄位名稱 */
.field .rt-wrap .rt-tools { left: auto; right: 0; }

/* 明細編輯：交付／驗收／付款三區塊橫向排列 */
.item-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.item-cols > .card { margin-bottom: 0; }
.item-cols .grid.one { grid-template-columns: 1fr; }
.item-cols .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-cols .grid + .cmp-stack, .item-cols .grid + div, .item-cols .cmp-stack + .grid { margin-top: 14px; }
.cmp-stack { display: grid; grid-template-columns: 1fr; gap: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin-top: 14px; }
.cs-cell { padding: 10px 12px; }
.cs-cell .label { display: block; font-size: .84rem; font-weight: 700; margin-bottom: 5px; }
.cs-expt { background: var(--expt); } .cs-expt .label { color: var(--expt-text); }
.cs-act { background: var(--act); } .cs-act .label { color: var(--act-text); }
.cs-act-row { display: flex; align-items: center; gap: 6px; }
.cmp-stack .rocdate { max-width: 180px; }
.cs-diff { padding: 8px 12px; display: flex; align-items: center; gap: 8px; background: #fff; border-top: 1px solid var(--line); }
@media (max-width: 1100px) { .item-cols { grid-template-columns: 1fr; } }

/* 明細表：編輯／刪除按鈕同寬；區塊說明灰字 */
.items-table .row-actions { width: 64px; }
.items-table .row-actions > a, .items-table .row-actions > form, .items-table .row-actions button { display: flex; width: 100%; }
.sec-hint { margin: 4px 0 0; font-size: .82rem; color: #8b939e; }

/* 明細表：交付項目內容、付款金額、應付未付標題改黑色置中 */
.items-table thead th:not(.col-expt):not(.col-act) { color: var(--text); text-align: center !important; }
.rt-mid .rt { min-height: 72px; max-height: 200px; }

/* 批次編輯明細 */
.b-hint { margin: 0 0 12px; }
.b-table th, .b-table td { padding: 6px 6px; vertical-align: top; }
.b-table thead th { text-align: center !important; color: var(--text); }
.b-table thead th.col-expt { color: var(--expt-text); } .b-table thead th.col-act { color: var(--act-text); }
.b-table thead th.grp { border-bottom: 1px solid var(--line); }
.b-table td.col-expt { background: var(--expt); } .b-table td.col-act { background: var(--act); }
.b-table .rocdate { width: 142px; max-width: 142px; }
.b-table .roc-text { font-size: .9rem; padding-left: 8px; }
.b-table .b-item { min-width: 200px; }
.b-table .b-memo { min-width: 170px; }
.b-table .rt { min-height: 36px; max-height: 120px; font-size: .88rem; padding: 6px 8px; }
.b-table .b-year { width: 70px; }
.b-table .b-amt { width: 110px; text-align: right; }
.b-table .b-chk { white-space: nowrap; font-size: .85rem; }
.b-table .b-chk label { display: flex; align-items: center; gap: 4px; margin: 4px 0; cursor: pointer; }
.b-table td.off { opacity: .35; background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f3f4f6 6px, #f3f4f6 12px); }
.b-table tr.is-del td { opacity: .4; }
.b-table tr.is-del td.b-del { opacity: 1; }
.b-table .del-toggle { display: inline-flex; align-items: center; gap: 4px; color: var(--red); font-size: .85rem; white-space: nowrap; cursor: pointer; margin-top: 6px; }
.b-table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.b-add { margin-top: 12px; }
#items .card-head .actions { display: flex; gap: 8px; }

/* 批次編輯：交付項目內容、備註加高；各格垂直置中 */
.b-table .rt { min-height: 72px; max-height: 160px; }
.b-table th, .b-table td { vertical-align: middle; }
.b-table .del-toggle { margin-top: 0; }

/* 批次編輯：日期欄縮窄（剛好顯示 115/12/31） */
.b-table .rocdate { width: 118px; max-width: 118px; }
.b-table .roc-text { padding: 6px 28px 6px 7px; font-size: .88rem; }
.b-table .roc-btn { right: 2px; width: 24px; }

/* 批次編輯：預計／實際日期上下排列 */
.b-table td.b-dates { padding: 0; min-width: 150px; }
.b-table .bd { padding: 6px 8px; display: flex; flex-direction: column; align-items: center; }
.b-table .bd-expt { background: var(--expt); }
.b-table .bd-act { background: var(--act); }
.b-table .rocdate { width: 134px; max-width: 134px; }
.b-table th.b-dh span { display: block; line-height: 1.5; }
.b-table th.b-dh .dh-expt { color: var(--expt-text); }
.b-table th.b-dh .dh-act { color: var(--act-text); }
.b-table th.b-q { white-space: normal; width: 72px; min-width: 72px; line-height: 1.4; }
.b-table td.b-chk label { justify-content: center; }

/* 案件明細頁：交付／驗收／付款明細表內容水平及垂直置中 */
.items-table tbody td { text-align: center !important; vertical-align: middle; }
.items-table .row-actions { margin: 0 auto; }
.items-table .rt-view { text-align: center; }

/* 區塊操作按鈕（統一樣式）；錨點避開固定頂端列 */
.btn-outline { background: #fff; color: var(--primary); border-color: #b9cbf3; font-weight: 400; }
.btn-outline:hover { background: var(--primary-l); border-color: var(--primary); }
#schedule { scroll-margin-top: 72px; }
