/* EXSHOP OS — 手寫樣式。版型參考 GrantOS／SHOPLINE 後台：左側雙欄選單、上方標題列、數字卡片。
   品牌色 #E3E400 只當強調色。手機優先，900px 以下選單變成抽屜。 */
:root {
  --brand: #E3E400;
  --brand-soft: #FBFBD6;
  --ink: #16181d;
  --ink-2: #3d424d;
  --muted: #6b7280;
  --line: #e6e8ec;
  --bg: #f5f6f8;
  --side: #f8f9fb;
  --card: #ffffff;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #e5484d;
  --radius: 12px;
  --rail: 60px;
  --panel: 212px;
  --top: 56px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.3rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.ic { flex: none; }

/* ---------- 外框 ---------- */
.shell { display: grid; grid-template-columns: calc(var(--rail) + var(--panel)) minmax(0, 1fr); min-height: 100vh; }
.shell.collapsed { grid-template-columns: var(--rail) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line); overflow: hidden; z-index: 30;
}
.sidebar-brand { height: var(--top); display: flex; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--brand); color: var(--ink); font-size: .85rem; font-weight: 900;
}
.sidebar-body { flex: 1; display: grid; grid-template-columns: var(--rail) 1fr; min-height: 0; }
.shell.collapsed .panel, .shell.collapsed .brand-text, .shell.collapsed .who,
.shell.collapsed .sidebar-user form { display: none; }
.shell.collapsed .sidebar-body { grid-template-columns: var(--rail); }

/* 圖示列 */
.rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; border-right: 1px solid var(--line); overflow-y: auto; }
.rail-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent;
  color: var(--ink-2); display: grid; place-items: center; cursor: pointer; flex: none;
}
.rail-btn:hover { background: #eceef2; }
.rail-btn.is-active { background: var(--brand-soft); color: var(--ink); box-shadow: inset 0 0 0 1px #ecec9a; }
.dot-badge {
  position: absolute; top: -4px; right: -6px; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; line-height: 14px; text-align: center;
  border: 2px solid var(--side);
}

/* 分區選單 */
.panel { overflow-y: auto; padding: 14px 10px; }
.panel-zone { display: none; }
.panel-zone.is-shown { display: block; }
.panel-title { font-size: .95rem; font-weight: 800; margin: 4px 8px 12px; }
.menu, .submenu { list-style: none; margin: 0; padding: 0; }
.menu > li + li { margin-top: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 10px;
  text-decoration: none; color: var(--ink-2); font-size: .93rem;
}
.menu-item:hover { background: #eceef2; }
.menu-item.is-active { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); }
.menu-item.is-locked { color: #9aa0aa; }
.menu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-ext { color: #9aa0aa; display: inline-flex; }
.submenu { margin: 2px 0 6px 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.menu-item.sub { min-height: 34px; font-size: .88rem; }
/* MIS 底下的「自動化程式」：大標＋各部門小標 */
.menu-heading {
  margin: 18px 8px 4px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: .85rem; font-weight: 800; color: var(--ink);
}
/* 部門小標：點小三角形收合／打開，有動畫 */
.menu-label {
  display: flex; align-items: center; gap: 6px; width: 100%; margin: 6px 0 0; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; font: inherit; font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .04em;
  cursor: pointer; text-align: left;
}
.menu-label:hover { background: #eceef2; color: var(--ink-2); }
.menu-label span:first-of-type { flex: 1; }
.menu-count { font-weight: 600; font-size: .72rem; color: #9aa0aa; }
.caret { flex: none; transition: transform .22s ease; }
.menu-group.is-open .caret { transform: rotate(90deg); }
.menu-collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.menu-group.is-open .menu-collapse { grid-template-rows: 1fr; }
.menu-collapse > .menu { overflow: hidden; min-height: 0; visibility: hidden; transition: visibility 0s .25s; }
.menu-group.is-open .menu-collapse > .menu { visibility: visible; transition-delay: 0s; }
.no-anim .menu-collapse, .no-anim .caret, .no-anim .menu-collapse > .menu { transition: none !important; }
@media (prefers-reduced-motion: reduce) { .menu-collapse, .caret { transition: none; } }
.pill {
  min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center;
}

/* 使用者 */
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--line); flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.who { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.who strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 主區 */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bg); }
.page-title { font-size: 1.05rem; font-weight: 800; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { position: relative; display: flex; align-items: center; gap: 8px; width: min(340px, 40vw); height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); flex: none; }
.search svg { flex: none; }
.search input { border: 0; outline: 0; min-height: 0; padding: 0; height: 100%; background: transparent; font-size: .9rem; }
.search:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; list-style: none; margin: 0; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .12); }
.search-results a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .9rem; }
.search-results a:hover { background: var(--bg); }
.search-results a span { color: var(--muted); font-size: .78rem; }
.search-results .empty { padding: 8px 10px; color: var(--muted); font-size: .85rem; }
.hintbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px;
  background: var(--brand-soft); border-bottom: 1px solid #ecec9a; font-size: .88rem; color: var(--ink-2);
}
.content { padding: 20px; max-width: 1400px; width: 100%; }
.content.solo { margin: 0 auto; max-width: 480px; }

/* 手機：選單變抽屜 */
.scrim { display: none; }
@media (max-width: 899px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(86vw, 292px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search { width: 38px; padding: 0 10px; }
  .search input { width: 0; }
  .search:focus-within { position: absolute; left: 12px; right: 12px; width: auto; z-index: 2; }
  .search:focus-within input { width: 100%; }
  .hintbar { padding: 8px 12px; font-size: .82rem; }
  .content { padding: 14px 12px; }
}

/* 預覽提示 */
.preview-bar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; background: var(--brand); color: var(--ink); font-size: .92rem;
}
.preview-bar form { margin: 0; }

/* 按鈕 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { box-shadow: inset 0 -3px 0 var(--brand); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .86rem; }
.btn-block { width: 100%; }

/* 面板、提示 */
.panel-card { background: var(--card); border-radius: var(--radius); padding: 24px; border: 1px solid var(--line); }
.login { margin: 12vh auto 0; display: grid; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; font-weight: 800; }
.alert { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.notice { margin-bottom: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--brand-soft); border: 1px solid #ecec9a; }
.notice p { margin: 4px 0 0; }
.big-icon { font-size: 2.5rem; }
.intro { margin: 0 0 14px; color: var(--muted); font-size: .88rem; }

/* 數字卡片 */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.stat-value small { font-size: .85rem; font-weight: 600; margin-left: 2px; color: var(--ink-2); }
.stat-note { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.stat-value.warn { color: var(--yellow); }
.stat-value.bad { color: var(--red); }
.stat-value.good { color: var(--green); }

/* 首頁：分區與卡片 */
.zone { margin-bottom: 20px; }
.zone-title { font-size: .92rem; color: var(--ink-2); margin: 0 0 8px; padding-left: 10px; border-left: 4px solid var(--brand); }
.cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); text-decoration: none; min-height: 100px; min-width: 0;
}
.card:hover { border-color: #c9ccd3; box-shadow: 0 2px 8px rgba(16, 24, 40, .06); }
.card-locked { background: #fafafa; color: var(--muted); border-style: dashed; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--ink); display: grid; place-items: center; flex: none; }
.card-locked .card-icon { background: #f0f1f3; color: #9aa0aa; }
.card-name { font-weight: 700; font-size: 1rem; }
.card-summary { margin: 0; font-size: .88rem; color: var(--ink-2); flex: 1; }
.card-locked .card-summary { color: var(--muted); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .8rem; }
.stage, .tag { padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); font-size: .76rem; }
.badge {
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--red); color: #fff;
  display: inline-grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.light { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; }
.light::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.light-green { color: var(--green); }
.light-yellow { color: var(--yellow); }
.light-red { color: var(--red); }
.light-gray { color: #9aa0aa; }

/* 表格（電腦版）／卡片（手機） */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row-yellow td { background: #fffbeb; }
.table tr.row-gray td { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; word-break: break-all; }
.only-desktop { display: none; }
@media (min-width: 900px) { .only-desktop { display: block; } .only-mobile { display: none; } }

/* 系統健康（手機卡片） */
.jobs { display: grid; gap: 10px; }
.job { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: var(--radius); padding: 12px 14px; }
.job-yellow { border-left-color: var(--yellow); background: #fffbeb; }
.job-red { border-left-color: var(--red); }
.job-gray { border-left-color: #c9ccd3; }
.job-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; word-break: break-all; }
.job-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 8px 0; font-size: .84rem; }
.job-meta div { display: flex; gap: 6px; min-width: 0; }
.job-meta dt { color: var(--muted); white-space: nowrap; }
.job-meta dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.runs { display: flex; gap: 4px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 3px; background: var(--line); }
.dot-success { background: var(--green); }
.dot-failed { background: var(--red); }
.dot-running { background: #93c5fd; }
.job-error { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: #fef2f2; color: #991b1b; font-size: .84rem; }

/* 清單、表單 */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.log { align-items: flex-start; font-size: .88rem; word-break: break-all; }
.result { white-space: nowrap; font-size: .8rem; font-weight: 700; }
.result-成功 { color: var(--green); }
.result-拒絕 { color: var(--red); }
.result-失敗 { color: var(--yellow); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters label { display: grid; gap: 2px; font-size: .8rem; color: var(--muted); }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; color: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--ink-2); }
.search input:focus { outline: 0; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.row-end select { width: auto; }
.compact textarea { min-height: 60px; }
.fb { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.fb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fb-content { margin: 6px 0; }
.fb-reply { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.status-new { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.pager { display: flex; gap: 12px; justify-content: center; margin: 12px 0; }

/* 問題回報小視窗 */
.dialog { width: min(92vw, 480px); border: 0; border-radius: var(--radius); padding: 18px; }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }

/* 模組說明頁 */
.info-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 18px; }
@media (min-width: 900px) { .info-grid { grid-template-columns: 2fr 1fr; } }
.info-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.info-card h2 { font-size: .95rem; }
.info-detail { white-space: pre-line; margin: 0; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* 首頁：自動化程式的部門小標 */
.zone-sub { margin: 14px 0 8px; font-size: .88rem; font-weight: 700; color: var(--muted); }

/* 卡片「上線中」標籤（完成的不顯示） */
.stage-live { background: var(--brand-soft); color: var(--ink); border-color: #ecec9a; }
.card-foot { margin-top: auto; }

/* 操作結果提示 */
.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: var(--brand-soft); border-color: #ecec9a; color: var(--ink); }

/* 網路查價 */
.pm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.pm-head .spacer { flex: 1; }
.pm-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.pm-result { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.pm-result h3 { margin: 0 0 4px; font-size: 1rem; }
.pm-result .range { color: var(--muted); font-size: .85rem; }
.pm-ok { color: #047857; font-weight: 600; margin: 8px 0 0; }
.pm-bad { color: #b45309; font-weight: 700; margin: 8px 0 6px; }
.pm-fail { color: #b91c1c; font-weight: 700; margin: 8px 0 0; }
.pm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pm-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: .9rem; }
.pm-price { font-weight: 700; min-width: 70px; }
.pm-link { color: var(--ink-2); word-break: break-all; flex: 1 1 200px; }
.pm-streak { font-size: .74rem; padding: 1px 7px; border-radius: 999px; background: #fef3c7; color: #92400e; }
.pm-report { white-space: pre-wrap; word-break: break-all; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: .85rem; }
.form-grid { display: grid; gap: 14px; max-width: 640px; }
.form-grid label, .field > span { font-weight: 600; font-size: .9rem; }
.field { display: grid; gap: 6px; }
.field input[type=text], .field input[type=number], .field input[type=time], .field input[type=email], .field textarea, .field select {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff;
}
.field .help { color: var(--muted); font-size: .8rem; }
.field .err { color: #b91c1c; font-size: .82rem; }
.field ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.field ul label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: inline; }
.field input[type=checkbox], .field input[type=radio] { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--ink); }
.field ul label, .check { justify-content: flex-start; }
.field ul label { min-height: 36px; }
