/* 漫畫風主題：粗黑描邊、錯位陰影、消防紅／反光黃／天空藍（依第二大隊犀牛吉祥物插圖） */
:root {
  --ink: #141414; --red: #e3262b; --red-dark: #b5161b; --yellow: #ffd60a; --sky: #1d7fe0; --sky-light: #d8ecff;
  --navy: #14254a; --paper: #ffffff; --cream: #fff8e1; --ok: #1f9d55; --bad: #e3262b; --muted: #4a5568;
  --line: 3px solid var(--ink); --shadow: 5px 5px 0 var(--ink); --shadow-sm: 3px 3px 0 var(--ink);
}
* { box-sizing: border-box; }
html { background: #e9f4ff; }
body {
  margin: 0; color: var(--ink);
  font: 16px/1.65 "Huninn", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background-color: #e9f4ff;
  background-image: radial-gradient(rgba(29,127,224,.18) 1.6px, transparent 1.7px);
  background-size: 14px 14px;
}
img { max-width: 100%; }

/* ---- 標題列 ---- */
header {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--red); border-bottom: var(--line);
  box-shadow: 0 6px 0 var(--yellow), 0 9px 0 var(--ink); margin-bottom: 18px; position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.emblem { width: 64px; height: 64px; border-radius: 50%; border: var(--line); background: #fff; box-shadow: var(--shadow-sm); flex: none; }
h1 {
  font-size: 22px; margin: 0; color: #fff; line-height: 1.25; letter-spacing: 1px;
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
h1 span { display: inline-block; margin-left: 8px; background: var(--yellow); color: var(--ink); text-shadow: none;
  padding: 0 8px; border: 2px solid var(--ink); border-radius: 6px; transform: rotate(-2deg); font-size: 18px; }
header .sub { color: #fff; font-size: 13px; text-shadow: 1px 1px 0 var(--ink); }
#who[hidden] { display: none; }
#who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: #fff; text-shadow: 1px 1px 0 var(--ink); }
#whoName { background: var(--navy); padding: 2px 10px; border: 2px solid var(--ink); border-radius: 20px; }
h2 { font-size: 20px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 14px; }
.note { color: var(--muted); font-size: 14px; }
.err { color: var(--bad); font-size: 15px; font-weight: 700; }

/* ---- 共用元件 ---- */
main { padding: 0 16px 48px; max-width: 1440px; margin: 0 auto; }
.card { background: var(--paper); border: var(--line); border-radius: 12px; padding: 16px; margin: 0 0 18px; box-shadow: var(--shadow); }
label { display: block; margin: 0 0 10px; font-size: 15px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 4px 8px;
}
input:focus, select:focus { outline: 3px solid var(--yellow); outline-offset: 1px; }
label input, label select { display: block; width: 100%; margin-top: 4px; }
button {
  font: inherit; font-size: 15px; border: 2px solid var(--ink); background: var(--red); color: #fff; border-radius: 10px;
  padding: 4px 14px; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .06s, box-shadow .06s;
  text-shadow: 1px 1px 0 rgba(0,0,0,.35);
}
button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.ghost { background: #fff; color: var(--ink); text-shadow: none; }
button.save { background: var(--sky); white-space: nowrap; }
button:disabled { opacity: .55; cursor: default; transform: none; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
::selection { background: var(--yellow); color: var(--ink); }
@media (pointer: coarse) { button { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
#who button { padding: 2px 10px; }
#export { background: var(--yellow); color: var(--ink); text-shadow: none; }

/* ---- 分頁列 ---- */
nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: center; }
nav button { background: #fff; color: var(--ink); text-shadow: none; border-radius: 22px; padding: 5px 16px; }
nav button.on { background: var(--yellow); transform: rotate(-1.5deg); box-shadow: 4px 4px 0 var(--ink); }
#gUnit { margin-left: auto; border-width: 3px; border-radius: 22px; box-shadow: var(--shadow-sm); }
#status { margin: 0 0 10px; }

/* ---- 橫幅 ---- */
.banner {
  position: relative; height: 210px; border: var(--line); border-radius: 14px; box-shadow: var(--shadow);
  background-size: cover; background-repeat: no-repeat; margin: 0 0 18px; overflow: hidden;
}
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,37,74,.55), rgba(20,37,74,0) 60%); }
.banner .btitle {
  position: absolute; left: 18px; bottom: 16px; z-index: 1; color: #fff; font-size: 26px; line-height: 1.3; max-width: 70%;
  text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.banner .bdue {
  position: absolute; right: 16px; top: 14px; z-index: 1; background: var(--yellow); border: 3px solid var(--ink);
  padding: 2px 12px; border-radius: 8px; transform: rotate(3deg); box-shadow: var(--shadow-sm); font-size: 17px;
}

/* ---- 總覽數字卡 ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { position: relative; }
.stat .sub { color: var(--ink); font-size: 15px; }
.stat .num { font-family: "Bangers", "Huninn", sans-serif; font-size: 40px; letter-spacing: 2px; line-height: 1.1; color: var(--red); text-shadow: 2px 2px 0 var(--ink); }
.bar { height: 16px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; margin-top: 8px; }
.bar i {
  display: block; height: 100%; border-right: 2px solid var(--ink);
  background: repeating-linear-gradient(-45deg, #4fb3ff 0 8px, #1d7fe0 8px 16px);
}

/* ---- 表格 ---- */
.tablewrap { overflow-x: auto; background: var(--paper); border: var(--line); border-radius: 12px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 2px solid var(--ink); border-right: 1px dashed #9aa5b1; padding: 7px 9px; text-align: left; vertical-align: top; white-space: nowrap; }
th { background: var(--navy); color: #fff; position: sticky; top: 0; font-weight: 400; letter-spacing: 1px; border-right-color: #3d5a8a; }
tr:nth-child(odd) td { background: var(--cream); }
td.wrap { white-space: normal; min-width: 180px; }
tr.done td:first-child { border-left: 8px solid var(--ok); }
tr.todo td:first-child { border-left: 8px solid #cfd8e3; }
tr.saving { opacity: .6; }
tr.dirty td, .mcard.dirty { background: #fff3a8 !important; }

/* ---- 標籤 ---- */
.tag { display: inline-block; padding: 0 8px; border-radius: 6px; border: 2px solid var(--ink); background: #fff; font-size: 13px; }
.tag.bad { background: var(--yellow); color: var(--ink); transform: rotate(-4deg); box-shadow: 2px 2px 0 var(--ink); }
.tag.bad::before { content: "💥 "; }
.tag.ok { background: #b9f3c9; } .tag.warn { background: #ffe08a; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.filters select, .filters input { border-width: 3px; border-radius: 10px; box-shadow: var(--shadow-sm); }
.form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form label { margin: 0; }

/* ---- 手機卡片 ---- */
.mcard { background: var(--paper); border: var(--line); border-left: 10px solid #cfd8e3; border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; box-shadow: var(--shadow-sm); }
.mcard.done { border-left-color: var(--ok); }
.mcard label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
.mcard label select, .mcard label input { flex: 1; max-width: 60%; min-height: 38px; }
.mhead { margin-bottom: 2px; font-size: 17px; }
.mfoot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* ---- 照片視窗 ---- */
#modal { position: fixed; inset: 0; background: rgba(20,37,74,.6); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.mbox { background: var(--paper); border: var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; width: 100%; max-width: 780px; }
.mtop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.upl { display: inline-block; margin: 8px 8px 8px 0; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.pcell img { width: 100%; border-radius: 8px; border: 2px solid var(--ink); display: block; }
.pcell button { margin-top: 6px; }

/* ---- 登入頁：主視覺 ---- */
#loginWrap {
  min-height: calc(100vh - 110px); margin: -18px 0 0; padding: 32px 16px;
  background: url("img/hero.webp") center 30% / cover no-repeat;
  display: flex; align-items: center; justify-content: flex-end; border-bottom: var(--line);
}
#loginWrap[hidden] { display: none; }
.narrow { max-width: 380px; width: 100%; margin: 0 6vw 0 0; }
#login h2 { font-size: 24px; }
#login h2::after { content: ""; display: block; width: 72px; height: 8px; background: var(--yellow); border: 2px solid var(--ink); border-radius: 6px; margin-top: 6px; }
#cover { position: fixed; inset: 0; background: #fff; z-index: 99; }

@media (max-width: 760px) {
  h1 { font-size: 17px; } h1 span { font-size: 14px; margin-left: 4px; }
  .emblem { width: 48px; height: 48px; }
  header .sub { font-size: 11px; }
  main { padding: 0 10px 40px; }
  .banner { height: 130px; } .banner .btitle { font-size: 19px; max-width: 85%; } .banner .bdue { font-size: 14px; }
  #loginWrap { justify-content: center; align-items: flex-end; background-position: 30% 20%; min-height: calc(100vh - 90px); }
  .narrow { margin: 0; }
  #gUnit { margin-left: 0; }
}

/* 新增成功提示 */
.flash { position: fixed; top: 18px; left: 50%; transform: translateX(-50%) rotate(-2deg); z-index: 60; background: var(--yellow);
  border: 3px solid var(--ink); border-radius: 12px; padding: 8px 18px; font-size: 18px; box-shadow: var(--shadow); }
tr.justadded td, .mcard.justadded { background: #c9f7d5 !important; }

/* ---- 甘特圖 ---- */
.gantt .g-head, .gantt .g-row { display: grid; grid-template-columns: 170px 1fr 170px; gap: 12px; align-items: center; }
.gantt .g-head { margin-bottom: 4px; }
.gantt .g-head .g-track { height: 22px; border: none; background: none; box-shadow: none; }
.gantt .g-head span { position: absolute; transform: translateX(-50%); font-family: "Bangers", "Huninn", sans-serif; font-size: 18px; letter-spacing: 1px; }
.gantt .g-head span:first-child { transform: none; }
.gantt .g-head span:last-child { transform: translateX(-100%); }
.g-row { padding: 6px 0; border-top: 2px dashed #c6d3e3; cursor: pointer; }
.g-row:hover { background: var(--cream); }
.g-label { font-size: 14px; line-height: 1.35; }
.g-track { position: relative; height: 30px; background: #eef4fb; border: 2px solid var(--ink); border-radius: 8px; }
.g-bar { position: absolute; top: 3px; bottom: 3px; background: #fff; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.g-bar i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, #4fb3ff 0 8px, #1d7fe0 8px 16px); }
.g-bar.behind { background: #ffe1e1; }
.g-bar.behind i { background: repeating-linear-gradient(-45deg, #ff7a7a 0 8px, var(--red) 8px 16px); }
.g-today { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 3px solid var(--red); }
.g-head .g-today { top: 0; bottom: -4px; }
.g-head .g-today::before { content: "今天"; position: absolute; top: -2px; left: 4px; font-size: 13px; color: var(--red); white-space: nowrap; }
.g-expect { position: absolute; bottom: -9px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 10px solid var(--ink); transform: translateX(-7px); }
.g-num { font-size: 15px; white-space: nowrap; }
.g-num .tag { margin-left: 6px; }
@media (max-width: 760px) {
  .gantt .g-head, .gantt .g-row { grid-template-columns: 1fr; gap: 4px; }
  .gantt .g-head > div:first-child, .gantt .g-head > div:last-child { display: none; }
}

/* 任務列：目前選的任務（之後會有多個任務） */
.taskbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; }
.taskbar .tlabel { background: var(--navy); color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 10px; font-size: 14px; }
.taskbar b { font-size: 20px; font-weight: 400; text-shadow: 1px 1px 0 var(--yellow); }

/* ---- 大巨蛋看板 ---- */
.dbanner { background-position: center 40%; }
[id^="dSec"] { scroll-margin-top: 78px; }
/* 區塊跳轉列：捲動時固定在上方 */
.secnav {
  position: sticky; top: 8px; z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 6px 8px; margin: 0 0 14px;
  background: var(--navy); border: var(--line); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.secnav button { flex: 0 0 auto; min-width: 120px; background: #fff; color: var(--ink); text-shadow: none; box-shadow: none; border-radius: 20px; }
.secnav button:hover, .secnav button:active { transform: none; box-shadow: none; background: var(--yellow); }
.secnav button[aria-current="true"] { background: var(--yellow); }
.secnav button:focus-visible { outline-color: var(--yellow); outline-offset: 1px; }
/* 表頭排序鈕：箭頭用 CSS 畫，目前排序的那欄才顯示 */
.thsort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.thsort:hover { transform: none; box-shadow: none; text-decoration: underline; }
.thsort:focus-visible { outline: 3px dashed var(--yellow); outline-offset: 3px; }
th[aria-sort="ascending"] .thsort::after, th[aria-sort="descending"] .thsort::after { content: ""; border: 5px solid transparent; }
th[aria-sort="ascending"] .thsort::after { border-bottom-color: var(--yellow); margin-top: -5px; }
th[aria-sort="descending"] .thsort::after { border-top-color: var(--yellow); margin-top: 5px; }
/* 失敗提示 */
.fail {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 70; width: min(560px, calc(100% - 24px));
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  background: var(--paper); border: var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px;
}
.fail b { color: var(--red-dark); }
.fail button { flex: none; }
.dfilters { gap: 10px 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filters .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.chip { border-radius: 20px; padding: 3px 14px; }
.chip.on { background: var(--yellow); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.statline { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 18px; font-size: 15px; }
.statline b { color: var(--red-dark); }
.grid.charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chartbox { position: relative; height: 280px; }
.grid.charts .card { min-width: 0; }
.tablewrap.tall { max-height: 520px; margin-bottom: 18px; }
.drow { cursor: pointer; }
.drow:hover td, .drow:focus-visible td { background: #d8ecff !important; }
.drow:focus-visible { outline-offset: -3px; }
.kv th { position: static; width: 8.5em; white-space: normal; }
.kv td.wrap { min-width: 0; overflow-wrap: anywhere; }
.empty { text-align: center; }
.card h2.next { margin-top: 18px; }
.dcard { display: block; width: 100%; text-align: left; color: var(--ink); text-shadow: none; font-size: 15px; border-left: var(--line); cursor: pointer; }
.dcard span { display: block; }
.dcard .dmeta { color: var(--muted); font-size: 14px; }
.dcard .dtags { margin-top: 6px; min-height: 0; }
.dcard .dtags:empty { display: none; }
.dcard .tag { display: inline-block; }
.more { text-align: center; }
.timeline { position: relative; margin: 0 0 24px; padding-left: 8px; }
.tl { display: grid; grid-template-columns: 150px 1fr; gap: 14px; position: relative; }
.tl::before { content: ""; position: absolute; left: 142px; top: 0; bottom: 0; border-left: 4px solid var(--ink); }
.tdate { font-family: "Bangers", "Huninn", sans-serif; font-size: 18px; letter-spacing: 1px; padding-top: 14px; text-align: right; padding-right: 22px; white-space: nowrap; }
.tl .tbody { margin-bottom: 14px; }
.ttext { margin-top: 6px; font-size: 15px; }
.ttext.clamp { max-height: 8.25em; overflow: hidden; }
.ttext + button { margin-top: 8px; }
#domeText, #lgText { width: 100%; font-size: 15px; }
@media (max-width: 760px) {
  .grid.charts { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid.four .num { font-size: 28px; letter-spacing: 1px; }
  .filters .actions { margin-left: 0; width: 100%; }
  .secnav button { flex: 1 0 auto; min-width: 0; }
  .tl { grid-template-columns: 1fr; } .tl::before { display: none; } .tdate { text-align: left; padding: 0; }
}

/* 第一層：專案切換卡片 */
.taskbar { gap: 12px; margin-bottom: 16px; }
.pcard { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; padding: 8px 18px; border-radius: 14px;
  background: #fff; color: var(--ink); text-shadow: none; border: 3px solid var(--ink); box-shadow: var(--shadow-sm); opacity: .75; }
.pcard .picon { font-size: 22px; }
.pcard.on { background: var(--yellow); opacity: 1; transform: rotate(-1deg) scale(1.03); box-shadow: var(--shadow); }
.pcard.admin { background: var(--navy); color: #fff; }
#tabs[hidden] { display: none; }
@media (max-width: 760px) { .pcard { font-size: 15px; padding: 6px 12px; flex: 1 1 100%; justify-content: center; } }
