:root {
  --bg: #f7f5f0; --surface: #ffffff; --surface-2: #f1eee7; --line: #e4dfd5; --line-strong: #cfc7b8;
  --text: #24211c; --muted: #6f685d; --accent: #b4552d; --accent-ink: #ffffff; --accent-soft: #f6e6dc;
  --mod: #c62828; --ok: #2f7d4f; --ok-soft: #e3f1e8; --bad: #b3261e; --bad-soft: #f8e1df; --warn: #9a6400; --warn-soft: #fbefd6;
  --radius: 10px; --shadow: 0 1px 2px rgba(36, 33, 28, .06), 0 2px 8px rgba(36, 33, 28, .04);
  /* 模組代表色（圖示底色／字色）：門市、生產、包裝、倉儲、財務、管理、其他 */
  --h-store-bg: #fbe5d6; --h-store: #b4552d; --h-prod-bg: #e2f0e4; --h-prod: #2f7d4f; --h-pack-bg: #ece4f5; --h-pack: #6b4a9b;
  --h-wh-bg: #e0ecf7; --h-wh: #2b6295; --h-fin-bg: #dff1ee; --h-fin: #1f7a6d; --h-mgmt-bg: #e8e6e1; --h-mgmt: #4f4a42;
  --h-other-bg: #f1eee7; --h-other: #6f685d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19; --surface: #252421; --surface-2: #2d2b28; --line: #3a3834; --line-strong: #4a4742;
    --text: #ece9e2; --muted: #a59f94; --accent: #e08a5f; --accent-ink: #1c1b19; --accent-soft: #3d2c22;
    --mod: #ff6b6b; --ok: #6cc38e; --ok-soft: #22362a; --bad: #f0857c; --bad-soft: #3f2422; --warn: #e6b45c; --warn-soft: #3b3020;
    --shadow: none;
    --h-store-bg: #3d2c22; --h-store: #f0a27a; --h-prod-bg: #213529; --h-prod: #7fcf9c; --h-pack-bg: #30273d; --h-pack: #c3a6ea;
    --h-wh-bg: #1f2e3d; --h-wh: #8ebfe8; --h-fin-bg: #1d3532; --h-fin: #7fd3c5; --h-mgmt-bg: #34322e; --h-mgmt: #cfc9bf;
    --h-other-bg: #2d2b28; --h-other: #a59f94;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, "Segoe UI", "Noto Sans TC",
  "PingFang TC", "Microsoft JhengHei", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: .2px; }
h2 { font-size: 16px; margin: 28px 0 10px; font-weight: 650; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

header.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top .in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; height: 56px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 15px; }
nav.main { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav.main a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
nav.main a.on, nav.main a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.who form { margin: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid2 > .card { margin-top: 0; }
.grid2 + .card, .card + .grid2 { margin-top: 16px; }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

button, .btn { font: inherit; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--muted); padding: 4px 6px; }
button.link:hover { color: var(--text); background: none; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin: 6px 14px 6px 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=url],
select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select.compact { width: auto; padding: 4px 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: none; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--line-strong); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

/* 首頁磁磚 */
.search { max-width: 320px; }
.cat { margin-top: 26px; }
.cat h2 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 30px 16px 16px; display: flex; gap: 12px; color: var(--text); box-shadow: var(--shadow); transition: border-color .12s, transform .12s; }
.tile:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.tile .ico { flex: 0 0 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; font-weight: 700; }
.tile .name { font-weight: 600; }
.tile .mod { display: inline-block; font-size: 12px; font-weight: 800; color: var(--mod); margin-right: 6px; }   /* 模組名：紅色粗體（使用者 2026-11-12 指示） */
.tile .desc { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.tile .dot { position: absolute; top: 12px; right: 12px; }
.tile .pin { bottom: 8px; right: 8px; }
.tile:hover { border-color: var(--hf, var(--accent)); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* 登入頁 */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 380px; }
.auth .tiles { grid-template-columns: 1fr; }
.auth .brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.auth .card { padding: 24px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.full { width: 100%; justify-content: center; }

/* 登入頁（2026-11-12 改版）：左側品牌、右側登入卡；手機只留登入卡 */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.login-hero { position: relative; overflow: hidden; color: #fff8f2;
  background: radial-gradient(120% 90% at 0% 0%, #d97a4a 0%, rgba(217,122,74,0) 55%),
              radial-gradient(90% 80% at 100% 100%, #7a2f14 0%, rgba(122,47,20,0) 60%),
              linear-gradient(150deg, #b4552d 0%, #8f3d1c 100%); }
.login-hero::after { content: ""; position: absolute; inset: 0; opacity: .08; pointer-events: none;
  background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 22px 22px; }
.login-hero-in { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 48px clamp(28px, 5vw, 72px); gap: 22px; }
.brand.big { font-size: 22px; color: #fff; }
.brand.big .mark { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; background: rgba(255,255,255,.18);
  color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.tagline { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.35; font-weight: 700; letter-spacing: .5px; margin: 0; }
.mods { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.mods li { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.mods .sw { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.85); }
.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; gap: 22px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 30px 26px; box-shadow: 0 1px 2px rgba(36,33,28,.05), 0 12px 32px rgba(36,33,28,.08); }
.login-card h1 { font-size: 24px; margin: 0; }
.login-card .sub { margin: 6px 0 20px; }
.login-card .brand.only-sm { display: none; }
.login-card .flash { margin-bottom: 14px; }
/* Google 按鈕：佔位與真按鈕疊在同一格，好了淡入，不跳動 */
.gslot { position: relative; height: 44px; }
.gslot .gsi { position: absolute; inset: 0; display: flex; justify-content: center; opacity: 0; transition: opacity .18s; }
.gslot.ready .gsi { opacity: 1; }
.gslot.ready .gbtn-ph { opacity: 0; pointer-events: none; }
.gbtn-ph { position: relative; width: 100%; height: 40px; margin: 2px 0; border-radius: 999px; border: 1px solid #dadce0;
  background: #fff; color: #3c4043; font: 400 14px/1 "Google Sans", Roboto, -apple-system, "Noto Sans TC", sans-serif;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: opacity .18s, background .12s;
  text-decoration: none; padding: 0 40px; }
.gbtn-ph:hover { background: #f8f9fa; text-decoration: none; }
.gbtn-ph .g { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; }
.gbtn-ph.loading span::after { content: "…"; }
.pwform label { margin-top: 10px; }
.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  color: var(--muted); font-size: 13px; padding: 4px 10px; }
.pw-toggle:hover { color: var(--text); background: none; }
.login-btn { margin-top: 18px; height: 44px; border-radius: 999px; font-size: 15px; }
.login-card .help { text-align: center; margin: 14px 0 0; }
.login-public { width: 100%; max-width: 400px; }
.login-public h2 { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 1px; margin: 0 0 8px 4px; }
.pub-grid { display: grid; gap: 8px; }
.pub { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); color: var(--text); transition: border-color .12s, transform .12s; }
.pub:hover { border-color: var(--hf); text-decoration: none; transform: translateX(2px); }
.pub .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 700;
  background: var(--hb); color: var(--hf); flex: 0 0 32px; }
.pub .t { flex: 1; min-width: 0; }
.pub .mod { font-size: 12px; font-weight: 800; color: var(--mod); margin-right: 6px; }
.pub .name { font-weight: 600; }
.pub .arrow { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .login-card { box-shadow: none; }
  .gbtn-ph { background: #fff; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-main { justify-content: flex-start; padding-top: 48px; }
  .login-card .brand.only-sm { display: flex; margin-bottom: 18px; }
  .login-card .brand.only-sm > span:last-child { display: inline; }
}
@media (max-width: 420px) { .login-card { padding: 24px 18px 20px; border-radius: 14px; } }

.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; letter-spacing: 2px; background: var(--surface-2);
  padding: 12px 16px; border-radius: 8px; display: inline-block; user-select: all; }

/* 模組色 */
.hue-store { --hb: var(--h-store-bg); --hf: var(--h-store); } .hue-prod { --hb: var(--h-prod-bg); --hf: var(--h-prod); }
.hue-pack { --hb: var(--h-pack-bg); --hf: var(--h-pack); } .hue-wh { --hb: var(--h-wh-bg); --hf: var(--h-wh); }
.hue-fin { --hb: var(--h-fin-bg); --hf: var(--h-fin); } .hue-mgmt { --hb: var(--h-mgmt-bg); --hf: var(--h-mgmt); }
.hue-other { --hb: var(--h-other-bg); --hf: var(--h-other); }
.tile .ico, .qa .ico, .app-ico { background: var(--hb, var(--accent-soft)); color: var(--hf, var(--accent)); }
.app-ico { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 28px; }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--bad);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* 首頁：問候＋搜尋 */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.hero h1 { font-size: 24px; }
.searchbox { position: relative; flex: 1 1 320px; max-width: 440px; }
.searchbox input { padding: 11px 44px 11px 14px; font-size: 15px; border-radius: 12px; box-shadow: var(--shadow); }
.searchbox kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 12px ui-monospace, Menlo, monospace;
  color: var(--muted); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 7px; background: var(--surface-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 4px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .n { font-size: 11px; opacity: .7; }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--hf, var(--muted)); }

/* 首頁：常用（大按鈕） */
.quick { margin-top: 22px; }
.quick h2, .cat h2 { display: flex; align-items: baseline; gap: 8px; }
.quick h2 .hint, .cat h2 .hint { font-weight: 400; letter-spacing: 0; }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qa { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 12px 12px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s; }
.qa:hover { border-color: var(--hf, var(--accent)); text-decoration: none; transform: translateY(-2px); }
.qa .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.qa .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.qa .meta { font-size: 11px; color: var(--muted); }
.qa .pin, .tile .pin { position: absolute; border: 0; background: none; padding: 2px 4px; font-size: 15px; line-height: 1; color: var(--line-strong); }
.qa .pin { top: 6px; right: 6px; }
.qa .dot { position: absolute; top: 10px; left: 10px; }
.pin.on { color: #d9a400; }
.pin:hover { color: #d9a400; background: none; }
.no-match { text-align: center; color: var(--muted); padding: 32px 0; }

/* 管理：總覽 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  color: var(--text); display: block; }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.warn { border-color: var(--warn); background: var(--warn-soft); } .stat.warn .v { color: var(--warn); }
.stat.bad { border-color: var(--bad); background: var(--bad-soft); } .stat.bad .v { color: var(--bad); }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.todo li:last-child { border-bottom: 0; }
.todo .grow { flex: 1; min-width: 0; }
.allclear { color: var(--ok); display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 70px; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.bar-row .lbl { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--hf, var(--accent)); }
.bar-row .num { text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* 管理：分頁列、帳號列表 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--surface-2); color: var(--muted); flex: 0 0 32px; }
.avatar.admin { background: var(--accent-soft); color: var(--accent); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .nm { font-weight: 600; color: var(--text); }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar .chips { margin: 0; }
.toolbar form { display: flex; gap: 8px; }
.grant-cat td { background: var(--surface-2); font-weight: 600; font-size: 13px; }
.grant-cat select { font-weight: 400; }

@media (max-width: 640px) {
  header.top .in { gap: 10px; }
  .who .name, .brand > span:last-child { display: none; }
  .card { padding: 16px; }
  th.hide-sm, td.hide-sm { display: none; }
  .qa-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .bar-row { grid-template-columns: 1fr 70px; } .bar-row .bar { display: none; }
  .searchbox { max-width: none; }
}

/* 產品外網入口的登入、核准與登出確認頁。 */
@media (max-width: 767px) {
  .product-entry { font-size: 16px; overflow-wrap: anywhere; }
  .product-entry :is(.small, .mono, .gbtn-ph, .login-btn, .pw-toggle, .divider, label, .mark) { font-size: 16px; }
  .product-entry :is(button, a[href], input:not([type=hidden])) { min-height: 44px; min-width: 44px; }
  .product-entry a[href] { display: inline-flex; align-items: center; }
  .product-entry .gbtn-ph { margin-block: 0; }
  .product-entry :is(.auth-wrap, .login-main) { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
