/* Baobab Alutech — UI v3 shell (design tokens + app shell, docs/design/README.md
   "Design Tokens" + "Screens 0/1" + "Interactions" sections).
   Common layout + shared components. Page-specific rules stay in each
   template's own <style> block. */

:root {
  /* ---- colour tokens (README "Design Tokens" > Colours) ---- */
  --brand: #1e4a41;        /* primary green — buttons, selected nav, rules */
  --brand-deep: #122e29;   /* pressed / link hover */
  --brass: #9d7b3c;        /* single accent: print kicker, login rule, in-progress dots, bars */
  --brass-tint: #f7f1e4;
  --ink: #1b2926;          /* body text */
  --muted: #6f7a77;        /* secondary text */
  --faint: #98a29f;        /* tertiary / labels */
  --hair: #e7eae9;         /* hairlines, control borders */
  --bg: #f4f5f5;           /* app background */
  --surface: #ffffff;      /* cards */
  --amber: #8a5a10;        /* on --amber-tint: due / warning */
  --amber-tint: #fbf3e6;
  --amber-ink: #5f4110;    /* on --amber-tint: notice-banner body copy */
  --blue: #1f5470;         /* on --blue-tint: ratios */
  --blue-tint: #eaf0f4;
  --green-tint: #e9f0ee;   /* settled / received */
  --rose: #8c2f3f;         /* on --rose-tint: locked / discount / declined */
  --rose-tint: #f9e9eb;
  --lane: #ebedec;         /* kanban lanes */

  /* ---- sidebar material (light, per Screen 1) ---- */
  --sidebar-w: 238px;
  --side-bg: #ebedec;
  --side-ink: #1b2926;
  --side-faint: #98a29f;
  --side-hair: #dfe2e1;
  --side-item: #39443f;
  --side-active: var(--brand);
  --side-active-ink: #ffffff;

  /* ---- shadows ---- */
  --shadow-card: 0 1px 2px rgba(20, 40, 36, .05), 0 6px 18px rgba(20, 40, 36, .035);
  --shadow-btn: 0 1px 1.5px rgba(20, 40, 36, .05);
  --shadow-dialog: 0 12px 32px rgba(45, 43, 43, .22);
  --shadow-kanban: 0 1px 2px rgba(20, 40, 36, .07); /* Screen 5/6 kanban cards */

  /* ---- radii (README "Design Tokens" > Radii) ---- */
  --radius-tag: 6px;       /* tags */
  --radius-nav: 8px;       /* nav items */
  --radius-control: 9px;   /* buttons / inputs / segmented */
  --radius-kanban: 11px;   /* kanban cards */
  --radius-card: 14px;     /* cards / lanes */
  --radius-sidebar: 16px;  /* sidebar & dialog */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

/* ---------- shell layout ---------- */

.shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

/* Mobile-only top bar (hamburger + brand + compact language switch) and the
   drawer backdrop. Hidden unconditionally here so desktop (>768px) never
   sees them; the @media block near the bottom of this file is what actually
   turns them on for narrow screens. */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

/* Sticky 238px sidebar. Outer <aside> only carries the sticky/flex-basis
   geometry + the gap to the viewport edge; the inner .sidebar-inner is the
   actual light card (docs/design/README.md Screen 1: "sticky left sidebar
   238px"). */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  padding: 14px 0 14px 14px;
}

.sidebar-inner {
  height: 100%;
  background: var(--side-bg);
  border-radius: var(--radius-sidebar);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  color: var(--side-ink);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px 18px;
  flex: none;
}

.sidebar-logo img {
  width: 132px;
  max-width: 100%;
  height: auto;
  display: block;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 10px;
  overflow-y: auto;
  flex: 1;
}

/* 分组标题（2026-08-15 起是个按钮：点了折叠这一组）。
   保留原来的字号/字重/颜色/内边距，视觉跟以前一模一样——多出来的只有右边那个
   小三角。button 的浏览器默认样式（边框/背景/字体/居中）要全部清掉，否则侧边栏
   里会冒出一排灰色方块。 */
.nav-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--side-faint);
  padding: 14px 12px 5px;
  text-align: left;
  cursor: pointer;
}

.nav-group:hover { color: var(--side-item); }

.nav-caret {
  font-size: 10px;
  line-height: 1;
  transition: transform .15s ease;
}

.nav-section.collapsed .nav-caret { transform: rotate(-90deg); }

.nav-section-items { display: flex; flex-direction: column; gap: 1px; }

.nav-section.collapsed .nav-section-items { display: none; }

.nav-item {
  display: block;
  padding: 7px 11px;
  border-radius: var(--radius-nav);
  color: var(--side-item);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}

.nav-item:hover {
  background: rgba(27, 41, 38, .06);
}

.nav-item.active {
  background: var(--side-active);
  color: var(--side-active-ink);
  font-weight: 590;
}

.sidebar-bottom {
  flex: none;
  border-top: 1px solid var(--side-hair);
  padding-top: 14px;
  margin-top: 14px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.user-meta { min-width: 0; }

.user-name {
  font-size: 13px;
  font-weight: 590;
  color: var(--side-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--side-faint);
  margin-top: 1px;
}

/* 自助改密入口（2026-08-08）：本人名字下方的小链接，弱化呈现不抢导航 */
.user-pw-link {
  display: inline-block;
  font-size: 11px;
  color: var(--side-faint);
  text-decoration: underline;
  margin-top: 3px;
}
.user-pw-link:hover { color: #fff; }

/* 2026-08-15 起这里有两条（改密码 + 使用说明）。inline-block 会让它们在窄侧边栏
   里挤成一行再断行，中间还没有间隔；改成各占一行，读起来是两个选项而不是一段
   下划线文字。 */
.user-pw-link { display: block; }
.user-pw-link + .user-pw-link { margin-top: 2px; }

/* 版本戳（2026-08-15 用户："怎么检查我系统里的版本"）。压得很小很淡：
   每天用系统的人不需要看见它，需要的时候它得在那儿。commit 短号跟在日期
   后面，颜色再淡一档——日期是给人看的，短号是拿来跟 GitHub 对的。 */
/* 2026-08-15 起是个链接（点进更新日志）。display:block 让整行都可点，
   不是只有那几个字——10.5px 的字本来就难点中。 */
.sidebar-build {
  display: block;
  margin: 10px 0 0;
  font-size: 10.5px;
  color: var(--side-faint);
  letter-spacing: .01em;
  text-decoration: none;
}

a.sidebar-build:hover { color: var(--side-item); }

.sidebar-build-sha { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

.logout-form { margin: 11px 0 0; }

.logout-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--side-faint);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.logout-btn:hover { color: var(--side-ink); }

.content {
  flex: 1;
  min-width: 0;
  padding: 16px 26px 64px 22px;
}

/* ---------- top utility bar (breadcrumb + search + lang toggle) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  margin-bottom: 14px;
}

.topbar .breadcrumb {
  font-size: 12px;
  color: var(--faint);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* v2 CHANGES#5: 搜索框可收缩、语言按钮不收缩不折行，防止挤压把工具条撑高。 */
.topbar-search { flex: 0 1 220px; min-width: 120px; }
.lang-switch-form { flex: none; }

.topbar-search input {
  width: 100%;
  box-sizing: border-box;
  min-height: 32px;
  font-size: 13px;
  padding: 0 10px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-control);
  background: #fff;
}

.topbar-search input:focus-visible,
.lang-toggle-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 74, 65, .14);
}

.lang-toggle-btn {
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-control);
  padding: 6px 13px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 590;
  color: var(--brand);
  box-shadow: var(--shadow-btn);
  white-space: nowrap;
}

.lang-switch-form { margin: 0; }

/* ---------- page head: H1 + subtitle, action block directly below ---------- */

.page-head { margin-bottom: 0; }

.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.026em;
  margin: 0 0 4px;
  color: var(--ink);
}

.page-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.page-actions-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin: 14px 0 20px;
}

/* Structural only — lets a template still define {% block page_actions %}
   without adding an extra flex/box layer inside .page-actions-bar. */
.page-actions { display: contents; }

/* Legacy fallback for any page-header link that hasn't been converted to the
   .btn system below — kept scoped with :not(.btn) so it never fights the
   button component's own color/decoration rules. */
.page-actions-bar a:not(.btn) {
  color: var(--brand);
  text-decoration: none;
}

.page-actions-bar a:not(.btn):hover { text-decoration: underline; }

/* ---------- page action buttons (page_actions_bar / toolbar) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 590;
  letter-spacing: -0.01em;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  box-shadow: var(--shadow-btn);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }

.btn-secondary {
  background: #fff;
  border-color: var(--hair);
  color: var(--ink);
}

.btn-secondary:hover {
  border-color: #c3cac6;
  background: #f7f8f8;
}

.btn-back {
  background: none;
  border-color: transparent;
  color: var(--muted);
  padding: 8px 6px;
  box-shadow: none;
}

.btn-back:hover { color: var(--ink); }

/* Compact variant for buttons that sit in tight spaces (kanban cards, table
   rows) — same .btn/.btn-secondary look, smaller footprint. */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.content-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}

/* ---------- shared components reused across list/detail pages ---------- */

table { border-collapse: collapse; width: 100%; }

th, td {
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
}

th { background: #eef1f0; color: var(--muted); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

a.no, a.name {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.pill, .tag, .badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--radius-tag);
  background: #eef3f1;
  color: var(--brand);
  display: inline-block;
}

.pill.warn { background: #fff3cd; color: #6b5300; }
.pill.ok { background: #e6f4ea; color: #1e7a3d; }

.empty { color: var(--faint); padding: 24px; text-align: center; }

.msgs { margin-bottom: 14px; }

.msg { padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }

.msg.warning { background: #fff4e5; color: #8a5300; }

form.inline { display: inline; }

button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

/* .card 是 v2 遗留容器，.panel 是 UI v3 的正式容器——两套并存导致同类小标题
   一个 14px 品牌绿、一个 17px 墨色，间距也不同（2026-08-04 用户："每个小标题
   的大小不一样大，间距，这样看着很不舒服"）。这里让 .card 视觉完全对齐
   .panel，模板不必逐个改类名。 */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 16px; color: var(--ink); }

.filters { margin-bottom: 14px; }

.filters a {
  display: inline-block;
  font-size: 12px;
  padding: 5px 12px;
  margin-right: 8px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--brand);
  background: #eef3f1;
  border: 1px solid transparent;
}

.filters a.on { background: var(--brand); color: #fff; }

/* Opt-in helper for pages with very wide tables (e.g. the quotation entry
   grid). Lets just that page's own content scroll horizontally instead of
   widening the whole shell — doesn't affect pages that don't use it. */
.scroll-x { overflow-x: auto; }

/* Generic wrapper for list-page tables that aren't already inside .scroll-x.
   No rule outside the mobile media query below — a bare div has no visual
   effect on its own, so wrapping a table in it is a zero-risk no-op at
   desktop widths (M1: mobile responsive + PWA manifest). */
/* 2026-08-15：这条规则一直是**空的**——类名叫 table-scroll、全站十几个表格都
   套着它，实际却什么都没做，宽表一律把整页顶出横向滚动条。CRM 加第 9 列
   （「上线前成交」）时撞上来，顺手补上它名字承诺的行为。

   宽内容在自己的容器里滚、不推着页面滚：表头/合计这些页面框架留在原位，只有
   表格本身横向移动，比整页平移好读得多。表格放得下时这两行完全不起作用，
   既有页面的观感不变。 */
.table-scroll { max-width: 100%; overflow-x: auto; }

/* ==========================================================================
   UI v3 phase 2 — Workbench (Screen 1) + Quotation register (Screen 2)
   docs/design/README.md. Both pages opt out of the generic white
   `.content-card` shell wrapper (they lay out several independent white
   cards directly on the grey `--bg`, per the design) via `body.page-flat`;
   every other page keeps the untouched default `.content-card` look.
   ========================================================================== */

body.page-flat .content-card {
  background: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

/* ---------- generic inputs (search box, etc.) ---------- */

.input {
  border: 1px solid var(--hair);
  border-radius: var(--radius-control);
  background: #fff;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  color: var(--ink);
}

.input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 74, 65, .14);
}

/* ---------- ghost / block button variants ---------- */

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--brand);
  box-shadow: none;
  padding: 6px 8px;
}

.btn-ghost:hover { color: var(--brand-deep); text-decoration: underline; }

.btn-ghost:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 74, 65, .14);
}

.btn-block { width: 100%; justify-content: flex-start; }

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--hair);
}

/* ---------- segmented control (stage filter) ---------- */

.seg {
  display: inline-flex;
  border: 1px solid var(--hair);
  border-radius: var(--radius-control);
  background: #eceeed;
  padding: 2px;
  gap: 2px;
  /* 2026-08-15：用户管理的角色标签有 11 段（9 个角色 + 全部），实测 912px，
     窄屏上把整页顶出横向滚动条。段本身不换行（.seg-opt 是 nowrap，换行会让
     这个控件看起来散架），所以让**它自己**横向滚，别推着页面滚——
     "宽内容在自己的容器里滚"是全站既有的做法（.table-scroll 同理）。
     内容放得下时这两行完全不起作用，台账/CRM 那几处的观感不变。 */
  max-width: 100%;
  overflow-x: auto;
}

.seg-opt {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 11px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.seg-opt:hover { color: var(--ink); }

.seg-opt:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 74, 65, .14);
}

.seg-opt.active {
  background: #fff;
  color: var(--ink);
  font-weight: 590;
  box-shadow: 0 1px 2px rgba(20, 40, 36, .10);
}

/* 历史档案两个页签互链（订单/报价，历史数据导入 Track 1+2）——同一份 .seg
   控件，放在 page_subtitle 区块顶部，跟下面的副标题文字留点呼吸空间。 */
.archive-tabs { margin-bottom: 8px; }

/* ---------- stage tags (Quotation.Status, shared by dashboard + register) ----------
   Colour-only modifiers layered on the existing shared `.pill, .tag, .badge`
   base rule above (geometry untouched — other pages' plain `.tag`/`.pill`
   usages must not shift). */

.tag-draft { background: #eceeed; color: var(--muted); }
.tag-pending { background: var(--amber-tint); color: var(--amber); }
.tag-won { background: var(--green-tint); color: var(--brand); }
.tag-shelved { background: var(--blue-tint); color: var(--blue); }
.tag-lost { background: var(--rose-tint); color: var(--rose); }

/* ---------- star toggle (quotation register; _star_toggle.html) ----------
   星标按钮（2026-10-07）：只有业务员的台账有这一列。加星后页面回到 #quote-<pk> 这一行；
   手机上顶栏固定、高 52px，行的 scroll-margin-top 使这一行不被顶栏遮住。 */

.star-col { width: 40px; text-align: center; }
tr[id^="quote-"] { scroll-margin-top: 64px; }
.star-form { display: inline; margin: 0; }

.star-btn {
  background: none;
  border: none;
  border-radius: var(--radius-control);
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  padding: 4px 6px;
}

.star-btn.on { color: var(--brass); }
.star-btn:hover { color: var(--brass); }

.star-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 74, 65, .14);
}

/* ---------- shared white panel (KPI tiles, follow-up table, stage mix, jump-to) ---------- */

.panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
}

.panel-table { padding: 8px 24px 16px; }

.panel-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title { margin: 0; font-size: 17px; }

.panel-sub { font-size: 12px; color: var(--faint); }

.panel-link { margin-left: auto; font-size: 13px; }

/* ---------- KPI tiles ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(216px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-tile {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 17px;
}

.kpi-head { display: flex; align-items: center; gap: 8px; }

.kpi-mark {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
}

.kpi-mark-brand { background: var(--brand); }
.kpi-mark-blue { background: var(--blue); }
.kpi-mark-faint { background: var(--faint); }
.kpi-mark-brass { background: var(--brass); }

.kpi-label { font-size: 13px; color: var(--muted); }

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 12px 0 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-note { font-size: 12px; color: var(--muted); }

/* 一个磁贴并列几个数字（「成交率」按张数和按金额）。数字沿用 .kpi-value 的字号，不另设，几个数字字号相同；
   各数字下方一行说明用副注的字号。 */
.kpi-parts { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.kpi-part { display: flex; flex-direction: column; }
.kpi-part-label { font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); }

/* ---------- prominent notice banner (archive stats "reference only" caveat) ---------- */

.notice-amber {
  background: var(--amber-tint);
  color: var(--amber-ink);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.75;
  margin-bottom: 16px;
}

.notice-amber strong { color: var(--amber); }

/* ---------- two-column dashboard body ---------- */

.dash-grid {
  display: grid;
  /* v2 CHANGES#4: auto-fit 自适应——窄屏自动落成单栏，右栏卡片不会被压穿。 */
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 16px;
  align-items: start;
}

.dash-grid > * { min-width: 0; }

/* 总管理、业务主管、看数据（2026-10-07）：按跟进人汇总的表有八列，占满整行；阶段分布和快捷入口移到表的下方，
   宽度够时并排。开单主管的最近 30 张报价单同样占满整行，按开单人的张数和状态分布与阶段分布、快捷入口并排
   （views.home 的 dash_wide）。表头和数字不换行，窄屏时表格在 .table-scroll 中横向滚动。合计一行在 tfoot，
   加粗并加上分隔线。 */
.dash-grid.dash-grid-wide { grid-template-columns: minmax(0, 1fr); }
.dash-grid-wide .dash-col-side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.summary-table th, .summary-table td { white-space: nowrap; }
.summary-table tfoot td { font-weight: 600; border-top: 1px solid var(--hair); }

.dash-col-side {
  display: grid;
  gap: 16px;
}

/* Pending follow-up row tint, day 1–30 (views._quote_row row_tint). */
tr.row-followup { background: #fdfaf3; }

.ageing-near { color: var(--brass); }
.ageing-over { color: var(--muted); }

/* 业务员工作台「我的跟进」（2026-10-07）：各行的「流失」「继续跟进」按钮不换行；列表下方是第 8–30 天
   的张数，链接到报价台账。 */
.row-actions { text-align: right; white-space: nowrap; }
.panel-foot { margin: 12px 0 0; font-size: 13px; }

/* ---------- stage mix bars ---------- */

.stage-mix-row + .stage-mix-row { margin-top: 13px; }

.stage-mix-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.stage-mix-count { color: var(--faint); }

.stage-mix-track {
  height: 5px;
  border-radius: 3px;
  background: #eff1f0;
}

.stage-mix-fill {
  height: 5px;
  border-radius: 3px;
  background: var(--brand);
}

/* ---------- jump-to button stack ---------- */

.jump-stack { display: grid; gap: 8px; }

@media (max-width: 768px) {
  .dash-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Mobile (<=768px) overrides — M1: 手机响应式适配 + PWA manifest, extended
   for UI v3's light sidebar.
   Everything that can change how the shell *looks* on a real desktop screen
   must live inside this one @media block. Nothing above this line (other
   than the .mobile-topbar/.sidebar-backdrop hidden-by-default rules, which
   only ever show up once this query matches) may differ for >768px viewports
   — that is the zero-regression contract for this change.
   ========================================================================== */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 12px;
    background: var(--brand);
    color: #fff;
    z-index: 30;
  }

  .nav-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    padding: 6px 8px;
    min-height: 40px;
    min-width: 40px;
    cursor: pointer;
  }

  .mobile-brand {
    font-size: 14px;
    font-weight: 700;
    flex: 1;
    text-align: center;
  }

  .mobile-lang-form {
    display: flex;
    gap: 4px;
  }

  .mobile-lang-form button {
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 11px;
    padding: 6px 8px;
    min-height: 32px;
    border-radius: 6px;
  }

  .mobile-lang-form button.on {
    background: #fff;
    color: var(--brand);
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 40;
  }

  /* Sidebar becomes an off-canvas drawer: hidden by default, slides in when
     JS toggles .open (see base.html's inline script). The gap-padding that
     makes it a floating card on desktop is dropped so the drawer is a
     full-bleed panel instead. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 78vw;
    max-width: 300px;
    padding: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 45;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-inner {
    border-radius: 0;
  }

  .shell {
    display: block;
  }

  .content {
    padding: 68px 12px 16px;
    width: 100%;
  }

  .content-card {
    padding: 16px 14px;
  }

  /* The desktop topbar's own language switch/search are replaced by the
     compact one in .mobile-topbar — hide the desktop topbar-actions here to
     avoid showing duplicate controls. */
  .topbar-actions {
    display: none;
  }

  .topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Button group in the page header must wrap onto its own line(s) instead
     of squeezing/overflowing next to the title on narrow screens. */
  .page-actions-bar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* Any list-page table wrapped in .table-scroll (or already using
     .scroll-x) scrolls on its own instead of blowing out the page width. */
  .table-scroll {
    overflow-x: auto;
  }

  /* Touch-friendly tap targets. */
  button {
    min-height: 40px;
  }
}

/* ---------- pagination (2026-08-03 真分页取代 200 条上限) ---------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 4px;
}

.page-btn {
  display: inline-block;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 590;
  color: var(--brand);
  background: #fff;
  border: 1px solid var(--hair);
  border-radius: var(--radius-control);
  text-decoration: none;
  box-shadow: var(--shadow-btn);
  white-space: nowrap;
}

.page-btn:hover { border-color: var(--brand); }

.page-btn.is-disabled {
  color: var(--faint);
  pointer-events: none;
  box-shadow: none;
}

.page-info {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.page-jump-input {
  width: 84px;
  padding: 5px 8px;
  text-align: center;
}

/* 确认弹窗（原 _workorder_confirm.html 内联样式，2026-08-04 收款确认也改弹窗后
   两个组件共用，挪进公共表——用户铁律：所有二次确认都是居中弹窗）。 */
.complete-dialog { width: min(400px, 100%); border: none; border-radius: 16px;
                    padding: 24px 26px; background: var(--surface); box-shadow: var(--shadow-dialog); }
.complete-dialog::backdrop { background: rgba(27, 41, 38, .45); }
.complete-dialog-title { font-size: 20px; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
.complete-dialog-desc { font-size: 13px; color: var(--muted); line-height: 1.75; margin: 0 0 16px; }
.complete-dialog-recap { background: var(--bg); border-radius: 10px; padding: 13px 15px;
                          font-size: 12px; display: grid; grid-template-columns: auto 1fr;
                          row-gap: 6px; column-gap: 14px; margin-bottom: 20px; }
.complete-dialog-recap .k { color: var(--muted); }
.complete-dialog-recap .v { color: var(--ink); font-weight: 590; }
.complete-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 收款确认表单（原 finance_receipts.html 与 order_detail.html 各写一份内联
   样式，两处规则完全相同，顺手清理批次挪进公共表；order_detail 那份多带
   margin-top，留在该模板自己的 <style> 里按更具体上下文补，视觉不变）。 */
.receipt-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 数据页筛选栏（_data_filters.html，2026-08-15 用户："数据板块，要能筛选"）。
   原先叫 .mix-range，只有起止两个日期框，三张报表各自内联抄了一份；长出
   「业务员」「客户类型」两个下拉之后组件化成一份模板，样式跟着挪进公共表——
   第四张页面（CRM）当初就是因为样式没跟过来才没有筛选栏。
   flex-wrap 是必需的：最宽的时候一行有两个日期框 + 两个下拉 + 两个按钮，
   窗口一窄不换行就会把「Apply」顶出可视区。 */
.data-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.data-filters .input { max-width: 170px; }
.data-filters-dash { color: var(--muted); }
/* flex-basis:100% 让它在 .page-actions-bar（flex + wrap）里独占一行，
   不跟筛选控件挤在一起。 */
.data-filters-note { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* 表单字段下面的小字说明。原先只在 user_form.html 里内联写了一份；2026-08-15
   价格库的「中文名」也要用，两处同一条规则就该进公共表——留两份必然哪天只改
   其中一份。 */
.field-hint { font-size: 11px; color: var(--faint); margin: 4px 0 0; }
