    /* ===================================================================
       Design tokens
       =================================================================== */
    :root {
      /* 中性灰為主，靛藍只用在「選取／焦點」，主要按鈕用近黑 —— 避免整頁都是藍色 */
      --bg:            #f7f7f8;
      --surface:       #ffffff;
      --surface-alt:   #fafafa;
      --border:        #e7e7ea;
      --border-strong: #d3d3d9;

      --text:          #17171a;
      --text-2:        #56565f;
      --text-3:        #8a8a93;

      --ink:           #1c1c20;   /* 主要按鈕 */
      --ink-hover:     #35353c;

      --accent:        #4a54c9;
      --accent-dark:   #3a43a8;
      --accent-soft:   #eef0fb;
      --accent-text:   #3a43a8;

      --ok:            #1c7a52;
      --ok-soft:       #ebf5f0;
      --warn:          #8a5a12;
      --warn-soft:     #fbf3e6;
      --warn-border:   #ecdcbe;
      --danger:        #b02a24;

      --radius:        6px;
      --radius-sm:     4px;
      --shadow:        none;
      --shadow-lg:     0 10px 30px rgba(20, 20, 25, .16);

      --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
              "Microsoft JhengHei", "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
    }

    /* ===================================================================
       Base
       =================================================================== */
    *, *::before, *::after { box-sizing: border-box; }

    html { -webkit-text-size-adjust: 100%; }

    body {
      margin: 0;
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      font-size: 15px;
      line-height: 1.55;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    h1, h2, h3, p { margin: 0; }

    button {
      font-family: inherit;
      cursor: pointer;
      border: none;
      background: none;
      color: inherit;
    }

    .num { font-variant-numeric: tabular-nums; }

    .shell {
      max-width: 1320px;
      margin: 0 auto;
      padding: 0 32px;
    }

    /* ===================================================================
       Header
       =================================================================== */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 30;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
    }

    .topbar-inner {
      height: 62px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 24px;
    }

    .brand { display: flex; align-items: center; gap: 10px; }

    .brand-mark {
      width: 32px;
      height: 32px;
      flex-shrink: 0;
      border-radius: var(--radius-sm);
      background: var(--ink);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .brand-mark svg { width: 18px; height: 18px; color: #fff; }

    .brand-name {
      font-size: 16.5px;
      font-weight: 600;
      letter-spacing: 0;
      line-height: 1.3;
    }
    .brand-sub {
      font-size: 12.5px;
      color: var(--text-3);
      line-height: 1.35;
    }

    .topbar-right { display: flex; align-items: center; gap: 6px; }

    .poll-label {
      font-size: 14px;
      color: var(--text-2);
      white-space: nowrap;
    }

    .bell-wrap { position: relative; }

    .bell {
      width: 44px;
      height: 44px;
      border-radius: var(--radius-sm);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-2);
      transition: background .15s ease, color .15s ease;
    }
    .bell:hover { background: #f1f3f7; color: var(--text); }
    .bell svg { width: 22px; height: 22px; }

    .badge {
      position: absolute;
      top: 2px;
      right: 2px;
      min-width: 20px;
      height: 20px;
      padding: 0 5px;
      border-radius: 10px;
      background: var(--danger);
      color: #fff;
      font-size: 12px;
      font-weight: 700;
      display: none;
      align-items: center;
      justify-content: center;
      border: 2px solid var(--surface);
    }
    .badge.show { display: flex; }

    /* ===================================================================
       Notification panel
       =================================================================== */
    .notif-panel {
      position: fixed;
      top: 84px;
      right: 32px;
      width: 420px;
      max-width: calc(100vw - 32px);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow-lg);
      z-index: 40;
      overflow: hidden;
      display: none;
    }
    .notif-panel.show { display: block; }

    .notif-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
    }
    .notif-title { font-size: 16px; font-weight: 650; }

    .link-btn {
      font-size: 14px;
      font-weight: 600;
      color: var(--accent-text);
      padding: 4px 2px;
    }
    .link-btn:hover { text-decoration: underline; }

    .notif-list { max-height: 380px; overflow-y: auto; }

    .notif-item { padding: 16px 20px; border-bottom: 1px solid var(--border); }
    .notif-item:last-child { border-bottom: none; }
    .notif-msg { font-size: 15px; color: var(--text); line-height: 1.65; }
    .notif-time { font-size: 13px; color: var(--text-3); margin-top: 6px; }

    /* ===================================================================
       Layout
       =================================================================== */
    main { padding: 32px 0 56px; }

    .stack > * + * { margin-top: 24px; }

    .grid-3 {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 24px;
    }

    .grid-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
      align-items: stretch;   /* 兩張卡片等高，避免左右不齊 */
    }
    .grid-2 > .card { display: flex; flex-direction: column; }
    .grid-2 .table-scroll { flex: 1; min-height: 280px; }

    /* ===================================================================
       Cards
       =================================================================== */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }

    .card-head {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
    }

    .card-title { font-size: 18px; font-weight: 650; letter-spacing: .01em; }
    .card-desc  { font-size: 14px; color: var(--text-3); margin-top: 4px; }

    .live {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 14px;
      color: var(--text-3);
      white-space: nowrap;
      padding-top: 3px;
    }
    .live-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #34a853;
      animation: pulse 2s ease-in-out infinite;
    }
    @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

    /* ── Stat card ── */
    .stat { padding: 24px; }
    .stat-label {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-2);
      letter-spacing: .02em;
    }
    .stat-row {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 16px;
      margin-top: 10px;
    }
    .stat-value {
      font-size: 44px;
      font-weight: 700;
      line-height: 1;
      letter-spacing: -.02em;
    }
    .stat-unit { font-size: 15px; color: var(--text-3); padding-bottom: 5px; }

    /* ===================================================================
       Demo console
       =================================================================== */
    .console {
      background: var(--surface);
      border: 1px solid var(--border);
      border-left: 4px solid var(--accent);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 24px 28px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 28px;
      flex-wrap: wrap;
    }
    .console-title { font-size: 17px; font-weight: 650; }
    .console-text {
      font-size: 15px;
      color: var(--text-2);
      margin-top: 6px;
      max-width: 720px;
      line-height: 1.7;
    }
    .console-text strong { color: var(--text); font-weight: 650; }

    .actions { display: flex; gap: 12px; flex-shrink: 0; }

    .btn {
      display: inline-flex;
      align-items: center;
      gap: 9px;
      height: 38px;
      padding: 0 16px;
      border-radius: var(--radius-sm);
      font-size: 14.5px;
      font-weight: 500;
      letter-spacing: 0;
      white-space: nowrap;
      transition: background .15s ease, border-color .15s ease;
    }
    .btn svg { width: 17px; height: 17px; }

    .btn-sm {
      height: 33px;
      padding: 0 13px;
      font-size: 13.5px;
      text-decoration: none;
      color: var(--text);
    }

    .btn-primary { background: var(--ink); color: #fff; }
    .btn-primary:hover { background: var(--ink-hover); }

    .btn-secondary {
      background: var(--surface);
      color: var(--text);
      border: 1px solid var(--border-strong);
    }
    .btn-secondary:hover { background: var(--surface-alt); border-color: #bcc5d2; }

    /* ===================================================================
       Ingest（訂單接收設定）
       =================================================================== */
    .ingest-body { padding: 24px; }

    .channel {
      display: flex;
      align-items: flex-start;
      gap: 14px;
      padding: 18px 0;
      border-bottom: 1px solid var(--border);
    }
    .channel:first-child { padding-top: 0; }
    .channel:last-child  { border-bottom: none; padding-bottom: 0; }

    .pill {
      flex-shrink: 0;
      margin-top: 2px;
      padding: 5px 12px;
      border-radius: 999px;
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
    }
    .pill-on  { background: var(--ok-soft);   color: var(--ok); }
    .pill-off { background: #f0f2f5;          color: var(--text-3); }

    .channel-name { font-size: 16px; font-weight: 650; }
    .channel-desc { font-size: 15px; color: var(--text-2); margin-top: 4px; line-height: 1.65; }

    code.inline {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 14px;
      background: #f2f4f7;
      border: 1px solid var(--border);
      border-radius: 4px;
      padding: 2px 7px;
      word-break: break-all;
    }

    .paste-area {
      width: 100%;
      min-height: 150px;
      margin-top: 12px;
      padding: 14px 16px;
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-sm);
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 14px;
      line-height: 1.7;
      color: var(--text);
      background: var(--surface-alt);
      resize: vertical;
    }
    .paste-area:focus {
      outline: none;
      border-color: var(--accent);
      background: var(--surface);
    }

    .paste-row {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-top: 12px;
      flex-wrap: wrap;
    }
    .paste-hint { font-size: 14px; color: var(--text-3); }

    /* ===================================================================
       Tables
       =================================================================== */
    .table-scroll { overflow: auto; max-height: 420px; }

    table { width: 100%; border-collapse: collapse; }
    /* 左右並排的卡片較窄，欄位擠不下時橫向捲動，不要硬折行 */
    .grid-2 table { min-width: 580px; }

    thead th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: var(--surface-alt);
      border-bottom: 1px solid var(--border);
      padding: 12px 24px;
      font-size: 14px;
      font-weight: 650;
      color: var(--text-2);
      text-align: left;
      white-space: nowrap;
      letter-spacing: .02em;
    }

    tbody td {
      padding: 18px 24px;
      border-bottom: 1px solid var(--border);
      font-size: 16px;
      color: var(--text);
      vertical-align: middle;
    }
    tbody tr:last-child td { border-bottom: none; }
    tbody tr:hover td { background: #fbfcfd; }

    td.sub { color: var(--text-2); font-size: 15px; }
    .cell-strong { font-weight: 650; }
    .cell-note { font-size: 14px; color: var(--text-3); margin-top: 3px; }
    .align-right { text-align: right; }
    .nowrap { white-space: nowrap; }

    .empty {
      padding: 64px 24px;
      text-align: center;
      font-size: 16px;
      color: var(--text-3);
    }

    /* ── Chips ── */
    .chip {
      display: inline-block;
      padding: 5px 12px;
      border-radius: 999px;
      font-size: 14px;
      font-weight: 600;
      white-space: nowrap;
      line-height: 1.4;
    }
    .chip-accent { background: var(--accent-soft); color: var(--accent-text); }
    .chip-date {
      background: var(--warn-soft);
      color: var(--warn);
      border: 1px solid var(--warn-border);
      border-radius: var(--radius-sm);
    }

    .mark-btn {
      font-size: 15px;
      font-weight: 600;
      color: var(--text-2);
      padding: 8px 14px;
      border: 1px solid var(--border-strong);
      border-radius: var(--radius-sm);
      white-space: nowrap;
      transition: all .15s ease;
    }
    .mark-btn:hover { color: var(--ok); border-color: #a8d5bf; background: var(--ok-soft); }

    /* ── Poll log ── */
    .log-dot {
      display: inline-block;
      width: 9px;
      height: 9px;
      border-radius: 50%;
      background: #c6ccd6;
    }
    .log-dot.hit { background: #34a853; }
    .log-hit { color: var(--ok); font-weight: 650; }
    .log-idle { color: var(--text-3); }

    /* ===================================================================
       Toast
       =================================================================== */
    .toast-wrap {
      position: fixed;
      top: 92px;
      right: 32px;
      z-index: 60;
      display: flex;
      flex-direction: column;
      gap: 12px;
      pointer-events: none;
    }

    .toast {
      pointer-events: auto;
      max-width: 400px;
      padding: 16px 20px;
      border-radius: var(--radius-sm);
      background: #16202f;
      color: #fff;
      font-size: 15px;
      line-height: 1.6;
      box-shadow: var(--shadow-lg);
      border-left: 4px solid #6ba0ff;
      animation: slide-in .28s cubic-bezier(.22, .8, .3, 1);
    }
    .toast.success { border-left-color: #45c98a; }
    .toast.error   { border-left-color: #ef6d68; }
    .toast.info    { border-left-color: #6ba0ff; }

    @keyframes slide-in {
      from { transform: translateX(115%); opacity: 0; }
      to   { transform: translateX(0);    opacity: 1; }
    }

    .fade-in { animation: fade-in .35s ease both; }
    @keyframes fade-in {
      from { opacity: 0; transform: translateY(4px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    /* ===================================================================
       Footer
       =================================================================== */
    .footer {
      border-top: 1px solid var(--border);
      margin-top: 40px;
      padding: 24px 0 40px;
      font-size: 14px;
      color: var(--text-3);
      display: flex;
      justify-content: space-between;
      gap: 16px;
      flex-wrap: wrap;
    }

    /* ===================================================================
       Scrollbar
       =================================================================== */
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: #d5dae2; border-radius: 6px; border: 3px solid var(--surface); }
    ::-webkit-scrollbar-thumb:hover { background: #bcc4cf; }

    /* ===================================================================
       Responsive
       =================================================================== */
    @media (max-width: 1100px) {
      .grid-2 { grid-template-columns: 1fr; }
    }

    @media (max-width: 820px) {
      .shell { padding: 0 20px; }
      .grid-3 { grid-template-columns: 1fr; }
      .console { flex-direction: column; align-items: stretch; gap: 20px; }
      .actions { width: 100%; }
      .actions .btn { flex: 1; justify-content: center; }
      .poll-label { display: none; }
      .stat-value { font-size: 38px; }
      .notif-panel { right: 20px; }
      .toast-wrap { right: 20px; left: 20px; }
      .toast { max-width: none; }
      thead th, tbody td { padding-left: 20px; padding-right: 20px; }
    }

    /* ── 頁首的主導覽（桌機）──────────────────────────────────────
       文字 + 底線，不用外框。工具列的操作按鈕才有外框，
       這樣「換頁」與「換檢視」一眼就分得開，也看得出現在在哪一頁。 */
    .mainnav {
      display: flex;
      align-items: stretch;
      align-self: stretch;
      gap: 2px;
      margin-left: 26px;
      margin-right: auto;
    }
    .mainnav a {
      position: relative;
      display: flex;
      align-items: center;
      padding: 0 14px;
      font-size: 14.5px;
      color: var(--text-2);
      text-decoration: none;
      white-space: nowrap;
    }
    .mainnav a:hover { color: var(--text); }
    .mainnav a.is-active { color: var(--text); font-weight: 600; }
    .mainnav a.is-active::after {
      content: '';
      position: absolute;
      left: 12px;
      right: 12px;
      bottom: -1px;
      height: 2px;
      background: var(--ink);
    }

    /* 頁面裡寫死的那排導覽按鈕由 nav.js 取代，全尺寸都收起 */
    .topbar-right a.btn { display: none; }

    /* ── 手機的底部分頁列 ──────────────────────────────────────────
       桌機不顯示；手機顯示，並把頁首那排導覽按鈕收起來。
       換頁交給底部、換檢視留在工具列，兩者不再混在一起。 */
    .tabbar { display: none; }

    /* 手機。這些規則放在 app.css，四個頁面才會一起吃到 ——
       先前只寫在 calendar.css 裡，訂單看板與設定頁完全沒套到。 */
    @media (max-width: 560px) {
      .shell { padding: 0 14px; }

      .topbar-inner { height: 52px; }
      .brand { flex: none; gap: 8px; min-width: 0; }
      .brand-name { white-space: nowrap; font-size: 15px; }
      .brand-sub { display: none; }
      .brand-mark { width: 28px; height: 28px; }
      .brand-mark svg { width: 16px; height: 16px; }

      /* 導覽搬到底部分頁列，頁首只留標題與鈴鐺 */
      .topbar-right { width: auto; gap: 6px; }
      .mainnav { display: none; }
      .bell { width: 34px; height: 34px; }

      .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding-bottom: env(safe-area-inset-bottom, 0);
      }
      .tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 7px 2px 8px;
        font-size: 11px;
        line-height: 1.2;
        color: var(--text-3);
        text-decoration: none;
      }
      .tab svg { width: 21px; height: 21px; }
      .tab.is-active { color: var(--ink); font-weight: 600; }
      .tab.is-active svg { stroke-width: 2.1; }

      /* 內容不要被分頁列蓋住 */
      body { padding-bottom: 66px; }

      /* 三張統計卡各佔一整行太浪費，改成一排三格 */
      .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
      .stat { padding: 12px 10px; }
      .stat-label { font-size: 12px; font-weight: 500; letter-spacing: 0; }
      .stat-row { margin-top: 6px; align-items: baseline; }
      .stat-value { font-size: 26px; letter-spacing: -.01em; }
      .stat-unit { font-size: 12px; padding-bottom: 2px; }

      .card-head { padding: 13px 14px; }
      .console { padding: 16px 14px; }
      .console-title { font-size: 15.5px; }
      .console-text { font-size: 14px; }
      .notif-panel { right: 14px; left: 14px; width: auto; }
      .toast-wrap { right: 14px; left: 14px; }
      thead th, tbody td { padding-left: 14px; padding-right: 14px; }
    }

    /* ===================================================================
       登入帳號與登出（由 nav.js 產生）
       桌機放在頁首最右邊；手機頁首擠不下，改放在底部分頁列最後一格。
       =================================================================== */
    .navuser {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-left: 6px;
      padding-left: 12px;
      border-left: 1px solid var(--border);
    }

    .navuser-name {
      font-size: 13.5px;
      color: var(--text-2);
      max-width: 160px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .navuser-out {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 13.5px;
      color: var(--text-2);
      text-decoration: none;
      white-space: nowrap;
    }
    .navuser-out svg { width: 15px; height: 15px; }
    .navuser-out:hover { color: var(--text); }

    @media (max-width: 560px) {
      /* 手機的登出在分頁列，頁首不重複放一份 */
      .navuser { display: none; }
      .tab-logout { color: var(--text-3); }
    }
