/* 到位 Doway 後台：顏色只用中性灰 + 兩個資料色（人力藍、支出橘）+ 狀態色 */

:root {
  color-scheme: light;
  --plane: #f3f3f0;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #ebeae6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 2px 8px rgba(11, 11, 11, 0.04);
  --shadow-lift: 0 2px 4px rgba(11, 11, 11, 0.06), 0 12px 28px rgba(11, 11, 11, 0.1);
  --btn: #1f1f1d;
  --btn-ink: #ffffff;
  --btn-hover: #000000;

  /* 資料色（已用配色檢查工具驗證，色盲也分得出來） */
  --labor: #2a78d6;
  --labor-track: #cde2fb;
  --expense: #eb6834;
  --total: #0b0b0b;
  --plan: #a9a8a1;

  /* 狀態色：一定搭配圖示和文字，不單靠顏色 */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-wash: rgba(12, 163, 12, 0.1);
  --warning-wash: rgba(250, 178, 25, 0.16);
  --serious-wash: rgba(236, 131, 90, 0.16);
  --critical-wash: rgba(208, 59, 59, 0.12);
  --up-text: #006300;
  --down-text: #b42323;

  --radius: 14px;
  --font: "Segoe UI", "Microsoft JhengHei UI", "Microsoft JhengHei", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 深色模式跟著 Windows 設定，也可以用右上角的按鈕手動選（theme.js）；匯出 PDF 時會暫時改成淺色 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 14px 30px rgba(0, 0, 0, 0.45);
    --btn: #f0efec;
    --btn-ink: #0b0b0b;
    --btn-hover: #ffffff;
    --labor: #3987e5;
    --labor-track: #1c3557;
    --expense: #d95926;
    --total: #f0efec;
    --plan: #6c6b66;
    --up-text: #0ca30c;
    --down-text: #e66767;
  }
}
  /* 手動選深色（theme.js 會在 <html> 加 data-theme） */
  :root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 14px 30px rgba(0, 0, 0, 0.45);
  --btn: #f0efec;
  --btn-ink: #0b0b0b;
  --btn-hover: #ffffff;
  --labor: #3987e5;
  --labor-track: #1c3557;
  --expense: #d95926;
  --total: #f0efec;
  --plan: #6c6b66;
  --up-text: #0ca30c;
  --down-text: #e66767;
  }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- 外框 ---- */

.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand { padding: 16px 20px 12px; display: grid; gap: 6px; }
.brand .product { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.brand .product small, .product-lockup small { font-weight: 600; color: var(--muted); margin-left: 5px; font-size: 0.85em; letter-spacing: 0.03em; }
.mark-box { width: 22px; height: 22px; border-radius: 7px; background: #008a60; color: #fff; display: grid; place-items: center; flex: none; }
.mark-box svg.i { width: 14px; height: 14px; }
.brand .company { font-weight: 700; font-size: 16px; }
.brand .sub { color: var(--muted); font-size: 12px; }
.brand .sub:empty { display: none; }
.product-lockup { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; margin-bottom: 16px; }
.product-lockup .mark-box { width: 30px; height: 30px; border-radius: 9px; }
.product-lockup .mark-box svg.i { width: 18px; height: 18px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-group { color: var(--muted); font-size: 12px; padding: 14px 10px 6px; display: flex; justify-content: space-between; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s, transform 0.15s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:active { transform: scale(0.98); }
.nav-item.active { background: var(--ink); color: var(--surface); }
.nav-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; font-size: 13px; }
.sidebar-foot .who small { display: block; color: var(--muted); font-size: 12px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar .crumbs { flex: 1; color: var(--muted); display: flex; gap: 6px; align-items: center; min-width: 0; }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }
.topbar .crumbs button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.topbar .crumbs button:hover { color: var(--ink); text-decoration: underline; }
.updated { color: var(--muted); font-size: 12px; }
.view { flex: 1; overflow-y: auto; padding: 24px 28px 48px; transition: opacity 0.2s; }
.view.loading { opacity: 0.55; pointer-events: none; }
.view-inner { max-width: 1320px; margin: 0 auto; animation: rise 0.45s var(--ease) both; }

/* ---- 共用元件 ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.12s var(--ease), box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.primary:hover { background: var(--btn-hover); box-shadow: var(--shadow-lift); }
.btn.danger { color: var(--down-text); }
.btn.danger:hover { background: var(--critical-wash); border-color: var(--critical); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn .i { width: 16px; height: 16px; }
.icon-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px;
  background: none; color: var(--ink-2); cursor: pointer;
  transition: background 0.15s, transform 0.12s var(--ease), color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
/* 外觀切換：依目前模式顯示對應的圖示 */
.icon-btn[data-theme-toggle] svg { display: none; }
.icon-btn[data-theme-toggle]:not([data-mode]) .t-auto, .icon-btn[data-theme-toggle][data-mode="auto"] .t-auto, .icon-btn[data-theme-toggle][data-mode="light"] .t-light, .icon-btn[data-theme-toggle][data-mode="dark"] .t-dark { display: block; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.spinning .i { animation: spin 0.8s linear infinite; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card h3 { font-size: 15px; font-weight: 600; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.section-title small { color: var(--muted); font-weight: 400; font-size: 12px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.page-head .sub { color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.page-head .actions { display: flex; gap: 8px; }

/* 狀態標籤：圖示 + 文字 + 淡底色 */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px 2px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--ink);
  background: var(--surface-3);
}
.chip .i { width: 14px; height: 14px; stroke-width: 2.4; }
.chip.good { background: var(--good-wash); } .chip.good .i { color: var(--good); }
.chip.warning { background: var(--warning-wash); } .chip.warning .i { color: #b77d00; }
.chip.serious { background: var(--serious-wash); } .chip.serious .i { color: var(--serious); }
.chip.critical { background: var(--critical-wash); } .chip.critical .i { color: var(--critical); }
.chip.closed .i { color: var(--muted); }
.dot.good { background: var(--good); } .dot.warning { background: var(--warning); }
.dot.serious { background: var(--serious); } .dot.critical { background: var(--critical); } .dot.closed { background: var(--axis); }

/* 圖例的色塊 */
.key { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; }
.key::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--key); }
.key.line::before { height: 2px; width: 14px; border-radius: 1px; }
.key.dash::before { height: 0; width: 14px; border-top: 2px dashed var(--key); background: none; }
.key.dotk::before { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.key.vline::before { width: 2px; height: 14px; border-radius: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* ---- 數字卡 ---- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpis.six .value { font-size: 21px; }
@media (max-width: 1360px) {
  .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.tile { padding: 16px 18px; animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.tile .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.01em; white-space: nowrap; }
.tile .value small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero { font-size: 48px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* ---- 進度條 ---- */

.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.meter .fill {
  height: 100%; width: 0; border-radius: 999px; background: var(--ink-2);
  transition: width 1s var(--ease);
}
.meter .fill.warning { background: var(--warning); }
.meter .fill.critical { background: var(--critical); }
.meter .fill.time { background: var(--plan); }
.meter-row { display: grid; grid-template-columns: 34px 1fr 42px; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.meter-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* 預算使用的大條：人力 + 支出，加上今天的時間位置 */
.bigmeter { position: relative; height: 22px; margin: 34px 0 10px; border-radius: 6px; background: var(--surface-3); }
.bigmeter .segs { position: absolute; inset: 0; display: flex; gap: 2px; border-radius: 6px; overflow: hidden; }
.bigmeter .seg { height: 100%; width: 0; transition: width 1.1s var(--ease); }
.bigmeter .seg.labor { background: var(--labor); }
.bigmeter .seg.expense { background: var(--expense); transition-delay: 0.15s; }
.bigmeter .budget-line { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); border-radius: 1px; }
.bigmeter .budget-line span { position: absolute; bottom: 100%; transform: translateX(-50%); font-size: 11px; color: var(--ink); white-space: nowrap; margin-bottom: 2px; font-weight: 600; }
.bigmeter .time-marker {
  position: absolute; top: -26px; bottom: -4px; width: 0; border-left: 2px solid var(--muted);
  left: 0; transition: left 1.1s var(--ease);
}
.bigmeter .time-marker span {
  position: absolute; top: 0; left: 6px; font-size: 11px; color: var(--ink-2); white-space: nowrap;
  background: var(--surface); padding: 0 4px; border-radius: 4px; line-height: 16px;
}

/* ---- 專案卡 ---- */

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.pcard {
  cursor: pointer; display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
  animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.pcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--axis); }
.pcard:active { transform: translateY(-1px) scale(0.99); }
.pcard header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pcard h3 { font-size: 16px; }
.pcard .money { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pcard .money .big { font-size: 22px; font-weight: 650; }
.pcard .money .of { color: var(--muted); font-size: 12px; }
.pcard footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.pcard footer span { display: inline-flex; gap: 4px; align-items: center; }
.pcard footer .i { width: 14px; height: 14px; }
.pcard.add {
  border: 1.5px dashed var(--axis); box-shadow: none; background: transparent;
  align-items: center; justify-content: center; color: var(--ink-2); min-height: 150px; gap: 8px;
}
.pcard.add:hover { border-color: var(--ink-2); color: var(--ink); background: var(--surface); }
.pcard.add .plus { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); transition: transform 0.3s var(--ease); }
.pcard.add:hover .plus { transform: rotate(90deg) scale(1.08); }

/* 今日現場 */
.live-list { display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.live-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); animation: rise 0.4s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.live-row:last-child { border-bottom: 0; }
.live-row .who { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.live-row .where { color: var(--muted); font-size: 12px; grid-column: 1; }
.live-row .when { color: var(--ink-2); font-size: 12px; grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); position: relative; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--good); animation: ping 1.8s var(--ease) infinite; }
.done-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); }

/* ---- 分頁 ---- */

.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2);
  display: inline-flex; gap: 6px; align-items: center; border-radius: 8px 8px 0 0;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab-ink { position: absolute; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; transition: left 0.35s var(--ease), width 0.35s var(--ease); }
.tab-body { animation: rise 0.35s var(--ease) both; }

/* ---- 圖表 ---- */

.chart { width: 100%; height: 300px; }
.chart.tall { height: 340px; }
.chart.short { height: 240px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.empty .i { width: 28px; height: 28px; display: block; margin: 0 auto 8px; color: var(--axis); }
.chart-tip { font-family: var(--font); font-size: 12px; min-width: 150px; }
.chart-tip .t { color: var(--muted); margin-bottom: 4px; }
.chart-tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.chart-tip .r b { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-tip .lk { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-tip .sum { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* ---- 表格 ---- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table a { color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; display: inline-flex; gap: 3px; align-items: center; }
.link-btn:hover { color: var(--ink); }
.link-btn .i { width: 13px; height: 13px; }

/* ---- 表單 ---- */

.field { display: grid; gap: 6px; }
.field > span { color: var(--ink-2); font-size: 13px; }
.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: var(--axis); }
.input:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--surface-3); }
.input.big { font-size: 20px; padding: 10px 14px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 12px; transition: background 0.15s, transform 0.12s; }
.quick button:hover { background: var(--surface-3); }
.quick button:active { transform: scale(0.95); }
.quick button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.shake { animation: shake 0.4s; }

/* ---- 預算 ---- */

.seg-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg-toggle button { border: 0; background: none; padding: 7px 16px; border-radius: 9px; cursor: pointer; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.budget-form { display: grid; gap: 14px; margin-top: 16px; overflow: hidden; animation: expand 0.35s var(--ease) both; }
.preview { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.preview b { font-size: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); animation: rise 0.4s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.timeline li:last-child { border-bottom: 0; }
.timeline .mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.timeline .mark .i { width: 13px; height: 13px; stroke-width: 2.4; }
.timeline .what { font-weight: 600; }
.timeline .meta { grid-column: 2; color: var(--muted); font-size: 12px; }
.timeline .amt { grid-row: 1 / span 2; grid-column: 3; text-align: right; font-variant-numeric: tabular-nums; }
.timeline .amt b { display: block; }
.timeline .amt small { color: var(--muted); font-size: 12px; }

/* ---- 地圖 ---- */

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.map-card { padding: 0; overflow: hidden; }
.map { height: 560px; width: 100%; background: var(--surface-2); }
.map.small { height: 260px; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; }
.leaflet-container { font-family: var(--font); }
.site-pin { position: relative; }
/* 地圖底圖一律是淺色，圖釘固定用深色 */
.site-pin .head {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: #1f1f1d; border: 3px solid #ffffff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  animation: drop 0.5s var(--ease) both;
}
.site-pin.bounce .head { animation: hop 0.5s var(--ease); }
.search-row { display: flex; gap: 8px; }
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; max-height: 210px; overflow-y: auto; }
.results button { width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--ink-2); transition: background 0.12s; }
.results button:hover { background: var(--surface-2); color: var(--ink); }
.coords { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.radius-val { font-size: 28px; font-weight: 650; }
.fit-stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 6px; }

/* ---- 工期 ---- */

.gantt { position: relative; margin: 40px 0 8px; height: 30px; }
.gantt .track { position: absolute; inset: 0; background: var(--surface-3); border-radius: 8px; }
.gantt .done { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--plan); border-radius: 8px 0 0 8px; transition: width 1.1s var(--ease); }
.gantt .over { position: absolute; top: 0; bottom: 0; background: var(--critical-wash); border: 1.5px solid var(--critical); border-radius: 0 8px 8px 0; }
.gantt .today { position: absolute; top: -30px; bottom: -6px; border-left: 2px solid var(--ink); }
.gantt .today span { position: absolute; top: 0; left: 6px; white-space: nowrap; font-size: 12px; font-weight: 600; background: var(--surface); padding: 0 4px; border-radius: 4px; }
.gantt-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; }
.facts div { display: grid; }
.facts span { color: var(--muted); font-size: 12px; }
.facts b { font-size: 18px; font-weight: 650; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* ---- 結案報告 ---- */

.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 48px; display: grid; gap: 28px; }
.report header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--ink); padding-bottom: 16px; }
.report header h1 { font-size: 28px; }
.report header .company { color: var(--muted); }
.report section h2 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.report .summary { font-size: 15px; line-height: 1.9; background: var(--surface-2); border-radius: 12px; padding: 16px 20px; }
.report .summary b { font-weight: 650; }
.report .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report .tile { border: 1px solid var(--border); border-radius: 12px; animation: none; }
.log { display: grid; gap: 0; }
.log-day { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); break-inside: avoid; }
.log-day:last-child { border-bottom: 0; }
.log-day .d { font-weight: 600; }
.log-day .d small { display: block; color: var(--muted); font-weight: 400; }
.log-day .what { color: var(--ink-2); display: grid; gap: 2px; }
.log-day .cost { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-day .cost small { display: block; color: var(--muted); font-size: 12px; }
.report-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }

/* ---- 登入 ---- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 440px; padding: 36px; animation: pop 0.5s var(--ease) both; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.steps { display: grid; gap: 14px; margin: 24px 0; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.bubble { display: inline-block; background: #06c755; color: #fff; padding: 4px 12px; border-radius: 14px 14px 4px 14px; font-weight: 600; margin-top: 6px; }
.code-input { text-align: center; letter-spacing: 0.3em; font-size: 26px; font-weight: 700; text-transform: uppercase; padding: 12px; }
.login-ok { display: grid; place-items: center; gap: 12px; padding: 30px 0 10px; }
.check-anim { width: 72px; height: 72px; }
.check-anim circle { fill: none; stroke: var(--good); stroke-width: 3; stroke-dasharray: 210; stroke-dashoffset: 210; animation: draw 0.6s var(--ease) forwards; }
.check-anim path { fill: none; stroke: var(--good); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 50; stroke-dashoffset: 50; animation: draw 0.4s 0.45s var(--ease) forwards; }

/* ---- 對話框和提示 ---- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 11, 11, 0.42); display: grid; place-items: center; z-index: 1000;
  animation: fade 0.2s both; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lift); width: min(560px, 100%);
  max-height: calc(100vh - 48px); overflow-y: auto; padding: 24px; animation: pop 0.3s var(--ease) both;
}
.modal.wide { width: min(880px, 100%); }
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .desc { color: var(--ink-2); margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.closing .modal-backdrop, .modal-backdrop.closing { animation: fade 0.18s reverse both; }
.modal-backdrop.closing .modal { animation: pop 0.18s reverse both; }

#toast-root { position: fixed; right: 24px; bottom: 24px; display: grid; gap: 8px; z-index: 2000; }
.toast {
  background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lift);
  display: flex; gap: 8px; align-items: center; max-width: 380px; animation: slide-in 0.35s var(--ease) both;
}
.toast.error { background: var(--critical); color: #fff; }
.toast.leaving { animation: slide-in 0.25s reverse both; }
.toast .i { width: 16px; height: 16px; }

/* ---- 動畫 ---- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { transform: scale(1); opacity: 0.6; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes expand { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 600px; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) rotate(-45deg); } to { opacity: 1; transform: rotate(-45deg); } }
@keyframes hop { 0%, 100% { transform: rotate(-45deg); } 40% { transform: translate(-6px, -6px) rotate(-45deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

/* ---- 列印（匯出 PDF）：只留下報告本身 ---- */

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .tabs, .report-bar, .page-head, #toast-root { display: none !important; }
  .shell { display: block; height: auto; }
  .view { overflow: visible; padding: 0; }
  .view-inner, .tab-body, .tile { animation: none !important; }
  .report { border: 0; padding: 0; box-shadow: none; }
  .page-head { margin-bottom: 8px; }
  .report section { break-inside: avoid; }
  .report section.allow-break { break-inside: auto; }
}

/* ---- 網站版：登入按鈕、員工、設定 ---- */

.oauth { justify-content: center; gap: 10px; text-decoration: none; font-weight: 600; }
.oauth .i { width: 20px; height: 20px; }
.oauth.line { background: #06c755; border-color: #06c755; color: #fff; }
.oauth.line:hover { background: #05b34c; border-color: #05b34c; }
.code-login { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 14px; }
.code-login summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.code-login[open] summary { margin-bottom: 8px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warning); color: #0b0b0b; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.company-switch { font-weight: 700; padding: 6px 8px; margin: -4px 0 2px -8px; width: calc(100% + 8px); }
.todo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); animation: rise 0.35s var(--ease) both; }
.todo-row > span { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.todo-row b { color: var(--ink); }
.invite-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 14px; }
.invite-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.toggle input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); }
.input.compact { padding: 6px 10px; width: auto; }
.rate { display: flex; gap: 4px; align-items: center; }
.rate .input { width: 100px; }
.plan-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpis, .kpis.six, .grid-2, .grid-3-1, .map-layout { grid-template-columns: 1fr; }
  .view { padding: 16px; }
}

/* 卡片被拉高時，內容靠上排，不要平均撐開 */
.stack { align-content: start; }
