/* esCrm 客戶操作手冊範本 — 樣式。顏色由 content.js 的 theme 覆寫。 */
:root{
  --primary:#1e3a8a; --primary-ink:#ffffff; --accent:#b7832f; --accent-soft:#fbf4e8;
  --ink:#1f2937; --muted:#6b7280; --line:#e5e7eb; --bg:#f7f8fb; --card:#ffffff;
  --note:#eef4ff; --note-line:#bcd0fb; --warn:#fff6e6; --warn-line:#f3c97a; --ok:#e9f8f0;
  --radius:12px; --sidebar:300px; --top:60px;
  font-size:17px;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth;scroll-padding-top:calc(var(--top) + 12px)}
body{margin:0;font-family:"Noto Sans TC","PingFang TC","Microsoft JhengHei","Heiti TC",system-ui,sans-serif;color:var(--ink);background:var(--bg);line-height:1.75}
img{max-width:100%}
a{color:var(--primary)}
.skip{position:absolute;left:-999px}.skip:focus{left:8px;top:8px;z-index:99;background:#fff;padding:6px 10px}
.btn{font:inherit;font-size:.9rem;border-radius:999px;padding:.45rem 1rem;border:1px solid var(--line);background:#fff;color:var(--ink);cursor:pointer;line-height:1.3}
.btn:hover{border-color:var(--primary)}
.btn.primary{background:var(--primary);color:var(--primary-ink);border-color:var(--primary)}
.btn.primary:disabled{opacity:.45;cursor:default}
.btn.ghost{background:transparent}
.btn:disabled{opacity:.4;cursor:default}

/* 頂欄 */
.topbar{position:sticky;top:0;z-index:30;height:var(--top);display:flex;align-items:center;gap:.75rem;padding:0 1rem;background:var(--primary);color:var(--primary-ink);box-shadow:0 2px 8px rgba(0,0,0,.12)}
.brand{display:flex;align-items:center;gap:.6rem;min-width:0;flex:1}
.brand-mark{display:inline-grid;place-items:center;width:34px;height:34px;border-radius:9px;background:var(--accent);color:#fff;font-weight:700;font-size:.9rem;flex:none}
.brand-text{display:flex;flex-direction:column;min-width:0;line-height:1.25}
.brand-text strong{font-size:1.02rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-text small{opacity:.8;font-size:.78rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .btn{color:var(--primary-ink);border-color:rgba(255,255,255,.45)}
.menu-btn{display:none;font-size:1.3rem;background:none;border:0;color:inherit;cursor:pointer;padding:.2rem .4rem}

/* 版面 */
.layout{display:flex;min-height:calc(100vh - var(--top))}
.sidebar{position:sticky;top:var(--top);height:calc(100vh - var(--top));width:var(--sidebar);flex:none;overflow-y:auto;background:#fff;border-right:1px solid var(--line);padding:1rem .75rem 2rem}
.content{flex:1;min-width:0;max-width:980px;padding:1.5rem 2rem 4rem;margin:0 auto}
.scrim{position:fixed;inset:var(--top) 0 0 0;background:rgba(0,0,0,.35);z-index:19}

/* 搜尋 */
.search-box{position:relative;margin-bottom:1rem}
#search{width:100%;font:inherit;font-size:.95rem;padding:.6rem .8rem;border:1px solid var(--line);border-radius:10px;background:var(--bg)}
#search:focus{outline:2px solid var(--primary);background:#fff}
.search-results{margin-top:.5rem;border:1px solid var(--line);border-radius:10px;background:#fff;max-height:55vh;overflow:auto}
.search-results button{display:block;width:100%;text-align:left;font:inherit;font-size:.88rem;background:none;border:0;border-bottom:1px solid var(--line);padding:.55rem .7rem;cursor:pointer}
.search-results button:hover{background:var(--accent-soft)}
.search-results b{display:block;color:var(--primary)}
.search-results span{color:var(--muted)}
.search-results mark{background:#ffe08a}
.search-empty{padding:.7rem;color:var(--muted);font-size:.88rem}

/* 目錄 */
.toc-part{margin:1rem 0 .3rem;padding:.25rem .6rem;font-size:.78rem;font-weight:700;letter-spacing:.05em;color:#fff;background:var(--accent);border-radius:6px;display:inline-block}
.toc a{display:block;text-decoration:none;color:var(--ink);border-radius:8px;padding:.32rem .6rem;font-size:.93rem}
.toc a.ch{font-weight:600;margin-top:.2rem}
.toc a.sec{padding-left:1.4rem;font-size:.86rem;color:var(--muted)}
.toc a:hover{background:var(--bg)}
.toc a.active{background:var(--accent-soft);color:var(--primary);font-weight:600}

/* 內容 */
.hero{background:linear-gradient(135deg,var(--primary),#2c4fae);color:#fff;border-radius:16px;padding:1.6rem 1.8rem;margin-bottom:1.5rem}
.hero h1{margin:0 0 .3rem;font-size:1.6rem;line-height:1.35}
.hero p{margin:.2rem 0;opacity:.92}
.hero .meta{font-size:.85rem;opacity:.8;margin-top:.6rem}
.part-title{margin:2.6rem 0 .6rem;padding:.5rem 1rem;border-left:6px solid var(--accent);background:#fff;border-radius:8px;font-size:1.25rem}
.part-title small{display:block;font-size:.85rem;color:var(--muted);font-weight:400}
.chapter{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:1.4rem 1.6rem;margin:1.2rem 0}
.chapter > h2{margin:0 0 .3rem;font-size:1.35rem;line-height:1.4;color:var(--primary)}
.chapter .lead{color:var(--muted);margin:.2rem 0 .8rem}
.section{margin-top:1.4rem;padding-top:1rem;border-top:1px dashed var(--line)}
.section h3{margin:0 0 .4rem;font-size:1.12rem}
.section.flash{animation:flash 1.6s ease}
@keyframes flash{0%{background:#fff3c4}100%{background:transparent}}
.content ol,.content ul{padding-left:1.4rem}
.content li{margin:.25rem 0}
.content ol.steps{list-style:none;counter-reset:s;padding-left:0}
.content ol.steps > li{counter-increment:s;position:relative;padding-left:2.4rem;margin:.55rem 0}
.content ol.steps > li::before{content:counter(s);position:absolute;left:0;top:.05rem;width:1.75rem;height:1.75rem;border-radius:50%;background:var(--primary);color:#fff;display:grid;place-items:center;font-size:.85rem;font-weight:700}
.ui{display:inline-block;color:var(--ink);padding:0 .4rem;border:1px solid var(--line);border-radius:6px;background:#f3f4f6;font-size:.92em;white-space:nowrap}
.callout{border-radius:10px;padding:.7rem 1rem;margin:.9rem 0;border:1px solid}
.callout b{display:block;margin-bottom:.1rem}
.callout.note{background:var(--note);border-color:var(--note-line)}
.callout.warn{background:var(--warn);border-color:var(--warn-line)}
.callout.tip{background:var(--ok);border-color:#a7dfc2}
.callout p{margin:.15rem 0}
table{border-collapse:collapse;width:100%;margin:.8rem 0;font-size:.93rem;background:#fff}
th,td{border:1px solid var(--line);padding:.45rem .6rem;text-align:left;vertical-align:top}
th{background:var(--accent-soft)}
.table-wrap{overflow-x:auto}
figure{margin:1rem 0;text-align:center}
figure img{border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 10px rgba(0,0,0,.06);cursor:zoom-in;background:#fff}
figure.phone img{max-width:320px}
figure figcaption{font-size:.85rem;color:var(--muted);margin-top:.35rem}
.placeholder{border:2px dashed #c4c9d4;border-radius:12px;background:repeating-linear-gradient(45deg,#fafbfc,#fafbfc 12px,#f1f3f7 12px,#f1f3f7 24px);color:#4b5563;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:1.2rem;min-height:220px;margin:0 auto}
.placeholder.phone{max-width:300px;min-height:420px}
.placeholder .ph-tag{font-weight:700;background:#fff;border:1px solid #c4c9d4;border-radius:999px;padding:.1rem .7rem;font-size:.85rem;margin-bottom:.4rem}
.placeholder .ph-title{font-weight:600}
.placeholder .ph-url{font-size:.8rem;color:var(--muted);word-break:break-all;margin-top:.3rem}
.tour-launch{display:flex;align-items:center;gap:.8rem;flex-wrap:wrap;background:var(--accent-soft);border:1px solid #ecd9b8;border-radius:12px;padding:.7rem 1rem;margin:.8rem 0}
.tour-launch .btn{font-weight:600}
.tour-launch span{color:#6b5326;font-size:.9rem}
.flow{display:flex;flex-wrap:wrap;gap:.5rem;align-items:stretch;margin:1rem 0;padding:0;list-style:none}
.flow li{flex:1 1 150px;background:#fff;border:1px solid var(--line);border-top:4px solid var(--primary);border-radius:10px;padding:.6rem .8rem;font-size:.92rem;margin:0}
.flow li b{display:block;color:var(--primary)}
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:.8rem;margin:1rem 0}
.cards a{display:block;text-decoration:none;color:inherit;background:#fff;border:1px solid var(--line);border-radius:12px;padding:.9rem 1rem}
.cards a:hover{border-color:var(--primary)}
.cards b{display:block;color:var(--primary);margin-bottom:.2rem}
.cards span{font-size:.88rem;color:var(--muted)}
details.faq{background:#fff;border:1px solid var(--line);border-radius:10px;padding:.6rem 1rem;margin:.5rem 0}
details.faq summary{cursor:pointer;font-weight:600}
details.faq[open] summary{color:var(--primary)}
.footer{margin-top:3rem;padding-top:1rem;border-top:1px solid var(--line);color:var(--muted);font-size:.88rem;text-align:center}
.footer .sign{margin-top:.6rem;text-align:right;color:var(--ink)}

/* 引導 */
.tour{position:fixed;inset:0;z-index:50;background:rgba(10,18,36,.72);display:flex;align-items:center;justify-content:center;padding:1rem}
.tour[hidden]{display:none}
.tour-panel{background:#fff;border-radius:16px;width:min(1180px,100%);max-height:100%;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.35)}
.tour-head{display:flex;justify-content:space-between;align-items:flex-start;padding:.8rem 1.1rem .5rem}
.tour-head h2{margin:0;font-size:1.1rem}
.tour-kicker{font-size:.75rem;color:var(--accent);font-weight:700;letter-spacing:.08em}
.tour-close{font-size:1.2rem;background:none;border:0;cursor:pointer;padding:.2rem .5rem;color:var(--muted)}
.tour-progress{height:4px;background:var(--line)}
.tour-bar{height:100%;background:var(--accent);transition:width .25s}
.tour-body{display:flex;gap:1rem;padding:1rem;min-height:0;overflow:auto}
.tour-stage{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:center;background:#eef1f6;border-radius:12px;padding:.6rem}
.tour-frame{position:relative;display:inline-block;overflow:hidden;border-radius:8px;line-height:0;max-width:100%}
.tour-frame img{display:block;max-width:100%;max-height:68vh;width:auto;height:auto}
.tour-frame .placeholder{line-height:1.5;width:640px;max-width:100%;min-height:380px}
.tour-frame .placeholder.phone{width:300px;min-height:520px}
.tour-hl{position:absolute;border:3px solid #ffb020;border-radius:8px;box-shadow:0 0 0 9999px rgba(10,18,36,.55);transition:all .3s ease;pointer-events:none}
.tour-hl::after{content:"";position:absolute;inset:-8px;border:2px solid rgba(255,176,32,.6);border-radius:12px;animation:pulse 1.4s ease-out infinite}
@keyframes pulse{0%{opacity:1;transform:scale(.97)}100%{opacity:0;transform:scale(1.08)}}
.tour-card{flex:0 0 300px;display:flex;flex-direction:column}
.tour-count{font-size:.85rem;color:var(--muted)}
.tour-step-title{margin:.2rem 0 .4rem;font-size:1.15rem;color:var(--primary)}
.tour-step-text{margin:0 0 .8rem;flex:1}
.tour-dots{display:flex;gap:.35rem;flex-wrap:wrap;margin-bottom:.8rem}
.tour-dots button{width:11px;height:11px;border-radius:50%;border:0;background:var(--line);cursor:pointer;padding:0}
.tour-dots button.on{background:var(--accent)}
.tour-nav{display:flex;justify-content:space-between;gap:.5rem}
.tour-hint{font-size:.78rem;color:var(--muted);margin:.6rem 0 0}
.lightbox{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.85);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:1rem;cursor:zoom-out}
.lightbox[hidden]{display:none}
.lightbox img{max-height:88vh;border-radius:8px;background:#fff}
.lightbox p{color:#fff;font-size:.9rem}

/* 手機 */
@media (max-width:900px){
  :root{font-size:16px}
  .menu-btn{display:block}
  .sidebar{position:fixed;left:0;top:var(--top);z-index:20;transform:translateX(-105%);transition:transform .2s;box-shadow:4px 0 16px rgba(0,0,0,.15);width:min(86vw,var(--sidebar))}
  body.nav-open .sidebar{transform:none}
  .content{padding:1rem .9rem 3rem}
  .chapter{padding:1rem}
  .hero{padding:1.2rem}
  .top-actions{display:none}
  .tour{padding:0}
  .tour-panel{border-radius:0;height:100%}
  .tour-body{flex-direction:column;padding:.6rem}
  .tour-card{flex:none}
  .tour-frame img{max-height:52vh}
  .tour-frame .placeholder{min-height:240px}
  .tour-frame .placeholder.phone{min-height:340px}
  .tour-hint{display:none}
}
@media print{
  .topbar,.sidebar,.tour-launch,.tour,.scrim,.lightbox{display:none!important}
  body{background:#fff}
  .content{max-width:none;padding:0}
  .chapter{break-inside:auto;border:0;padding:0}
  figure,table,.callout{break-inside:avoid}
  details.faq{display:block}
  details.faq > *{display:block}
}
