:root {
  --ink: #0e1b21;
  --ink-soft: #33454d;
  --muted: #7b8a90;
  --paper: #f4f2ec;
  --card: #ffffff;
  --line: #e6e2d9;
  --teal: #10756c;
  --teal-2: #17a08f;
  --teal-soft: #e3f2ee;
  --amber: #b57614;
  --amber-soft: #fbf0d9;
  --red: #b23c30;
  --red-soft: #fbe6e3;
  --violet: #5b52a8;
  --violet-soft: #ece9f8;
  --slate: #64757c;
  --slate-soft: #e9eef0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(14, 27, 33, .05), 0 8px 24px -18px rgba(14, 27, 33, .35);
  --sidebar: 232px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 "Inter", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 版面 ---------------- */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100%; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 14px;
  background: var(--ink);
  color: #cfe0e2;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px; }
.brand b { color: #fff; font-size: 16px; letter-spacing: -.01em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal-2); box-shadow: 0 0 0 4px rgba(23, 160, 143, .18); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 0; border-radius: 10px;
  background: transparent; color: #b9cdd0; text-align: left; cursor: pointer;
  font-size: 14px;
}
.sidebar nav button .ico { width: 18px; text-align: center; opacity: .8; font-size: 13px; }
.sidebar nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav button.on { background: var(--teal); color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .ghost { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.14); color: #dfe8ea; }
.sidebar .ghost:hover { background: rgba(255,255,255,.1); }
.sidebar .primary { background: var(--teal); }

.view { padding: 26px 30px 60px; min-width: 0; }
.view .page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.page-head h1 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -.02em; font-weight: 650; }
.page-head .sub { margin: 8px 0 0; color: var(--ink-soft); max-width: 60ch; font-size: 14px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- 按鈕 ---------------- */

.primary, .ghost, button.primary, button.ghost {
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 550; font-size: 14px;
  transition: filter .15s, background .15s, border-color .15s;
}
.primary { background: var(--teal); color: #fff; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.ghost:hover { border-color: #c9c3b6; }
.ghost.small { padding: 7px 11px; font-size: 13px; }
.primary.small { padding: 7px 11px; font-size: 13px; }
.ghost.tiny { padding: 4px 8px; font-size: 12px; border-radius: 8px; }
.ghost.danger { color: var(--red); border-color: #efd3cf; }
.ghost.on, .primary.on { background: var(--teal-soft); border-color: #b9dcd5; color: var(--teal); }
button.danger:not(.ghost) { background: var(--red); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; }
.link { background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; font-size: 13px; }
.link.strong { font-weight: 600; font-size: 15px; color: var(--ink); }
.link:hover { text-decoration: underline; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--muted); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--slate-soft); color: var(--ink); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 15px; letter-spacing: .01em; font-weight: 650; }
.muted { color: var(--muted); }
.muted.small, .small { font-size: 12.5px; }
.empty { color: var(--muted); font-size: 14px; margin: 10px 0; }
.chip { background: var(--teal-soft); color: var(--teal); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.grow { flex: 1; }

/* ---------------- KPI ---------------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; }
.kpi b { display: block; font-size: 26px; line-height: 1.2; margin: 4px 0 2px; letter-spacing: -.02em; }
.kpi em { font-style: normal; color: var(--muted); font-size: 12px; }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 16px; }

/* ---------------- 列表 ---------------- */

.rows { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 11px 6px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; cursor: pointer; border-radius: 8px;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: #fbfaf6; }
.row-main { min-width: 0; flex: 1; }
.row-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; flex-wrap: wrap; }
.row-name .mono { font-weight: 450; color: var(--muted); font-size: 12.5px; }
.row-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.mono { font-family: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------------- 狀態 ---------------- */

.s-pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.s-Y { background: #e2f4e6; color: #1f7a3d; }
.s-N { background: var(--red-soft); color: var(--red); }
.s-VM { background: var(--violet-soft); color: var(--violet); }
.s-O { background: var(--amber-soft); color: var(--amber); }
.s-F { background: #eceff1; color: #52646b; }
.s-none { background: var(--slate-soft); color: #5c6f76; }

.o-pill { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 600; }
.o-OWN { background: #eef3f4; color: #46605f; }
.o-RECEIVED { background: #eaf0fb; color: #33569c; }
.o-ASSIGNED { background: #f7eef7; color: #7b3f74; }

.lvl { display: inline-block; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 600; }
.follow { font-size: 12px; color: var(--teal); font-weight: 600; }
.follow.late { color: var(--red); }
.star { color: var(--amber); }

.tag { display: inline-block; background: var(--slate-soft); color: #4d5f66; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; }
.tag.ok { background: #e2f4e6; color: #1f7a3d; }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.info { background: #e6eefb; color: #2f5aa8; }
.tag.danger { background: var(--red-soft); color: var(--red); }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------------- 總覽區塊 ---------------- */

.status-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.status-cell { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; border: 1px solid var(--line); background: #fcfbf8; border-radius: 10px; padding: 8px; cursor: pointer; }
.status-cell b { font-size: 17px; }
.status-cell:hover { border-color: #c9c3b6; }
.mini-bars { display: grid; gap: 6px; margin-top: 14px; }
.mini-bars > div { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--slate-soft); }
.bar.ok { background: linear-gradient(90deg, #38a169, #7bc79a); }
.bar.warn { background: linear-gradient(90deg, #c98a2b, #e6c07a); }

.partner-list { display: grid; gap: 2px; }
.partner-row { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; }
.partner-row:last-child { border-bottom: 0; }
.partner-row:hover { background: #fbfaf6; }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-size: 12px; font-weight: 700; }

/* ---------------- 篩選 ---------------- */

.filter-row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)) auto; gap: 8px; }
.filter-row input, .filter-row select,
.field input, .field select, .field textarea, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: #fdfcf9; outline: none;
}
.filter-row input:focus, .filter-row select:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal-2); box-shadow: 0 0 0 3px rgba(23,160,143,.12); }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pill { border: 1px solid var(--line); background: #fdfcf9; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--ink-soft); }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------------- 行程時間軸 ---------------- */

.timeline { display: grid; gap: 10px; }
.tl { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fdfcf9; }
.tl.special { box-shadow: inset 3px 0 0 var(--amber); }
.tl.conflict { border-color: #e8c7a4; background: #fffaf2; }
.tl-time { text-align: right; color: var(--ink-soft); }
.tl-time b { display: block; font-size: 15px; }
.tl-time span { font-size: 12px; color: var(--muted); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.gap { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; border-left: 2px dashed var(--line); margin-left: 36px; }
.warn-line { color: var(--amber); font-size: 12.5px; margin: 6px 0 0; }

/* ---------------- 機率 ---------------- */

.prob { border-top: 1px solid var(--line); padding: 10px 0; }
.prob:first-of-type { border-top: 0; }
.prob-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.prob-row { display: grid; grid-template-columns: 74px 1fr 34px; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
.track { height: 8px; background: var(--slate-soft); border-radius: 999px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 999px; background: var(--teal); }
.track i.s-Y { background: #48a868; }
.track i.s-N { background: #cf6a5d; }
.track i.s-VM { background: #7c74c0; }
.track i.s-O { background: #d6a04b; }
.track i.s-F { background: #93a3a9; }
.track i.s-none { background: #b8c6ca; }

/* ---------------- 日曆 ---------------- */

.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { font-size: 11.5px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-cell { min-height: 92px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fdfcf9; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.today { border-color: var(--teal-2); box-shadow: 0 0 0 2px rgba(23,160,143,.14); }
.cal-cell > b { font-size: 12px; color: var(--muted); }
.cal-ev { border: 0; border-radius: 6px; padding: 2px 5px; font-size: 11px; text-align: left; cursor: pointer; background: var(--slate-soft); color: var(--ink-soft); }
.cal-ev.s-Y { background: #e2f4e6; color: #1f7a3d; }
.cal-ev.s-N { background: var(--red-soft); color: var(--red); }
.cal-ev.s-VM { background: var(--violet-soft); color: var(--violet); }
.cal-ev.s-O { background: var(--amber-soft); color: var(--amber); }
.more { font-size: 10.5px; color: var(--muted); }

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

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--muted); }
.field.span2, .span2 { grid-column: 1 / -1; }
.field.span-check { flex-direction: row; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.field small { color: var(--muted); font-size: 11.5px; }
.alert-card { border-color: #eddcbf; background: #fffdf8; }
.note-text { margin: 6px 0 0; color: var(--ink-soft); font-size: 13.5px; white-space: pre-wrap; }
.raw { background: #f7f5f0; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12.5px; white-space: pre-wrap; overflow-x: auto; }
.lan code { display: inline-block; background: #f1efe9; border-radius: 8px; padding: 6px 10px; margin: 4px 6px 0 0; font-size: 13px; }

/* ---------------- 抽屜 ---------------- */

body.drawer-open { overflow: hidden; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(14, 27, 33, .32); backdrop-filter: blur(1.5px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 96vw);
  background: var(--paper); z-index: 41; display: flex; flex-direction: column;
  box-shadow: -24px 0 60px -30px rgba(14, 27, 33, .5);
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sheet-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line); }
.drawer-body { overflow-y: auto; padding: 16px 22px 40px; }
.sheet-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.sheet-block h3 { margin: 0 0 10px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }

.visit { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fdfcf9; }
.visit.l3 { box-shadow: inset 3px 0 0 var(--violet); }
.visit-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.visit-top b { font-size: 13.5px; }
.visit-body { margin-top: 6px; font-size: 13px; }
.visit-place { color: var(--ink-soft); }
.mini-select { border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; font-size: 12px; background: #fff; }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding: 5px 0; font-size: 13px; }
.kv-row span { color: var(--muted); }
.kv-row b { font-weight: 550; text-align: right; }
.kv-row em { color: #b9c2c6; font-style: normal; }

.att-list { display: grid; gap: 6px; margin-bottom: 10px; }
.att-row { display: flex; align-items: center; gap: 10px; font-size: 13px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.upload { display: inline-block; border: 1px dashed #c9c3b6; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--teal); }

/* ---------------- 彈窗 ---------------- */

.modal-backdrop { position: fixed; inset: 0; background: rgba(14, 27, 33, .38); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--paper); border-radius: 16px; width: min(560px, 96vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px -40px rgba(0,0,0,.6); }
.modal.wide { width: min(760px, 96vw); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--card); border-radius: 16px 16px 0 0; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--card); border-radius: 0 0 16px 16px; }
.confirm-text { margin: 0; font-size: 14.5px; }

/* ---------------- Toast ---------------- */

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 90; box-shadow: 0 12px 30px -12px rgba(0,0,0,.5);
}
#toast.error { background: var(--red); }

/* ---------------- 手機 ---------------- */

.tabbar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .view { padding: 18px 14px 90px; }
  .page-head h1 { font-size: 24px; }
  .grid2 { grid-template-columns: 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .cal-cell { min-height: 66px; }
  .drawer { width: 100vw; }

  .tabbar {
    display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tabbar button { flex: 1 0 auto; min-width: 62px; border: 0; background: none; display: grid; gap: 2px; justify-items: center; font-size: 11px; color: var(--muted); padding: 4px 2px; cursor: pointer; }
  .tabbar button span { font-size: 16px; }
  .tabbar button.on { color: var(--teal); }
}

@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .client-row .row-name .mono { display: none; }
  .status-grid { grid-template-columns: repeat(3, 1fr); }
}

.kbd { font-size: 10px; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .55; margin-left: 6px; }
.row-item.static { cursor: default; background: transparent; }
.row-item.static:hover { background: transparent; }
#gsInput { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font: inherit; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg .ghost { border-radius: 999px; padding: 8px 14px; }
.seg .ghost.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.tag.mute { background: var(--line); color: var(--ink-soft); }
.rows .row-item.static .row-name { display: flex; align-items: center; gap: 8px; }

.check-row { display: flex; gap: 26px; flex-wrap: wrap; align-items: center; padding-top: 8px; }
.check-row .check { white-space: nowrap; }

.live { display: flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: .04em; color: rgba(255,255,255,.55); padding: 0 2px 8px; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: #2f9e6a; box-shadow: 0 0 0 0 rgba(47,158,106,.5); animation: livePulse 2.4s infinite; }
.live.off .dot { background: #c0562f; animation: none; }
.live.busy .dot { background: #cf9b2f; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(47,158,106,.45); } 70% { box-shadow: 0 0 0 7px rgba(47,158,106,0); } 100% { box-shadow: 0 0 0 0 rgba(47,158,106,0); } }

/* 計算器輸出 */
.calc-out { margin-top: 14px; }
.calc-out .kpi strong { display: block; font-size: 26px; line-height: 1.2; margin: 4px 0 2px; letter-spacing: -.02em; }
.calc-out .kpi strong.accent { color: var(--teal); }

/* 產品庫文件連結 */
.doc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.doc-links .doc {
  font-size: 12px; padding: 4px 9px; border-radius: 999px; text-decoration: none;
  background: var(--teal-soft); color: #0d5f52; border: 1px solid #cfe8e2;
}
.doc-links .doc:hover { background: #d6efe8; }
.doc-links .doc.off { background: var(--line); color: var(--muted); }

/* ---------- 週檢視（TimeTree 風格時間段） ---------- */
.week { padding: 0; overflow: hidden; }
.wk-scroll { overflow: auto; max-height: 72vh; }
.wk-head { display: grid; grid-template-columns: 56px repeat(7, minmax(96px, 1fr)); position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--line); }
.wk-gutter { border-right: 1px solid var(--line); }
.wk-hd { padding: 8px 6px; text-align: center; border-left: 1px solid var(--line); }
.wk-hd span { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.wk-hd b { font-size: 18px; }
.wk-hd.today b { color: var(--teal); }
.wk-body { display: grid; grid-template-columns: 56px repeat(7, minmax(96px, 1fr)); position: relative; }
.wk-hours { border-right: 1px solid var(--line); }
.wk-hour { position: relative; }
.wk-hour span { position: absolute; top: -7px; right: 6px; font-size: 11px; color: var(--muted); background: var(--card); padding: 0 2px; }
.wk-day { position: relative; border-left: 1px solid var(--line); }
.wk-day.today { background: color-mix(in srgb, var(--teal) 5%, transparent); }
.wk-line { border-bottom: 1px dashed var(--line); }
.wk-ev { position: absolute; left: 3px; right: 3px; overflow: hidden; text-align: left; border: 0; border-left: 3px solid var(--teal); border-radius: 6px; padding: 3px 5px; background: #e8f3ef; color: var(--ink); font-size: 11px; line-height: 1.25; cursor: pointer; }
.wk-ev b { display: block; font-family: var(--mono); font-size: 11px; }
.wk-ev span { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-ev i { display: block; font-style: normal; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-ev.appt { border-left-style: dashed; border-left-color: #b07d18; background: #fdf3dd; }
.wk-ev.s-none { border-left-color: #b9b2a6; background: #f1eee7; }
.wk-ev.s-N { border-left-color: #c0563f; background: #fbe9e5; }
.wk-ev.s-VM { border-left-color: #6b63b3; background: #eeecfa; }
.wk-ev.s-O, .wk-ev.s-F { border-left-color: #b07d18; background: #fdf3dd; }

/* ---------- 預約卡（抽屜） ---------- */
.appt-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.appt-row:last-of-type { border-bottom: 0; }
.appt-when b { display: block; font-size: 13px; }
.appt-when span { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.appt-actions { display: flex; gap: 6px; }
.sum-preview { margin-top: 10px; }
.sum-preview .kv > div { border-bottom: 1px dashed var(--line); }

/* ---- 客戶分析 ---- */
.an-wrap { margin-top: 16px; display: grid; gap: 18px; }
.an-score { display: flex; align-items: center; gap: 18px; }
.an-ring { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--teal) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.an-ring::before { content: ""; position: absolute; inset: 8px; background: var(--card); border-radius: 50%; }
.an-ring b { position: relative; font-size: 26px; }
.an-ring span { position: relative; font-size: 11px; color: var(--muted); }
.an-grade { font-weight: 700; font-size: 18px; }
.an-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 22px; }
.an-bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.an-track { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; }
.an-track i { display: block; height: 100%; background: var(--teal); }
.an-finds { display: grid; gap: 10px; }
.an-find { border-left: 3px solid var(--line); padding: 8px 12px; background: var(--paper); border-radius: 0 8px 8px 0; }
.an-find.good { border-color: #2e9e6b; }
.an-find.warn { border-color: #d29b2a; }
.an-find.bad { border-color: #d05252; }
.an-find-main { display: flex; justify-content: space-between; gap: 12px; }
.an-k { color: var(--muted); font-size: 13px; }
.an-note { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.5; }
.an-acts h3 { font-size: 14px; margin-bottom: 8px; }
.an-act { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.an-act:last-child { border-bottom: 0; }
.an-risks ul { margin: 6px 0 0 18px; }
.an-risks li { font-size: 13px; line-height: 1.7; color: var(--ink); }

#btnAnalyze { width: auto; min-width: 190px; flex: none; }
#anHint { flex: 1; }

.pc-grid { align-items: end; }
.pc-out { margin-top: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.pc-out .kpi { flex: 1; min-width: 150px; }
#pcResult .note { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.policies { display: grid; gap: 8px; }
.policy-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.policy-main { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.policy-main b { font-size: 14px; }
.policy-main .mono { font-size: 12px; color: var(--mute); }
.policy-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--mute); margin-top: 4px; }
.policy-meta .tag.ok { background: #e2f5ec; color: #14654a; }
.policy-meta .tag.mute { background: #f1f1ee; color: #777; }

.tier-note { margin: 10px 0 6px; font-size: 13px; color: var(--ink); font-weight: 600; }
.tier-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tier-table th, .tier-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tier-table th { color: var(--mute); font-weight: 500; }
.tier-table tr.on { background: #eef7f3; }
.tier-table tr.on td { font-weight: 600; color: #14654a; }

.wk-allday { display: grid; grid-template-columns: 56px repeat(7, 1fr); border-bottom: 1px solid var(--line); background: #fbfaf6; }
.wk-allday .wk-gutter { font-size: 11px; color: var(--mute); display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); }
.wk-ad-cell { display: flex; flex-direction: column; gap: 3px; padding: 4px; border-right: 1px solid var(--line); min-height: 26px; }
.wk-ad { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #eef2ff; color: #33427a; border: 1px dashed #9aa8dc; text-align: left; }
.cal-ev.allday { background: #eef2ff; color: #33427a; border: 1px dashed #9aa8dc; }

.table-wrap{overflow:auto;max-height:70vh;border:1px solid var(--line);border-radius:10px}
.doc-table{width:100%;border-collapse:collapse;font-size:13px}
.doc-table th{position:sticky;top:0;background:var(--card);text-align:left;padding:8px 10px;border-bottom:1px solid var(--line);font-weight:600;white-space:nowrap}
.doc-table td{padding:8px 10px;border-bottom:1px solid var(--line);vertical-align:top}
.doc-table tbody tr:hover td{background:rgba(0,0,0,.025)}
.doc-table .doc-name{max-width:520px}

.doc-table a.ghost.tiny{white-space:nowrap}

.offline-bar{position:fixed;left:50%;bottom:18px;transform:translateX(-50%) translateY(20px);background:#a02a1d;color:#fff;padding:10px 16px;border-radius:999px;font-size:13px;box-shadow:0 10px 24px rgba(0,0,0,.18);opacity:0;pointer-events:none;transition:.25s;z-index:9999}
.offline-bar.show{opacity:1;transform:translateX(-50%) translateY(0)}

.news-summary{margin:6px 0 0;font-size:13px;line-height:1.55;color:var(--muted);max-width:78ch}
.bookmark-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--teal);margin-right:6px;vertical-align:middle}

.digest{border-top:1px solid var(--line);padding:14px 0}
.digest:first-of-type{border-top:0;padding-top:4px}
.digest-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:6px}
.digest-line{margin:4px 0;font-size:14.5px;line-height:1.55}
.digest-take{margin:8px 0 0;padding:9px 12px;background:var(--band);border-radius:8px;font-size:13.5px}
.digest-more{margin-top:8px}
.digest-more summary{cursor:pointer;color:var(--muted);font-size:13px}
.digest-item{padding:4px 0;font-size:13.5px}
