/* MaKarma 營運中控台：奶油白底、黑字、黃綠色重點。
   黃綠色只用在「選取中、主要按鈕、滑過」；連結文字用深綠。不用紫色，也不用黑色硬陰影。 */
:root {
  --bg: #f5f2e8;
  --surface: #fffdf6;
  --ink: #1a1a17;
  --muted: #66635a;
  --line: #1a1a17;
  --divider: #ddd7c6;
  --accent: #c6e34a;
  --accent-light: #eef6c8;
  --accent-dark: #4f6b0e;
  --danger: #c2410c;
  --danger-light: #fbe6da;
  --warn: #8a5a08;
  --warn-light: #f8ecc9;
  --ok: #3d5a0c;
  --radius: 12px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0; }
p { margin: 0; }
a { color: var(--accent-dark); }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.empty { padding: 32px 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 按鈕 */
.btn { font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 18px; transition: background .12s; }
.btn:hover { background: var(--accent-light); }
.btn.primary { background: var(--accent); box-shadow: 3px 3px 0 var(--ink); }
.btn.primary:hover { background: #b9d93a; }
.btn.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.quiet { border-color: var(--divider); background: transparent; }
.btn.quiet:hover { border-color: var(--line); background: var(--surface); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-light); }
.btn.small { padding: 4px 14px; font-size: 13.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { font: inherit; font-weight: 600; background: none; border: 0; padding: 0; color: var(--accent-dark); text-decoration: underline; cursor: pointer; }
.link-tool { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--divider); }
.link-tool:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* 頁首 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1340px; margin: 0 auto; padding: 18px 24px 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); border: 1.5px solid var(--line); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--ink); }
.kicker { font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.top h1 { font-size: 22px; font-weight: 900; letter-spacing: .02em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }

/* 版面：左側欄 + 主畫面 */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 28px; max-width: 1340px; margin: 0 auto; padding: 0 24px; align-items: start; }
.shell > main { min-width: 0; padding: 14px 0 48px; }

.sidebar { position: sticky; top: 14px; margin-top: 14px; display: grid; gap: 12px; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; max-height: calc(100vh - 28px); overflow: auto; }
.side-nav { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.side-item { font: inherit; font-weight: 700; text-align: left; cursor: pointer; color: var(--ink); background: transparent; border: 1.5px solid transparent; border-radius: 10px; padding: 7px 12px; display: flex; align-items: center; gap: 8px; }
.side-item:hover { background: var(--accent-light); }
.side-item.is-active { background: var(--accent); border-color: var(--line); }
.side-item.is-sub { font-weight: 600; font-size: 14px; padding: 5px 12px; }
.side-count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted); }
.side-item.is-active .side-count { color: var(--ink); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.side-head h2 { font-size: 12.5px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.side-pinned { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-row { display: grid; gap: 4px; }
.side-link { display: block; padding: 6px 12px; border-radius: 10px; color: var(--ink); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-dark); margin-right: 10px; vertical-align: middle; }
.side-link:hover { background: var(--accent-light); }
.side-tools { display: flex; gap: 6px; padding-left: 12px; }
.side-mini { font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--divider); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 0 8px; }
.side-mini:hover:not(:disabled) { border-color: var(--line); }
.side-mini:disabled { opacity: .35; cursor: not-allowed; }
.side-manage { border-top: 1px solid var(--divider); padding-top: 10px; }
.side-manage summary { cursor: pointer; font-size: 12.5px; font-weight: 800; letter-spacing: .12em; color: var(--muted); padding: 2px 4px; }
.side-manage summary:hover { color: var(--ink); }
.side-manage-items { display: grid; gap: 2px; margin-top: 6px; }

/* 搜尋列 */
.home-search { position: relative; }
.home-search input, .links-bar input[type="search"] { font: inherit; font-size: 16px; color: var(--ink); width: 100%; height: 50px; padding: 0 48px 0 20px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; }
.home-search input:focus, .links-bar input[type="search"]:focus { outline: 0; box-shadow: 0 0 0 4px var(--accent-light); border-color: var(--ink); }
.search-key { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--divider); border-radius: 6px; padding: 0 7px; pointer-events: none; }
.home-total { margin: 10px 4px 0; color: var(--muted); font-size: 13.5px; }
.links-bar { display: flex; align-items: stretch; gap: 10px; }
.links-bar input[type="search"] { flex: 1 1 auto; width: auto; min-width: 0; padding-right: 20px; }
.status-select { flex: none; display: flex; }
.status-select select { width: auto; height: 50px; padding: 0 14px; font-weight: 600; border-radius: 999px; cursor: pointer; }
.manage-toggle { flex: none; height: 50px; padding: 0 22px; }
.manage-toggle.is-active { background: var(--accent); }
.manage-hint { margin: 2px 0 8px; }

/* 篩選膠囊 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 10px; }
.filter, .link-filter, .tab { font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); background: var(--surface); border: 1.5px solid var(--divider); border-radius: 999px; padding: 4px 14px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.filter:hover, .link-filter:hover, .tab:hover { border-color: var(--line); }
.filter.is-active, .link-filter.is-active, .tab.is-active { background: var(--accent); border-color: var(--line); }
.link-filter .count { font-size: 12px; font-weight: 700; color: var(--muted); }
.link-filter.is-active .count { color: var(--ink); }
.link-filter.is-sortable { cursor: grab; }
.link-filter.is-dragging { opacity: .4; }
.link-filter.is-drop-target { outline: 2px dashed var(--ink); outline-offset: 3px; }
.tabs { display: flex; gap: 8px; margin: 0 0 18px; }

/* 首頁區塊 */
.home-block { margin-top: 26px; }
.block-title { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--muted); margin: 0 0 10px 4px; }
.tile-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cat-grid { columns: 3; column-gap: 12px; }
.cat-tile { break-inside: avoid; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 16px 10px; min-width: 0; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat-head h3 { font-size: 16px; font-weight: 800; }
.cat-count { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.cat-links { list-style: none; margin: 0; padding: 0; display: grid; }
.cat-links li { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding: 5px 0; border-top: 1px solid var(--divider); }
.cat-links li:first-child { border-top: 0; }
.cat-links a { flex: none; max-width: 60%; font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-links a:hover { color: var(--accent-dark); text-decoration: underline; }
.cat-desc { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tile .hint { font-size: 12.5px; }
.cat-more { align-self: flex-start; font: inherit; font-size: 13px; font-weight: 700; color: var(--accent-dark); background: none; border: 0; padding: 2px 0; cursor: pointer; }
.cat-more:hover { text-decoration: underline; }
.client-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.client-line { color: var(--muted); }
.client-line strong { color: var(--ink); }

/* 入口卡片：整張可點、約 76px 高 */
.link-list { display: grid; gap: 4px; margin-top: 4px; }
.link-section { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; margin: 22px 0 10px; }
.link-section::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.section-count { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.link-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.link-card { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; min-height: 76px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 11px 14px 10px; transition: background .12s; }
.link-card:hover { background: var(--accent-light); }
.link-card.status-hidden { opacity: .55; }
.link-head { display: flex; align-items: flex-start; gap: 8px; }
.link-head h3 { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.card-title-link { color: var(--ink); text-decoration: none; }
.link-card.is-single .card-title-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.link-desc { color: var(--muted); font-size: 13px; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip-static { font-size: 12px; font-weight: 600; color: var(--ink); background: var(--bg); border: 1px solid var(--divider); border-radius: 999px; padding: 0 9px; white-space: nowrap; }
.link-urls { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.link-urls li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.quick-link { position: relative; z-index: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 12px; }
.quick-link:hover { background: var(--accent); }
.link-foot { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: auto; padding-top: 6px; }
.pin-btn { position: relative; z-index: 1; flex: none; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); background: transparent; border: 1px solid var(--divider); border-radius: 999px; padding: 0 9px; }
.pin-btn:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.pin-btn.is-on { color: var(--ink); background: var(--accent); border-color: var(--line); }
.link-card .link-tool { position: relative; z-index: 1; }
.link-card.is-compact .link-desc { white-space: nowrap; }
@media (hover: hover) {
  .link-foot, .pin-btn:not(.is-on) { opacity: 0; transition: opacity .12s; }
  .link-card:hover .link-foot, .link-card:focus-within .link-foot, .link-card:hover .pin-btn, .link-card:focus-within .pin-btn { opacity: 1; }
}

/* 客戶 */
.client-list { display: grid; gap: 6px; margin-top: 4px; }
.client-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.client-card.status-ended { opacity: .6; }
.client-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 16px; min-height: 40px; }
.client-card > summary::-webkit-details-marker { display: none; }
.client-card > summary::before { content: "▸"; color: var(--muted); transition: transform .12s; }
.client-card[open] > summary::before { transform: rotate(90deg); }
.client-card > summary:hover { background: var(--accent-light); border-radius: var(--radius); }
.client-name { font-weight: 800; font-size: 15.5px; }
.kind-tag { font-size: 12px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; }
.kind-tag.is-seo { background: var(--accent-light); }
.kind-tag.is-system { background: var(--warn-light); }
.kind-tag.is-muted { border-color: var(--divider); color: var(--muted); }
.client-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.client-body { display: grid; gap: 12px; padding: 4px 16px 14px 36px; border-top: 1px solid var(--divider); padding-top: 12px; }
.base-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.base-link { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--divider); border-radius: 999px; padding: 2px 12px; }
.base-link a { font-weight: 700; text-decoration: none; color: var(--ink); }
.base-link a:hover { color: var(--accent-dark); text-decoration: underline; }
.delivery-list { list-style: none; margin: 0; padding: 0; display: grid; }
.delivery { display: grid; grid-template-columns: 86px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid var(--divider); }
.delivery:first-child { border-top: 0; }
.type-tag { justify-self: start; font-size: 12px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; background: var(--surface); white-space: nowrap; }
.type-tag.is-keyword { background: var(--accent); }
.type-tag.is-client { background: var(--accent-light); }
.type-tag.is-results { background: var(--warn-light); }
.delivery-title { font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery-title:hover { color: var(--accent-dark); text-decoration: underline; }
.delivery-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.delivery-tools { display: flex; gap: 12px; white-space: nowrap; }
.client-notes { white-space: pre-wrap; color: var(--muted); font-size: 13.5px; }
.client-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.orphans { margin: 6px 0 10px; background: var(--warn-light); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
.orphans summary { cursor: pointer; font-weight: 700; }
.orphans .delivery-list { margin-top: 8px; }

/* SEO 客戶：進度標籤與首頁小卡 */
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.block-head .block-title { margin: 0 0 0 4px; }
.seo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.seo-tile { display: grid; gap: 6px; min-width: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 11px 14px 12px; }
.seo-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seo-name { font: inherit; font-size: 15.5px; font-weight: 800; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seo-name:hover { color: var(--accent-dark); text-decoration: underline; }
.seo-head .stage-tag { margin-left: auto; flex: none; }
.seo-meta { font-size: 13px; color: var(--muted); min-height: 20px; }
.seo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-tag { font-size: 12px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; white-space: nowrap; background: var(--surface); }
.stage-tag.is-selecting { background: var(--accent); }
.stage-tag.is-proposal { background: var(--warn-light); }
.stage-tag.is-review { background: var(--accent-light); }
.stage-tag.is-closed { border-color: var(--divider); color: var(--muted); }
.todo-tag { font-size: 12px; font-weight: 700; color: var(--danger); background: var(--danger-light); border-radius: 6px; padding: 0 7px; white-space: nowrap; }
.client-progress { font-size: 13px; font-weight: 600; color: var(--muted); }
.client-card.stage-closed { opacity: .65; }
.seo-status { margin: 10px 4px 0; }
.seo-status.is-error { color: var(--warn); }
.delivery.is-keyword-page .delivery-title { font-weight: 700; }
@media (max-width: 1100px) { .seo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .seo-grid { grid-template-columns: 1fr; } }

/* 提示訊息 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--surface); font-weight: 600; padding: 9px 18px; border-radius: 999px; max-width: calc(100vw - 32px); }
.ok-note { color: var(--ok); font-size: 13.5px; }
.field-error { color: var(--danger); font-size: 13.5px; }
.field-error.is-warn { color: var(--warn); }

/* ===== 管理：店家與合約 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0; }
.stat { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.stat dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat dd { margin: 2px 0 4px; font-size: 28px; font-weight: 900; line-height: 1.2; }
.stat.is-warn { background: var(--warn-light); }
.stat.is-danger { background: var(--danger-light); }
.stat.is-danger dd { color: var(--danger); }
.stat-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.stat-chips span { font-size: 12px; font-weight: 600; padding: 0 9px; border: 1px solid var(--divider); border-radius: 999px; background: var(--bg); white-space: nowrap; }

.attention { margin-top: 14px; padding: 12px 16px; background: var(--warn-light); border: 1.5px solid var(--line); border-radius: var(--radius); }
.attention h2 { font-size: 15px; margin-bottom: 6px; }
.attention ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.attention li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tag { font-size: 13px; font-weight: 700; }
.tag.is-expired { color: var(--danger); }
.tag.is-soon { color: var(--warn); }

.store-list { display: grid; gap: 10px; }
.store { display: grid; grid-template-columns: minmax(0, 2.2fr) 90px 150px minmax(0, 2fr) minmax(0, 1.4fr) auto; gap: 16px; align-items: center; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.store-main { min-width: 0; }
.store-main h2 { font-size: 16.5px; font-weight: 800; overflow-wrap: anywhere; }
.store.status-ended .store-main h2 { color: var(--muted); }
.notes { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-fee { display: grid; }
.store-fee .fee { font-weight: 700; }
.store-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.store-actions .btn { padding: 5px 14px; }
.store-links { display: flex; flex-wrap: wrap; gap: 6px; }
.store-links .link-chip { font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 12px; }
.store-links .link-chip:hover { background: var(--accent); }

.badge { display: inline-block; white-space: nowrap; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--divider); }
.badge.is-running { background: var(--accent-light); color: var(--ink); border-color: var(--line); }
.badge.is-building { background: var(--surface); color: var(--ink); border-color: var(--line); }
.badge.is-paused { background: var(--warn-light); color: var(--warn); border-color: var(--warn); }

.bar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--accent); }
.bar-fill.is-soon { background: #e8b93a; }
.bar-fill.is-expired { background: var(--danger); }
.bar-fill.is-ended { background: var(--muted); }
.contract-text { font-size: 13.5px; }
.contract-text.is-soon { color: var(--warn); font-weight: 700; }
.contract-text.is-expired { color: var(--danger); font-weight: 700; }
.contract-text.is-none, .contract-text.is-ended { color: var(--muted); }

/* 系統類型 */
.types-intro { margin-bottom: 14px; }
.type-list { display: grid; gap: 10px; }
.type-card { display: grid; gap: 8px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.type-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.type-head h2 { font-weight: 800; font-size: 17px; }
.type-key { font-size: 12.5px; background: var(--bg); border: 1px solid var(--divider); border-radius: 6px; padding: 0 8px; }
.type-desc { overflow-wrap: anywhere; }
.type-stores { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--divider); }
.type-count { font-weight: 900; margin-right: 4px; }
.chip { font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); padding: 1px 12px; }
.chip:hover { background: var(--accent-light); }
.chip.status-ended, .chip.status-paused { color: var(--muted); }

/* 異動紀錄 */
.audit { margin-top: 28px; }
.audit summary { cursor: pointer; font-weight: 800; padding: 6px 0; }
.audit-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.audit-list li { display: grid; grid-template-columns: 170px minmax(0, 1fr); column-gap: 12px; }
.audit-list time { color: var(--muted); }
.audit-list .muted { grid-column: 2; }

/* 店家 Logo */
.store-icon { flex: none; width: 48px; height: 48px; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: inline-grid; place-items: center; }
.store-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.store-icon.is-empty { background: var(--accent-light); font-weight: 900; font-size: 22px; }
.store-icon.is-lg { width: 72px; height: 72px; border-radius: 16px; font-size: 32px; }
.icon-edit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ===== 對話框與表單 ===== */
dialog { width: min(580px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 0; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; }
dialog::backdrop { background: rgba(26, 26, 23, .45); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { font-size: 19px; font-weight: 900; }
.field { display: grid; gap: 4px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label, .field-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; padding: 8px 10px; background: #fff; border: 1.5px solid var(--divider); border-radius: 10px; }
input:hover, select:hover, textarea:hover { border-color: #bdb6a2; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-light); }
textarea { resize: vertical; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check-row input { width: auto; flex: none; accent-color: var(--accent-dark); }
.dialog-actions { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-rows { display: grid; gap: 8px; }
.link-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; }
.link-rows.is-single .link-row { grid-template-columns: minmax(0, 1fr) auto; }
.link-rows.is-single .row-label { display: none; }
.more-box { border-top: 1px solid var(--divider); padding-top: 10px; }
.more-box summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 4px 0; }
.more-box[open] summary { color: var(--ink); }
.more-fields { display: grid; gap: 14px; margin-top: 10px; }

/* 店家頁（遠端管理） */
.remote { padding: 22px; display: grid; gap: 16px; }
.remote h2 { font-size: 19px; font-weight: 900; }
.remote h3 { font-size: 15px; }
.remote-section { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--divider); }
.remote-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.remote-head input { width: auto; }
.remote-number { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.remote-number strong { font-size: 34px; font-weight: 900; line-height: 1.2; }
.module-list { display: grid; gap: 6px; }
.module-group { margin: 14px 0 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.module-group:first-child { margin-top: 0; }
.module-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--divider); border-radius: 10px; background: #fff; font-weight: 600; cursor: pointer; }
.module-row:has(input:checked) { background: var(--accent-light); border-color: var(--line); }
.module-row input { width: auto; flex: none; accent-color: var(--accent-dark); }
.module-row.is-locked { cursor: default; color: var(--muted); }
.key-state { margin-left: 8px; font-weight: 700; color: var(--muted); }
.key-state.is-set { color: var(--ok); }

/* 登入頁 */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; padding: 28px; display: grid; gap: 6px; }
.login-card h1 { font-size: 24px; font-weight: 900; }
.login-card h1 .dot { color: var(--accent-dark); }
.login-card h1 .zh { margin-left: 8px; }
.login-card form { display: grid; gap: 8px; margin-top: 16px; }
.login-card .btn { margin-top: 8px; }

/* ===== 窄螢幕 ===== */
@media (max-width: 1100px) {
  .link-cards, .tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-grid { columns: 2; }
}
@media (max-width: 860px) {
  .top { padding: 14px 16px 6px; }
  .top h1 { font-size: 19px; }
  .top-actions .btn { padding: 6px 14px; }
  .menu-btn { display: inline-block; }
  .shell { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .sidebar { display: none; position: static; margin: 8px 0 0; max-height: none; }
  body.menu-open .sidebar { display: grid; }
  .links-bar { flex-wrap: wrap; }
  .links-bar input[type="search"] { flex-basis: 100%; height: 46px; }
  .home-search input { height: 46px; }
  .status-select select, .manage-toggle { height: 40px; font-size: 14px; }
  .category-filters { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 4px 16px 10px; scrollbar-width: none; }
  .category-filters::-webkit-scrollbar { display: none; }
  .link-filter { flex: none; }
  .store { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
  .store-status { justify-self: end; }
  .store-fee, .store-contract, .store-url { grid-column: 1 / -1; }
  .store-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .audit-list li { grid-template-columns: 1fr; }
  .audit-list .muted { grid-column: 1; }
  .delivery { grid-template-columns: auto minmax(0, 1fr); }
  .delivery-meta, .delivery-tools { grid-column: 1 / -1; }
  .client-body { padding-left: 16px; }
  .client-chips { margin-left: 0; width: 100%; }
}
@media (max-width: 640px) {
  .link-cards { grid-template-columns: 1fr; }
  .cat-grid { columns: 1; }
  .tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile-row .link-card { min-height: 0; padding: 9px 12px; }
  .top h1 { white-space: nowrap; font-size: 17px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-mark::after { inset: 7px; }
  .top-actions { flex-wrap: nowrap; gap: 6px; }
  .top-actions .btn { padding: 5px 11px; font-size: 13.5px; }
  .field-row { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr auto; }
  .link-row .row-label { grid-column: 1 / -1; }
  .kicker { display: none; }
}
