/* 百駿訂單。配色取自官網 baichunfarm_index_pomelo.html 的柚子色系。
   官網的 #7DC041 配白字對比只有 2.3，當按鈕底色不及格，
   所以按鈕與連結用加深的 --accent #4A7F1E（白字 4.8，過 WCAG AA）。 */

:root {
  --bg: #FAFAF5;
  --card: #FFFFFF;
  --line: #E4E0D4;
  --text: #2D2D2D;
  --muted: #6E5D4E;
  --accent: #4A7F1E;
  --accent-text: #3F6E18;
  --accent-soft: #E6F1DA;
  --leaf: #7DC041;
  --yellow-soft: #FBF3CF;
  --yellow-ink: #6B5500;
  --danger: #B3261E;
  --danger-soft: #FBE4E2;
  --blue-soft: #E3EEF9;
  --blue-ink: #1F4E7A;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 2px 8px rgba(60, 50, 30, .05);
  --radius: 14px;
  --nav-h: 64px;
  --sidebar-w: 220px;
  color-scheme: light;
}

/* 預設淺色（使用者選的）。深色要在「更多 → 外觀」手動切，或選「跟隨系統」。
   data-theme 由 index.html 開頭的內聯腳本在 CSS 載入前就設好，才不會先閃一下淺色。
   深色 token 寫兩次（手動深色、跟隨系統時的深色），改顏色兩邊一起改。 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141611;
  --card: #1E211A;
  --line: #33382B;
  --text: #ECEBE4;
  --muted: #B0A594;
  --accent: #4A7F1E;
  --accent-text: #9ED36A;
  --accent-soft: #26331B;
  --yellow-soft: #3A3314;
  --yellow-ink: #F0DC7A;
  --danger: #F2867E;
  --danger-soft: #3D1F1C;
  --blue-soft: #1B2A38;
  --blue-ink: #9CC7F0;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #141611;
    --card: #1E211A;
    --line: #33382B;
    --text: #ECEBE4;
    --muted: #B0A594;
    --accent: #4A7F1E;
    --accent-text: #9ED36A;
    --accent-soft: #26331B;
    --yellow-soft: #3A3314;
    --yellow-ink: #F0DC7A;
    --danger: #F2867E;
    --danger-soft: #3D1F1C;
    --blue-soft: #1B2A38;
    --blue-ink: #9CC7F0;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
/* 只有手機版有固定在底部的導覽列，要留白 */
:root[data-layout="mobile"] body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent-text); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .v, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 頂欄與導覽 */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.sync { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-state="ok"]::before { background: var(--leaf); }
.sync[data-state="syncing"]::before { background: #E0B93A; }
.sync[data-state="error"]::before, .sync[data-state="unauthed"]::before { background: var(--danger); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 12px; min-height: 48px;
}
.nav a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a[aria-current="page"] { color: var(--accent-text); font-weight: 600; }

.top .undo-btn { margin-left: auto; }
.top .undo-btn:not([hidden]) + .sync { margin-left: 0; }

main { max-width: 980px; margin: 0 auto; padding: 16px; }

/* ---------------------------------------------------------------- 基本元件 */

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; color: var(--muted); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.explain { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-big { min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="date"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 420px) { .grid2.stack { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

.badge { display: inline-block; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; }
.badge.warn { background: var(--yellow-soft); color: var(--yellow-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--blue-soft); color: var(--blue-ink); }
.badge.gray { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }

/* ---------------------------------------------------------------- 指標卡 */

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } .kpis.three { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.card .kpi { box-shadow: none; background: var(--bg); }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; line-height: 1.25; margin-top: 2px; overflow-wrap: anywhere; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.kpi.good .v { color: var(--accent-text); }
.kpi.warn .v { color: var(--yellow-ink); }
.kpi.bad .v { color: var(--danger); }
a.kpi { color: inherit; display: block; }

.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--leaf); border-radius: 3px; }

/* ---------------------------------------------------------------- 清單 */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; }
.toolbar select { width: auto; flex: 0 0 auto; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list .empty { padding: 24px; text-align: center; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); color: inherit; min-height: 56px; }
.row:first-child { border-top: 0; }
a.row:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.row-main { flex: 1; min-width: 0; }
.row-main .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { text-align: right; flex: 0 0 auto; }
.row-side .money { font-weight: 700; }
.row-side .badges { display: flex; gap: 4px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.row .pick { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.more { display: block; text-align: center; padding: 14px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; color: var(--accent-text); font-weight: 600; }

.bulkbar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--text); color: var(--bg);
}
.bulkbar .btn { background: var(--bg); color: var(--text); border: 0; }

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

.form-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.form-top h1 { margin: 0; margin-right: auto; }

.linked { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); margin: -4px 0 12px; font-size: 14px; }
.linked button { margin-left: auto; }

.suggest { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: -6px 0 12px; }
.suggest button { display: flex; width: 100%; text-align: left; gap: 8px; padding: 10px 12px; border: 0; border-top: 1px solid var(--line); background: var(--card); cursor: pointer; min-height: 48px; align-items: center; }
.suggest button:first-child { border-top: 0; }
.suggest .s-main { flex: 1; min-width: 0; }
.suggest .s-sub { font-size: 13px; color: var(--muted); }

.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line.on .line-name { font-weight: 700; }
.line-name { min-width: 0; }
.line-price { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.line-price input { width: 88px; min-height: 36px; padding: 4px 8px; }
.stepper { display: flex; align-items: center; gap: 4px; grid-row: span 2; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 22px; cursor: pointer; line-height: 1; }
.stepper input { width: 52px; text-align: center; min-height: 44px; padding: 4px; font-weight: 700; font-size: 18px; }
.line.on .stepper input { border-color: var(--accent); }

.inline-hint { display: flex; align-items: center; gap: 8px; margin: -6px 0 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

.summary {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 20px rgba(0,0,0,.12);
}
.summary .sum-text { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.summary .sum-total { font-size: 20px; font-weight: 800; color: var(--text); }

details.more-fields > summary { cursor: pointer; color: var(--accent-text); font-size: 14px; margin-bottom: 12px; min-height: 32px; }

/* ---------------------------------------------------------------- 圖表 */

.chart { position: relative; margin: 0; }
.chart-svg { width: 100%; height: 210px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .peak { fill: var(--text); font-size: 12px; font-weight: 700; }
.chart .bar { fill: var(--leaf); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .hit { fill: transparent; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 13px; white-space: nowrap; pointer-events: none; }

.rank { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.rank-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--leaf); border-radius: 5px; }
.rank-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-v small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.two-col { display: grid; gap: 14px; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } .two-col > .card { margin-bottom: 0; } .two-col { margin-bottom: 14px; } }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 600; font-size: 13px; }

.tier-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tier-chips .badge { font-size: 14px; padding: 8px 12px; }

/* ---------------------------------------------------------------- 登入與其他 */

.login { max-width: 360px; margin: 12vh auto; padding: 24px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; }
.login h1 { margin: 12px 0 4px; }
.login form { margin-top: 20px; text-align: left; }
.login .err { color: var(--danger); min-height: 1.5em; font-size: 14px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 76px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 15px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
#toast { display: flex; align-items: center; gap: 14px; }
#toast button { background: none; border: 0; color: #9ED36A; font-weight: 700; font-size: 15px; cursor: pointer; padding: 6px 4px; min-height: 36px; }

.contact-row .row-actions .btn { min-width: 44px; }
.settings-products .row { flex-wrap: wrap; }
.settings-products input { min-height: 40px; }
.p-name { flex: 2 1 160px; }
.p-price { flex: 1 1 80px; }
.p-cat { flex: 1 1 90px; }

/* ---------------------------------------------------------------- 共用的新元件 */

.btn-back { flex: 0 0 auto; }
.btn[disabled] { opacity: .45; cursor: default; }
.kpis.two { grid-template-columns: 1fr 1fr; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.backup-steps { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); }
.backup-steps ol { margin: 8px 0; padding-left: 22px; }
.backup-steps li { margin: 6px 0; }
.script-box { width: 100%; min-height: 160px; font: 12px/1.4 ui-monospace, Consolas, monospace; }
.stats-split { display: grid; gap: 14px; }

/* ---------------------------------------------------------------- 電腦版
   參考 Seller Central／Seller Hub：左側選單、頂欄搜尋、快照列、表格與右側抽屜。 */

:root[data-layout="desktop"] { --nav-h: 0px; }
:root[data-layout="desktop"] body { font-size: 15px; }

.d-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.d-side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px; background: var(--card); border-right: 1px solid var(--line);
}
.d-side .brand { padding: 4px 10px 18px; }
.d-nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-size: 15px; min-height: 44px; }
.d-nav svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.d-nav:hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.d-nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.d-side-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); }

.d-body { min-width: 0; display: flex; flex-direction: column; }
.d-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.d-top .sync { margin-left: 0; }
.d-search { position: relative; flex: 1; max-width: 560px; margin-right: auto; }
.d-search input { min-height: 40px; }
.gsearch-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .16); overflow: hidden; max-height: 70vh; overflow-y: auto;
}
.gsearch-results h4 { margin: 0; padding: 10px 14px 4px; font-size: 12px; color: var(--muted); }
.gsearch-results a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; color: var(--text); }
.gsearch-results a:hover { background: var(--accent-soft); }
.gsearch-results .empty { padding: 14px; color: var(--muted); }

main.d-main { max-width: 1480px; width: 100%; margin: 0; padding: 20px 28px 48px; }

.d-snapshot { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.d-snapshot .kpi .v { font-size: 20px; }
@media (max-width: 1360px) { .d-snapshot { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.d-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.d-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.d-grid > .card, .d-grid3 > .card { margin: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs.compact { border: 0; margin: 0; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  padding: 8px 12px; min-height: 40px; color: var(--muted); font-weight: 600;
}
.tab[aria-pressed="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs.compact .tab { border-radius: 8px; border-bottom: 0; min-height: 34px; padding: 4px 10px; font-size: 14px; }
.tabs.compact .tab[aria-pressed="true"] { background: var(--accent-soft); }
.tab .count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--bg); font-size: 12px; font-variant-numeric: tabular-nums; }

.sales-side { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.sales-side > div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.sales-side .k { font-size: 12px; color: var(--muted); }
.sales-side .v { font-size: 18px; font-weight: 700; }

.task { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; border-top: 1px solid var(--line); color: var(--text); min-height: 56px; }
.task:first-child { border-top: 0; }
.task small { display: block; font-size: 12px; color: var(--muted); }
.task .count { font-size: 24px; font-variant-numeric: tabular-nums; }
.task.warn .count { color: var(--yellow-ink); }
.task.bad .count { color: var(--danger); }
.task.zero { color: var(--muted); }
.task.zero .count { font-weight: 400; }
.task:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

.table-card { padding: 0; overflow: hidden; }
.card-head.pad { padding: 14px 16px 4px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid-table th:first-child, .grid-table td:first-child { padding-left: 16px; }
.grid-table tbody tr:last-child td { border-bottom: 0; }
.grid-table tr[data-open-order], .grid-table tr[data-open-customer] { cursor: pointer; }
.grid-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.grid-table tr.picked { background: var(--accent-soft); }
.grid-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid-table .nowrap { white-space: nowrap; }
.grid-table .clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-table .actions { text-align: right; white-space: nowrap; }
.grid-table .actions .btn + .btn { margin-left: 6px; }
.grid-table .empty { text-align: center; color: var(--muted); padding: 28px; }
.grid-table .pick-cell { width: 40px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.th-sort:hover { color: var(--text); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.pager .muted { margin-right: auto; }

:root[data-layout="desktop"] .bulkbar { bottom: 16px; }
:root[data-layout="desktop"] #toast { bottom: 24px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 10, .32); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(1000px, 94vw);
  display: flex; flex-direction: column; background: var(--bg); box-shadow: -12px 0 40px rgba(0, 0, 0, .22);
}
body.drawer-open { overflow: hidden; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.drawer-head h2 { margin: 0 auto 0 0; font-size: 19px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.form-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.drawer .summary { position: static; border-radius: 0; border-width: 1px 0 0; box-shadow: none; padding: 10px 20px; }

:root[data-layout="desktop"] .stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
:root[data-layout="desktop"] .stats > .card { margin: 0; }
:root[data-layout="desktop"] .stats > .wide { grid-column: 1 / -1; }
:root[data-layout="desktop"] .stats-split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; }
:root[data-layout="desktop"] .scroll-list { max-height: 520px; overflow-y: auto; }
:root[data-layout="desktop"] .customer-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
:root[data-layout="desktop"] .settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
:root[data-layout="desktop"] .settings-grid > .card { margin: 0; }
