  :root {
    --navy: #1E232B;
    --navy-2: #2A313D;
    --cream: #F2EFE4;
    --white: #FFFFFF;
    --brass: #B8935B;
    --brass-dark: #9C7A42;
    --border: #DAD4C2;
    --muted: #6b6558;
    --red: #A85D45;
    --green: #3E6B4A;

    --st-new: #33506B;
    --st-inspecting: #6B6E8C;
    --st-scheduled: #9C7A3C;
    --st-done: #3F6E64;
    --st-to_invoice: #C1793F;
    --st-invoiced: #6B4E5E;
    --st-paid: #3E6B4A;
    --st-cancelled: #9AA0A6;

    --shadow-sm: 0 1px 3px rgba(30,35,43,0.05);
    --shadow-md: 0 6px 16px -4px rgba(30,35,43,0.14);
    --shadow-lg: 0 20px 50px -12px rgba(30,35,43,0.28);
    --radius: 10px;
  }
  * { box-sizing: border-box; }
  /* overflow-x:hidden 同时设在 html 和 body 上，在 iOS Safari 会把 body 变成滚动容器，
     里面 position:fixed 的底栏就会跟着内容一起滚。clip 同样裁掉横向溢出，但不创建滚动容器；
     不支持 clip 的旧系统回退到前一行的 hidden。 */
  html, body { overflow-x: hidden; overflow-x: clip; overscroll-behavior-y: none; }
  body {
    margin: 0;
    background: var(--cream);
    color: var(--navy);
    font-family: "IBM Plex Sans", -apple-system, "PingFang SC", sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  body.no-scroll { position: fixed; inset: 0; overflow: hidden; width: 100%; }
  h1, h2, h3, .serif { font-family: "Source Serif 4", Georgia, serif; }
  .mono { font-family: "IBM Plex Mono", monospace; }
  button { font-family: inherit; transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease; }
  button:active { transform: scale(0.97); }
  input, select, textarea { transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
  ::selection { background: var(--brass); color: white; }
  * { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--brass); }

  /* custom checkbox */
  input[type=checkbox] {
    appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0;
    border: 1.5px solid var(--border); border-radius: 5px; background: var(--white);
    cursor: pointer; position: relative; flex-shrink: 0;
  }
  input[type=checkbox]:checked { background: var(--navy); border-color: var(--navy); }
  input[type=checkbox]:checked::after {
    content: ''; position: absolute; left: 5px; top: 1px; width: 4px; height: 8px;
    border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg);
  }
  input[type=checkbox]:focus-visible { box-shadow: 0 0 0 3px rgba(184,147,90,0.25); outline: none; }

  /* toast notifications */
  #toast-container {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
  }
  .toast {
    background: var(--navy); color: white; padding: 11px 20px; border-radius: 8px;
    font-size: 13px; box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateY(8px) scale(0.96);
    transition: opacity .2s ease, transform .2s ease;
    max-width: min(88vw, 420px); text-align: center;
  }
  .toast.show { opacity: 1; transform: translateY(0) scale(1); }
  .toast.error { background: var(--red); }
  .toast.success { background: var(--green); }

  /* loading spinner */
  .spinner {
    display: inline-block; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35); border-top-color: white;
    animation: spin .7s linear infinite; vertical-align: middle;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #board-loading {
    display: none; align-items: center; justify-content: center; gap: 10px;
    padding: 60px 0; color: var(--muted); font-size: 13px;
  }
  #board-loading .spinner { border: 2px solid var(--border); border-top-color: var(--brass); }
  #main > * { animation: fadeIn .2s ease; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

  /* ---------- Login ---------- */
  #login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(circle at 15% 15%, rgba(184,147,90,0.13), transparent 45%),
      radial-gradient(circle at 85% 85%, rgba(30,35,43,0.06), transparent 50%),
      var(--cream);
  }
  #login-box .brand-mark {
    width: 40px; height: 40px; border-radius: 10px; background: var(--navy);
    display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
    color: var(--brass); font-family: "Source Serif 4", serif; font-size: 20px; font-weight: 700;
  }
  #login-box {
    width: 320px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 36px;
    box-shadow: 0 20px 50px -20px rgba(30,35,43,0.25);
    animation: fadeIn .3s ease;
  }
  #login-box h1 { font-size: 19px; margin: 0 0 22px; color: var(--navy); font-weight: 600; }
  #login-box input {
    width: 100%;
    padding: 11px 13px;
    margin-bottom: 12px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--navy);
    font-size: 14px;
    font-family: inherit;
  }
  #login-box input:focus {
    outline: none; border-color: var(--brass); background: var(--white);
    box-shadow: 0 0 0 3px rgba(184,147,90,0.15);
  }
  #login-box button {
    width: 100%;
    padding: 11px;
    background: var(--navy);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    margin-top: 4px;
  }
  #login-box button:hover { background: #2a313d; }
  #login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

  /* ---------- Shell ---------- */
  #app { display: none; min-height: 100vh; flex-direction: column; }
  #topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--navy);
    color: var(--cream);
  }
  #topbar h1 { font-size: 18px; margin: 0; color: white; }
  #topbar .right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
  #topbar button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: var(--cream);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
  }
  #tabs-wrap { position: relative; background: var(--navy); }
  #tabs-wrap::after {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0; width: 28px;
    background: linear-gradient(to right, rgba(30,35,43,0), var(--navy));
    pointer-events: none;
  }
  #tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    background: var(--navy);
    overflow-x: auto;
    scrollbar-width: none;
  }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button {
    background: transparent;
    border: none;
    color: rgba(242,239,228,0.65);
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color .15s ease, border-color .2s ease;
  }
  #tabs button:hover { color: white; }
  #tabs button.active { color: white; border-bottom-color: var(--brass); }
  #tabs button:active { transform: none; }

  /* ---------- Filter bar ---------- */
  #filterbar {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
  }
  #filterbar.show { display: flex; }
  .pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
  .pill {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--cream);
    font-size: 12px;
    cursor: pointer;
    color: var(--navy);
  }
  .pill:hover { border-color: var(--brass); }
  .pill.active { background: var(--navy); color: white; border-color: var(--navy); }
  .pill.active:hover { border-color: var(--navy); }
  #filterbar input[type=date] {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--cream);
    font-size: 12px;
    font-family: inherit;
  }
  #filterbar .sep { color: var(--muted); font-size: 12px; }
  #clear-filters { display: none; background: transparent; border: none; color: var(--red); font-size: 12px; cursor: pointer; text-decoration: underline; }
  #invoice-search {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    width: 200px;
  }

  #view-banner {
    padding: 6px 16px;
    font-size: 12px;
    color: var(--muted);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: none;
  }

  #main { flex: 1; overflow: auto; padding: 16px; }

  /* ---------- Kanban ---------- */
  #kanban-columns { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
  .col {
    min-width: 260px; max-width: 260px;
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
    max-height: calc(100vh - 220px);
    box-shadow: 0 1px 3px rgba(30,35,43,0.04);
  }
  .col-head {
    padding: 10px 12px;
    font-size: 12px; font-weight: 600;
    border-bottom: 3px solid var(--stc, var(--border));
    display: flex; justify-content: space-between;
  }
  .col-head .count { color: var(--muted); font-weight: 400; }
  .col-body { padding: 8px; overflow-y: auto; flex: 1; }

  .card {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--stc, var(--border));
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
  }
  .card:hover { box-shadow: 0 6px 16px -4px rgba(30,35,43,0.16); transform: translateY(-1px); }
  .card:active { transform: translateY(0); }
  .card .row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
  .card .agency { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; }
  .card .urgent { color: var(--red); font-size: 11px; font-weight: 600; }
  .card .address { font-family: "IBM Plex Mono", monospace; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
  .card .job { color: var(--muted); font-size: 12px; margin-bottom: 6px; line-height: 1.4; }
  /* 已取消：整卡置灰、文字变淡、去掉左侧状态色条的高饱和感 */
  .card.cancelled { opacity: 0.62; filter: grayscale(0.5); }
  .card.cancelled .address { text-decoration: line-through; text-decoration-color: var(--muted); }
  /* 抽屉里的取消横幅 */
  #cancel-banner.cancel-banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
  #cancel-banner.cancelled { background: #ECEEF0; color: #4A4F55; border: 1px solid #D6DADE; }
  #cancel-banner.suspected { background: #FCECEC; color: #8A2B2B; border: 1px solid #F2C9C9; }
  #cancel-banner .cancel-banner-actions { margin-top: 8px; display: flex; gap: 8px; }
  #cancel-banner .cancel-banner-actions button { font-size: 12px; padding: 5px 12px; border-radius: 7px; border: 1px solid currentColor; background: transparent; color: inherit; cursor: pointer; }
  #cancel-banner #confirm-cancel-inline { background: var(--red, #B3261E); color: #fff; border-color: transparent; }
  #cancel-order-btn { color: var(--muted); }
  .card .sched-pill {
    display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: var(--cream); border: 1px solid var(--border); margin-bottom: 6px; font-family: "IBM Plex Mono", monospace;
  }
  .card .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-family: "IBM Plex Mono", monospace; }
  .card .flag { color: var(--red); font-size: 11px; margin-top: 6px; }
  #add-card-btn {
    margin: 8px; padding: 8px;
    background: transparent; border: 1px dashed var(--border); color: var(--muted);
    border-radius: 6px; cursor: pointer; font-size: 12px; width: calc(100% - 16px);
  }

  /* ---------- All orders table ---------- */
  table.orders-table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 13px; }
  table.orders-table th, table.orders-table td {
    text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  }
  table.orders-table th { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  table.orders-table tr { cursor: pointer; }
  table.orders-table tr:hover { background: var(--cream); }
  .status-chip {
    display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 999px; color: white; background: var(--stc);
  }
  .card-stack { display: none; flex-direction: column; gap: 8px; }

  /* ---------- Invoices ---------- */
  #invoice-toolbar { display: flex; justify-content: space-between; margin-bottom: 12px; }
  #download-all-btn {
    padding: 8px 14px; background: var(--navy); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
  }
  .invoice-row { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
  .invoice-row .icon { font-size: 20px; }
  .invoice-row .info { flex: 1; min-width: 0; overflow-wrap: break-word; }
  .invoice-row .fname { font-size: 12px; color: var(--muted); font-family: "IBM Plex Mono", monospace; overflow-wrap: break-word; }

  /* ---------- Documents ledger ---------- */
  #documents-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
  #documents-search {
    flex: 1; min-width: 180px; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface-tint); font-size: 13px; font-family: inherit; color: var(--navy);
  }
  #documents-search:focus { outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring); }
  #documents-toolbar .sep { color: var(--muted); font-size: 12px; }
  #documents-date-clear {
    padding: 4px 9px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface-tint); font-size: 11px; cursor: pointer; color: var(--red);
  }
  #documents-date-clear:disabled { opacity: .4; cursor: not-allowed; color: var(--muted); }
  /* 中介筛选：看板顶部和发票台账用同一套样式，两处一眼看上去是同一个控件 */
  #agency-filter, #documents-agency-filter {
    flex: 0 1 auto; max-width: 190px; padding: 5px 8px; border: 1px solid var(--border);
    border-radius: 7px; background: var(--surface-tint); font-size: 12px;
    font-family: inherit; color: var(--navy); cursor: pointer;
  }
  #agency-filter:focus, #documents-agency-filter:focus {
    outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring);
  }
  #documents-selectbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 4px 0 14px; }
  #documents-selectbar label.checkbox { margin-bottom: 0; }
  #documents-selected-count { font-size: 12px; color: var(--muted); }
  #documents-download-btn {
    margin-left: auto; padding: 8px 14px; background: var(--navy); color: white;
    border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
  }
  #documents-download-btn:disabled { opacity: .45; cursor: not-allowed; }
  #documents-paid-btn {
    padding: 8px 14px; background: transparent; color: var(--navy);
    border: 1px solid var(--navy); border-radius: 6px; cursor: pointer; font-size: 13px;
  }
  #documents-paid-btn:disabled { opacity: .35; cursor: not-allowed; }
  #documents-void-btn {
    padding: 8px 14px; background: transparent; color: var(--muted);
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px;
  }
  #documents-void-btn:disabled { opacity: .35; cursor: not-allowed; }
  #documents-review-btn {
    padding: 8px 14px; background: transparent; color: #8d6935;
    border: 1px solid #e0c98f; border-radius: 6px; cursor: pointer; font-size: 13px;
  }
  #documents-review-btn:disabled { opacity: .35; cursor: not-allowed; }
  .month-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .03em; }
  .month-title:first-of-type { margin-top: 2px; }
  #documents-list .invoice-row { align-items: flex-start; }
  #documents-list .invoice-row .doc-check { flex-shrink: 0; margin-top: 3px; }
  .doc-agency-select {
    margin-top: 6px; padding: 5px 8px; border: 1px solid var(--brass); border-radius: 6px;
    background: var(--surface-tint); font-size: 12px; font-family: inherit; color: var(--navy); cursor: pointer;
  }

  /* ---------- Today / follow-up ---------- */
  .simple-card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
  .simple-card .t { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); }
  .group-title { font-size: 14px; font-weight: 600; margin: 20px 0 10px; }
  .group-title:first-child { margin-top: 0; }

  /* ---------- By agency ---------- */
  .agency-card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; }
  .agency-card h3 { margin: 0 0 8px; font-size: 15px; }
  .agency-stats { display: flex; gap: 24px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
  .agency-stats b { color: var(--navy); font-family: "IBM Plex Mono", monospace; }

  /* ---------- Detail drawer ---------- */
  #drawer-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(30,35,43,0);
    z-index: 20; transition: background-color .25s ease;
  }
  #drawer-backdrop.show { background: rgba(30,35,43,0.35); }
  #drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw;
    background: var(--white); box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    /* 抽屉本身不滚（iOS 对 fixed 容器自身的 overflow 滚动会出问题）：
       header / actions 作为不收缩的 flex 子项，body 作为唯一的滚动区。
       这样「保存」操作栏永远钉在底部、不依赖 sticky，手机上一定点得到。 */
    overflow: hidden;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.32,.72,.35,1);
    display: flex; flex-direction: column;
  }
  #drawer-backdrop.show #drawer { transform: translateX(0); }
  #drawer-header {
    flex-shrink: 0; background: var(--white);
    padding: 20px 24px 14px; border-bottom: 1px solid var(--border);
  }
  #drawer-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); border-radius: 6px; padding: 2px 6px; }
  #drawer-close:hover { background: var(--cream); color: var(--navy); }
  /* 头部主按钮：紧挨关闭键左侧。查看模式 =「✎ 编辑」（柔和浅底），编辑模式 =「保存」（实心深色）。
     放在头部是为了永远可见、不被手机底部栏遮挡；显示与否、文案由 setDrawerMode 控制（员工/子员工不显示）。 */
  #drawer-save-top {
    display: none; float: right; margin-right: 10px;
    height: 34px; padding: 0 16px; border-radius: 999px;
    font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer;
    background: #eff1f5; color: #202938; border: 1px solid #dfe3ea;
    transition: background-color .15s ease, color .15s ease, transform .1s ease;
  }
  #drawer-save-top:active { transform: scale(.97); }
  #drawer-save-top.is-save { background: #202938; color: #fff; border-color: #202938; }
  #drawer .agency-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
  #drawer-body { padding: 20px 24px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  #d-address-view, #f-address {
    display: block; width: 100%; margin: 4px 0 0; padding: 4px 0;
    font-size: 22px; font-family: "IBM Plex Mono", monospace; font-weight: 500;
    color: var(--navy); background: transparent; border: none; border-bottom: 1px solid transparent;
    line-height: 1.3;
  }
  #d-address-view { word-break: break-word; min-height: 1.3em; }
  #f-address:focus { outline: none; border-bottom-color: var(--brass); background: var(--cream); }
  #d-contact-view { display: flex; flex-direction: column; gap: 4px; min-height: 1.3em; padding: 4px 0; }
  #d-contact-view .contact-name { font-size: 13px; color: var(--navy); }
  #d-contact-view .contact-empty { font-size: 13px; color: var(--muted); }
  #d-contact-view .contact-link {
    font-size: 13px; color: var(--brass-dark); text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  }
  #d-contact-view .contact-link:active { opacity: 0.7; }
  #edit-mode-banner {
    display: none; align-items: center; gap: 6px; background: #FBF3E4; color: #8a6a2f;
    font-size: 11px; padding: 6px 10px; border-radius: 6px; margin: 12px 0 -4px;
  }
  #status-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
  #status-pills .pill { font-size: 11px; }
  #status-pills .pill.auto-pill {
    opacity: 0.55; cursor: not-allowed; background: transparent; border-style: dashed;
  }
  #status-pills .pill.auto-pill:hover { border-color: var(--border); }
  #status-pills .pill.auto-pill.active { opacity: 1; border-style: solid; }
  .field-row { display: flex; gap: 12px; margin-bottom: 14px; }
  .field { flex: 1; min-width: 0; }
  .field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.02em; }
  .field input, .field textarea, .field select {
    width: 100%; padding: 7px 8px; margin: -7px -8px; border: 1px solid transparent; border-radius: 6px; background: transparent;
    font-size: 13px; font-family: inherit; color: var(--navy);
  }
  .field textarea { resize: vertical; min-height: 22px; }
  /* edit mode: fields look like real inputs */
  #drawer.editing .field input, #drawer.editing .field textarea {
    border-color: var(--border); background: var(--cream);
  }
  #drawer.editing .field input:focus, #drawer.editing .field textarea:focus {
    outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px rgba(184,147,90,0.15);
  }
  #drawer.editing #f-address { border-bottom-color: var(--border); }
  #drawer:not(.editing) .field input, #drawer:not(.editing) .field textarea { cursor: default; }
  #drawer:not(.editing) input[type=date]::-webkit-calendar-picker-indicator { display: none; }
  #invoice-file-card { display: flex; align-items: center; gap: 10px; background: var(--cream); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 14px; cursor: pointer; transition: background-color .15s ease; }
  #invoice-file-card:hover { background: #ece7d8; }
  #invoice-file-empty { color: var(--muted); font-size: 12px; padding: 10px; text-align: center; border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 14px; }
  #timeline-list { max-height: 160px; overflow-y: auto; margin-bottom: 14px; }
  .tl-item { border-left: 2px solid var(--border); padding: 4px 0 4px 10px; margin-bottom: 6px; font-size: 12px; }
  .tl-item .tl-meta { color: var(--muted); font-size: 11px; font-family: "IBM Plex Mono", monospace; }
  #note-hint {
    display: none; background: #FBF3E4; border: 1px solid var(--brass); border-radius: 8px; padding: 10px; font-size: 12px; margin-bottom: 12px;
  }
  #note-hint button { font-size: 11px; padding: 4px 10px; border-radius: 4px; border: 1px solid var(--brass); background: white; cursor: pointer; margin-right: 6px; margin-top: 6px; }
  #drawer-actions {
    flex-shrink: 0; background: var(--white);
    display: flex; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--border);
    /* iOS 底部安全区（home indicator）留白，别让按钮贴到最边缘点不到 */
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  #drawer-actions button { padding: 9px 16px; border-radius: 7px; border: 1px solid var(--border); background: var(--cream); cursor: pointer; font-size: 13px; }
  #drawer-actions button:hover { border-color: var(--brass); }
  #edit-btn, #save-btn { background: var(--navy); border-color: var(--navy); color: white; }
  #edit-btn:hover, #save-btn:hover { background: #2a313d; border-color: #2a313d; }
  #delete-btn, #cancel-btn { color: var(--red); border-color: var(--red); }
  #delete-btn:hover, #cancel-btn:hover { background: var(--red); color: white; }
  #view-actions, #edit-actions { display: flex; gap: 8px; }
  label.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 14px; }
  label.checkbox input { width: auto; }
  #drawer:not(.editing) label.checkbox { pointer-events: none; opacity: 0.75; }

  /* ---------- Invoice preview modal ---------- */
  #invoice-modal-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(30,35,43,0);
    align-items: center; justify-content: center; z-index: 30; transition: background-color .2s ease;
  }
  #invoice-modal-backdrop.show { background: rgba(30,35,43,0.5); }
  #invoice-modal {
    width: 460px; max-width: 92vw; background: white; border-radius: 12px; padding: 32px;
    font-family: "IBM Plex Mono", monospace; font-size: 13px; position: relative;
    box-shadow: 0 24px 60px -12px rgba(0,0,0,0.35);
    transform: scale(0.96) translateY(8px); opacity: 0;
    transition: transform .2s cubic-bezier(.32,.72,.35,1), opacity .2s ease;
  }
  #invoice-modal-backdrop.show #invoice-modal { transform: scale(1) translateY(0); opacity: 1; }
  #invoice-modal .close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); font-family: sans-serif; }
  #invoice-modal h2 { font-family: "Source Serif 4", serif; font-size: 18px; margin: 0 0 4px; }
  #invoice-modal .sub { color: var(--muted); font-size: 11px; margin-bottom: 20px; }
  #invoice-modal .row { display: flex; justify-content: space-between; margin-bottom: 8px; }
  #invoice-modal .divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
  #invoice-modal .amount { font-size: 20px; font-weight: 500; }
  #invoice-modal .footnote { font-family: "IBM Plex Sans", sans-serif; font-size: 11px; color: var(--muted); margin-top: 20px; text-align: center; }

  /* ---------- Unmatched queue ---------- */
  #unmatched-badge {
    display: inline-block; background: var(--red); color: white; font-size: 10px;
    border-radius: 999px; padding: 1px 6px; margin-left: 5px; font-family: "IBM Plex Sans", sans-serif;
  }
  .unmatched-card { background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--brass); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
  .unmatched-card .src-tag { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; }
  .unmatched-card .summary { margin: 6px 0; font-size: 13px; }
  .unmatched-card .reason { color: var(--red); font-size: 12px; margin-bottom: 10px; }
  .unmatched-card .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .unmatched-card select {
    padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--cream); font-size: 12px; font-family: inherit; max-width: 220px;
  }
  .unmatched-card input.amt {
    padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--cream); font-size: 12px; width: 90px; font-family: inherit;
  }
  .unmatched-card button {
    padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--cream); cursor: pointer; font-size: 12px;
  }
  .unmatched-card button.primary { background: var(--navy); color: white; border-color: var(--navy); }
  .unmatched-card button.dismiss { color: var(--red); border-color: var(--red); }

  /* ---------- Responsive ---------- */
  @media (max-width: 860px) {
    table.orders-table { display: none; }
    .card-stack { display: flex; }
    #drawer { width: 100vw; }
    #invoice-search { width: 140px; }
    #topbar h1 { font-size: 15px; }
    #topbar { padding: 10px 14px; }
    #filterbar { padding: 8px 12px; gap: 6px; }
    #filterbar .sep { display: none; }
    .unmatched-card .actions { flex-direction: column; align-items: stretch; }
    .unmatched-card select, .unmatched-card input.amt { max-width: none; width: 100%; }
    input, select, textarea { font-size: 16px !important; }

    /* drawer: single column, roomier touch targets */
    .field-row { flex-direction: column; gap: 4px; margin-bottom: 18px; }
    .field-row .field:not(:first-child) { margin-top: 14px; }
    #drawer-header { padding: 16px 18px 12px; }
    #drawer-body { padding: 16px 18px; }
    #drawer-actions { padding: 12px 18px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    #d-address-view, #f-address { font-size: 19px; }
    #status-pills .pill { padding: 7px 12px; font-size: 12px; }

    /* bottom nav instead of top tab strip */
    #tabs-wrap {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
      border-top: 1px solid rgba(255,255,255,0.15);
    }
    /* 抽屉/弹层打开时（body.no-scroll）隐藏底部导航：手机上抽屉本就全屏盖住，
       留着这条导航只会挡住抽屉底部的「保存」按钮，还在 iOS 上跟 sticky 底栏打架。 */
    body.no-scroll #tabs-wrap { display: none; }
    #tabs-wrap::after { background: linear-gradient(to right, rgba(30,35,43,0), var(--navy) 85%); }
    #tabs button { padding: 10px 12px; font-size: 11px; }
    #main { padding-bottom: 60px; }
    #view-banner { margin-bottom: 0; }

    /* kanban: stack columns vertically instead of side-scrolling */
    #kanban-columns { flex-direction: column; overflow-x: visible; }
    .col { min-width: 100%; max-width: 100%; max-height: none; margin-bottom: 12px; }
    .col-body { max-height: none; overflow-y: visible; }
    .col.empty-on-mobile { display: none; }
  }

/* ==========================================================
   Visual system · refined workspace
   Presentation-only overrides. Behaviour and layout hooks stay intact.
   ========================================================== */
:root {
  --navy: #17201f;
  --navy-2: #24302e;
  --cream: #f3f1eb;
  --white: #fffefa;
  --brass: #b78b4a;
  --brass-dark: #8d6935;
  --border: #dedbd1;
  --muted: #716f68;
  --red: #b65f4a;
  --green: #39705a;
  --surface-soft: #f8f7f2;
  --surface-tint: #eceae2;
  --ink-soft: #43504e;
  --ring: rgba(183, 139, 74, 0.18);
  --shadow-sm: 0 1px 2px rgba(23, 32, 31, 0.04), 0 4px 12px rgba(23, 32, 31, 0.03);
  --shadow-md: 0 12px 32px -12px rgba(23, 32, 31, 0.2);
  --shadow-lg: 0 28px 80px -24px rgba(23, 32, 31, 0.34);
  --radius: 12px;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(183, 139, 74, 0.06), transparent 30rem),
    var(--cream);
  letter-spacing: -0.005em;
}

button,
input,
select,
textarea { border-radius: 9px; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

/* Login */
#login-screen {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.7), rgba(243,241,235,0.5)),
    radial-gradient(circle at 15% 18%, rgba(183,139,74,0.2), transparent 28rem),
    radial-gradient(circle at 86% 80%, rgba(57,112,90,0.12), transparent 34rem),
    var(--cream);
}
#login-screen::before,
#login-screen::after {
  content: '';
  position: absolute;
  width: 22rem;
  height: 22rem;
  border: 1px solid rgba(183,139,74,0.14);
  border-radius: 50%;
  pointer-events: none;
}
#login-screen::before { top: -12rem; right: -7rem; }
#login-screen::after { bottom: -14rem; left: -5rem; width: 30rem; height: 30rem; }
#login-box {
  position: relative;
  z-index: 1;
  width: min(390px, calc(100vw - 32px));
  padding: 42px;
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 22px;
  background: rgba(255,254,250,0.86);
  box-shadow: 0 32px 100px -38px rgba(23,32,31,0.42);
  backdrop-filter: blur(20px);
}
#login-box .brand-mark {
  width: 50px;
  height: 50px;
  margin-bottom: 26px;
  border-radius: 15px;
  background: linear-gradient(145deg, #283633, var(--navy));
  box-shadow: 0 12px 28px -12px rgba(23,32,31,0.7);
  font-size: 22px;
}
#login-box h1 { margin-bottom: 26px; font-size: 25px; letter-spacing: -0.02em; }
#login-box input {
  padding: 13px 15px;
  margin-bottom: 12px;
  border-color: transparent;
  background: rgba(236,234,226,0.7);
}
#login-box .password-field {
  position: relative;
  margin-bottom: 12px;
}
#login-box .password-field input {
  margin-bottom: 0;
  padding-right: 46px;
}
#password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 34px !important;
  height: 34px;
  margin: 0 !important;
  padding: 0 !important;
  place-items: center;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #77756e;
  box-shadow: none !important;
  transform: translateY(-50%);
}
#password-toggle:hover { background: rgba(23,32,31,.06) !important; color: var(--navy); }
#password-toggle:active { transform: translateY(-50%) scale(.94); }
#password-toggle .eye-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
#password-toggle .eye-closed { display: none; }
#password-toggle.showing .eye-open { display: none; }
#password-toggle.showing .eye-closed { display: block; }
#login-box input:hover { border-color: var(--border); }
#login-box button {
  padding: 13px;
  margin-top: 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  box-shadow: 0 10px 24px -12px rgba(23,32,31,0.8);
  font-weight: 600;
}

/* App shell */
#topbar {
  position: relative;
  padding: 18px 28px 14px;
  background: var(--navy);
}
#topbar::after {
  content: '';
  position: absolute;
  right: 28%;
  bottom: 0;
  width: 22rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(183,139,74,0.55), transparent);
}
#topbar h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; }
#topbar .right { color: rgba(255,255,255,0.62); }
#topbar button {
  padding: 7px 13px;
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
}
#topbar button:hover { border-color: rgba(183,139,74,0.7); color: white; }
#tabs-wrap { background: var(--navy); }
#tabs {
  gap: 3px;
  padding: 0 20px;
  background: var(--navy);
}
#tabs button {
  position: relative;
  padding: 11px 14px 13px;
  border-bottom: 0;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}
#tabs button::after {
  content: '';
  position: absolute;
  right: 14px;
  bottom: 4px;
  left: 14px;
  height: 2px;
  border-radius: 99px;
  background: var(--brass);
  transform: scaleX(0);
  transition: transform .2s ease;
}
#tabs button.active { color: #fff; }
#tabs button.active::after { transform: scaleX(1); }

/* Filters */
#filterbar {
  gap: 10px;
  padding: 13px 24px;
  border-bottom-color: rgba(222,219,209,0.9);
  background: rgba(255,254,250,0.88);
  box-shadow: 0 8px 24px -24px rgba(23,32,31,0.8);
  backdrop-filter: blur(16px);
}
.pill-group { gap: 7px; }
.pill {
  padding: 6px 12px;
  border-color: transparent;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-weight: 500;
}
.pill:hover { border-color: rgba(183,139,74,0.55); background: var(--white); }
.pill.active {
  background: var(--navy);
  box-shadow: 0 5px 14px -8px rgba(23,32,31,0.8);
}
#filterbar input[type=date],
#invoice-search {
  min-height: 31px;
  border-color: transparent;
  background: var(--surface-tint);
  color: var(--navy);
}
#filterbar input:hover,
#invoice-search:hover { border-color: var(--border); background: var(--white); }
#clear-filters { text-decoration: none; font-weight: 500; }
#view-banner {
  padding: 8px 24px;
  border-bottom: 1px solid #ead9bb;
  background: #fbf4e8;
  color: #82683c;
}
#main { padding: 22px 24px 28px; }

/* Kanban */
#kanban-columns { gap: 15px; padding: 2px 2px 16px; }
.col {
  min-width: 276px;
  max-width: 276px;
  overflow: hidden;
  border-color: rgba(222,219,209,0.86);
  border-radius: 15px;
  background: rgba(255,254,250,0.68);
  box-shadow: var(--shadow-sm);
}
.col-head {
  padding: 14px 14px 12px;
  border-bottom-width: 2px;
  background: rgba(255,255,255,0.45);
  letter-spacing: 0.01em;
}
.col-head .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-tint);
  text-align: center;
}
.col-body { padding: 10px; }
.card {
  margin-bottom: 10px;
  padding: 13px 13px 12px;
  border: 1px solid rgba(222,219,209,0.82);
  border-left: 3px solid var(--stc, var(--border));
  border-radius: 11px;
  background: rgba(255,254,250,0.98);
  box-shadow: 0 1px 2px rgba(23,32,31,0.025);
}
.card:hover {
  border-color: rgba(183,139,74,0.42);
  border-left-color: var(--stc, var(--border));
  box-shadow: 0 14px 28px -17px rgba(23,32,31,0.42);
  transform: translateY(-2px);
}
.card .row1 { margin-bottom: 7px; }
.card .agency { color: #817a6d; font-size: 10px; font-weight: 600; letter-spacing: .06em; }
.card .urgent { padding: 2px 7px; border-radius: 99px; background: rgba(182,95,74,.1); }
.card .address { margin-bottom: 6px; color: var(--navy); font-size: 13px; line-height: 1.45; }
.card .job { margin-bottom: 9px; color: var(--ink-soft); }
.card .sched-pill { border-color: transparent; background: #f1ede4; color: #79623f; }
.card .meta { padding-top: 8px; border-top: 1px solid rgba(222,219,209,0.62); }
.card .flag { padding: 6px 8px; border-radius: 7px; background: rgba(182,95,74,.07); }
#add-card-btn { margin: 10px; padding: 10px; border-color: #c9c3b5; border-radius: 9px; }
#add-card-btn:hover { border-color: var(--brass); background: rgba(183,139,74,.07); color: var(--brass-dark); }

/* Lists, tables, summaries */
table.orders-table {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: var(--shadow-sm);
}
table.orders-table th {
  padding: 12px 13px;
  background: var(--surface-tint);
  color: #77746c;
  letter-spacing: .045em;
}
table.orders-table td { padding: 11px 13px; }
table.orders-table tr:last-child td { border-bottom: 0; }
table.orders-table tbody tr { transition: background-color .15s ease; }
table.orders-table tr:hover { background: #faf7ee; }
.status-chip { padding: 4px 9px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
#invoice-toolbar { align-items: center; margin-bottom: 16px; }
#download-all-btn {
  padding: 9px 15px;
  border-radius: 9px;
  background: var(--navy);
  box-shadow: 0 8px 18px -12px rgba(23,32,31,.8);
}
.invoice-row,
.simple-card,
.agency-card,
.unmatched-card {
  border-color: rgba(222,219,209,.9);
  border-radius: 12px;
  background: rgba(255,254,250,.94);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.invoice-row:hover,
.simple-card:hover,
.agency-card:hover,
.unmatched-card:hover {
  border-color: rgba(183,139,74,.46);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.invoice-row { padding: 13px 15px; }
.simple-card { padding: 13px 15px; }
.agency-card { padding: 18px 20px; margin-bottom: 12px; }
.agency-card h3 { margin-bottom: 12px; font-size: 17px; }
.agency-stats { gap: 12px 34px; }
.agency-stats > div { padding-right: 22px; border-right: 1px solid var(--border); }
.agency-stats > div:last-child { border-right: 0; }
.group-title { margin-top: 26px; font-family: "Source Serif 4", serif; font-size: 17px; }
.unmatched-card { padding: 16px 17px; }
.unmatched-card .actions { margin-top: 12px; }
.unmatched-card select,
.unmatched-card input.amt { border-color: transparent; background: var(--surface-tint); }

/* Drawer */
#drawer-backdrop.show { background: rgba(15,24,23,.48); backdrop-filter: blur(3px); }
#drawer {
  width: 500px;
  border-left: 1px solid rgba(255,255,255,.7);
  background: var(--white);
  box-shadow: -24px 0 70px -28px rgba(15,24,23,.55);
}
#drawer-header {
  padding: 24px 28px 17px;
  border-bottom-color: rgba(222,219,209,.78);
  background: rgba(255,254,250,.9);
  backdrop-filter: blur(18px);
}
#drawer-close { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--surface-tint); }
#drawer .agency-label { color: var(--brass-dark); font-weight: 600; letter-spacing: .07em; }
#d-address-view,
#f-address { margin-top: 7px; font-size: 23px; letter-spacing: -.025em; }
#status-pills { margin: 19px 0 3px; }
#drawer-body { padding: 24px 28px 30px; }
.field-row { gap: 16px; margin-bottom: 19px; }
.field label { margin-bottom: 7px; color: #848078; font-weight: 600; letter-spacing: .055em; }
.field input,
.field textarea,
.field select { line-height: 1.55; }
#drawer.editing .field input,
#drawer.editing .field textarea { padding: 9px 10px; margin: -9px -10px; background: var(--surface-soft); }
#invoice-file-card { padding: 12px; border-color: transparent; background: var(--surface-tint); }
#invoice-file-empty { padding: 13px; background: var(--surface-soft); }
#timeline-list { max-height: 210px; }
.tl-item { padding: 7px 0 7px 13px; border-left-color: #d6c8ae; }
#drawer-actions {
  padding: 15px 28px;
  padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
  border-top-color: rgba(222,219,209,.8);
  background: rgba(255,254,250,.92);
  box-shadow: 0 -10px 30px -26px rgba(23,32,31,.8);
  backdrop-filter: blur(16px);
}
#drawer-actions button { padding: 9px 17px; background: var(--surface-tint); }
#edit-btn,
#save-btn { background: var(--navy) !important; }

/* Modal and feedback */
#invoice-modal-backdrop.show { background: rgba(15,24,23,.58); backdrop-filter: blur(4px); }
#invoice-modal {
  padding: 38px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
}
#invoice-modal h2 { font-size: 22px; }
#invoice-modal .sub { color: var(--brass-dark); letter-spacing: .12em; }
#invoice-modal .divider { border-top-color: #d9c8a9; }
.toast { padding: 12px 18px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; }
#board-loading { min-height: 45vh; }

@media (max-width: 860px) {
  #topbar { padding: 13px 16px 11px; }
  #topbar::after { display: none; }
  #topbar .right { gap: 8px; }
  #who-label { display: none; }
  #tabs { padding: 0 8px; }
  #tabs button { padding: 11px 12px 12px; }
  #tabs button::after { right: 12px; left: 12px; }
  #filterbar { padding: 10px 12px; }
  #main { padding: 14px 12px 76px; }
  .col { min-width: 100%; max-width: 100%; border-radius: 13px; }
  .col-head { padding: 13px; }
  .card { padding: 13px; }
  #drawer { width: 100vw; }
  #drawer-header { padding: 18px 19px 14px; }
  #drawer-body { padding: 20px 19px 26px; }
  #drawer-actions { padding: 12px 19px; }
  .agency-stats > div { border-right: 0; }
  #invoice-modal { padding: 28px 24px; }
}

[hidden] { display: none !important; }
.staff-mode #delete-btn { display: none !important; }
.staff-mode #edit-btn { display: none !important; }
.staff-mode #view-actions-right { display: none !important; }
/* Staff can now move an order through the operational statuses, so only the
   pills they actually can't set are dimmed. */
.staff-mode #status-pills .pill[disabled] { cursor: default; opacity: .55; }
.staff-mode .card .meta { justify-content: flex-start; }

@media (max-width: 460px) {
  #login-box { padding: 32px 25px; }
  #topbar h1 { font-size: 17px; }
  #filterbar .pill { padding: 6px 10px; }
  #invoice-search { width: 100%; }
  #drawer-actions { gap: 8px; }
  #drawer-actions button { padding: 9px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================
   Desktop composition · navigation, rhythm and interaction
   ========================================================== */
@media (min-width: 861px) {
  #app {
    --sidebar-width: 218px;
    --header-height: 72px;
    display: none;
    min-height: 100vh;
    padding-left: var(--sidebar-width);
    background: transparent;
  }

  #topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    height: var(--header-height);
    margin-left: calc(var(--sidebar-width) * -1);
    padding: 0 28px 0 24px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 10px 36px -28px rgba(15,24,23,.9);
  }

  #topbar h1 {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  #topbar h1::before {
    content: '猫';
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(214,177,112,.28);
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.025));
    color: #d6b170;
    font-size: 17px;
    box-shadow: inset 0 1px rgba(255,255,255,.08);
  }

  #topbar .right::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6fbc94;
    box-shadow: 0 0 0 4px rgba(111,188,148,.1);
  }

  #tabs-wrap {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 16;
    width: var(--sidebar-width);
    padding: 20px 12px;
    border-right: 1px solid rgba(255,255,255,.07);
    background:
      radial-gradient(circle at 0 100%, rgba(183,139,74,.13), transparent 18rem),
      var(--navy);
  }

  #tabs-wrap::before {
    content: 'WORKSPACE';
    display: block;
    padding: 0 13px 10px;
    color: rgba(255,255,255,.27);
    font-family: "IBM Plex Mono", monospace;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: .16em;
  }

  #tabs-wrap::after {
    top: auto;
    right: 20px;
    bottom: 22px;
    left: 20px;
    width: auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(183,139,74,.25), transparent);
  }

  #tabs {
    flex-direction: column;
    gap: 5px;
    padding: 0;
    overflow: visible;
  }

  #tabs button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 43px;
    padding: 10px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    text-align: left;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease;
  }

  #tabs button::before {
    display: inline-grid;
    width: 24px;
    margin-right: 8px;
    place-items: center;
    color: rgba(214,177,112,.74);
    font-size: 14px;
  }

  #tabs button[data-tab="board"]::before { content: '◫'; }
  #tabs button[data-tab="all"]::before { content: '☷'; }
  #tabs button[data-tab="invoices"]::before { content: '◇'; }
  #tabs button[data-tab="today"]::before { content: '◷'; }
  #tabs button[data-tab="followup"]::before { content: '↗'; }
  #tabs button[data-tab="byagency"]::before { content: '◎'; }
  #tabs button[data-tab="unmatched"]::before { content: '⌁'; }
  #tabs button[data-tab="documents"]::before { content: '🗂'; }

  #tabs button:hover {
    border-color: rgba(255,255,255,.06);
    background: rgba(255,255,255,.055);
    transform: translateX(2px);
  }

  #tabs button.active {
    border-color: rgba(214,177,112,.16);
    background: linear-gradient(90deg, rgba(183,139,74,.19), rgba(255,255,255,.055));
    box-shadow: inset 3px 0 #c49a59;
  }

  #tabs button::after { display: none; }

  #unmatched-badge {
    margin-left: auto;
    padding: 2px 7px;
    background: #b96852;
  }

  #filterbar {
    position: sticky;
    top: var(--header-height);
    z-index: 12;
    min-height: 58px;
  }

  #main {
    width: 100%;
    min-width: 0;
  }

  #kanban-columns {
    min-height: calc(100vh - 174px);
  }

  .col {
    max-height: calc(100vh - 174px);
  }
}

/* Interaction details shared across viewports */
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; }

#download-all-btn:hover,
#edit-btn:hover,
#save-btn:hover,
.unmatched-card button.primary:hover {
  background: #273633 !important;
  box-shadow: 0 12px 24px -14px rgba(23,32,31,.9);
  transform: translateY(-1px);
}

#download-all-btn:active,
#edit-btn:active,
#save-btn:active,
.unmatched-card button.primary:active { transform: translateY(0) scale(.98); }

.invoice-row .icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: #f1eadc;
  font-size: 18px;
}

.invoice-row::after {
  content: '›';
  color: #aaa59a;
  font-size: 22px;
  transition: transform .18s ease, color .18s ease;
}

.invoice-row:hover::after { color: var(--brass-dark); transform: translateX(3px); }

.simple-card { position: relative; padding-right: 42px; }
.simple-card::after {
  content: '›';
  position: absolute;
  top: 50%;
  right: 16px;
  color: #aaa59a;
  font-size: 21px;
  transform: translateY(-50%);
}

.simple-card:hover::after { color: var(--brass-dark); }

.agency-card h3::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 4px rgba(183,139,74,.1);
  vertical-align: 2px;
}

.field input:hover,
.field textarea:hover { background-color: rgba(243,241,235,.7); }

#drawer.editing .field input:hover,
#drawer.editing .field textarea:hover { border-color: #c8c2b5; }

#drawer:not(.editing) .field input,
#drawer:not(.editing) .field textarea { color: #35413f; }

#drawer.editing #edit-mode-banner {
  border: 1px solid #ead5ad;
  background: #fbf5e9;
  color: #806234;
}

#note-hint { border-color: #dcc28f; background: #fbf5e9; }

@media (max-width: 860px) {
  #app { padding-left: 0; }

  #tabs-wrap {
    background: rgba(23,32,31,.96);
    box-shadow: 0 -10px 30px -22px rgba(15,24,23,.95);
    backdrop-filter: blur(18px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #tabs-wrap::after { width: 22px; }

  #tabs button {
    min-width: 66px;
    min-height: 56px;
    padding: 14px 12px 16px;
    border-bottom: 0;
    border-radius: 0;
  }

  #tabs button::after { bottom: 3px; }

  #tabs button.active { background: rgba(255,255,255,.045); }

  #main { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }

  .invoice-row .icon { width: 34px; height: 34px; }
}

/* ==========================================================
   Final palette · modern graphite and cobalt
   ========================================================== */
:root {
  --navy: #131922;
  --navy-2: #202938;
  --cream: #f4f6fa;
  --white: #ffffff;
  --brass: #596fe8;
  --brass-dark: #4057d0;
  --border: #e1e6ee;
  --muted: #6f7887;
  --red: #d45f61;
  --green: #33866b;
  --surface-soft: #f8f9fc;
  --surface-tint: #edf0f5;
  --ink-soft: #4a5565;
  --ring: rgba(89,111,232,.16);

  --st-new: #4b6cb7;
  --st-inspecting: #7169a8;
  --st-scheduled: #b17a43;
  --st-done: #398179;
  --st-to_invoice: #c36c4e;
  --st-invoiced: #775e8e;
  --st-paid: #38805f;
}

/* 底纹：一层极细的墨点做纸感，三团很淡的光把空白撑起来。
   做成 body 的背景层而不是 fixed 伪元素 —— iOS 上少一个合成层，滚动不掉帧。 */
body {
  background:
    radial-gradient(rgba(19,25,34,.08) .6px, transparent .6px) 0 0 / 5px 5px,
    radial-gradient(circle at 12% -8%, rgba(89,111,232,.085), transparent 34rem),
    radial-gradient(circle at 104% 72%, rgba(51,134,107,.07), transparent 28rem),
    radial-gradient(circle at -10% 108%, rgba(89,111,232,.06), transparent 30rem),
    var(--cream);
}

::selection { background: #7183e9; color: white; }

#login-screen {
  background:
    radial-gradient(circle at 12% 14%, rgba(89,111,232,.15), transparent 28rem),
    radial-gradient(circle at 88% 84%, rgba(131,101,206,.09), transparent 30rem),
    linear-gradient(145deg, #f8f9fc, #eef1f7);
}
#login-screen::before,
#login-screen::after { border-color: rgba(89,111,232,.1); }
#login-box {
  border-color: rgba(255,255,255,.94);
  background: rgba(255,255,255,.9);
  box-shadow: 0 34px 90px -40px rgba(31,42,70,.38);
}
#login-box .brand-mark {
  background: linear-gradient(145deg, #27334a, #131922);
  color: #aeb9ff;
}
#login-box input { background: #f1f3f7; }
#login-box input:focus { border-color: #7c8cea; box-shadow: 0 0 0 4px var(--ring); }
#login-box > #login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #243047, #131922);
}
#login-box > #login-btn:disabled { opacity: .72; cursor: wait; }
#login-error { color: var(--red); }

#topbar,
#tabs-wrap,
#tabs { background-color: var(--navy); }
#topbar h1::before {
  border-color: rgba(150,166,255,.22);
  color: #aeb9ff;
}
#topbar .right::before { background: #5cc89c; box-shadow: 0 0 0 4px rgba(92,200,156,.1); }

#filterbar {
  border-bottom-color: var(--border);
  background: rgba(255,255,255,.88);
}
.pill { background: #edf0f5; color: #465164; }
.pill:hover { border-color: #b7c0f4; background: #f8f9ff; color: #3449b4; }
.pill.active { background: #202938; color: #fff; }
#filterbar input[type=date],
#invoice-search { background: #f0f2f6; }
#view-banner { border-color: #dce2ff; background: #f1f4ff; color: #4d5fae; }

.col {
  border-color: #e0e5ed;
  background: rgba(248,249,252,.82);
}
.col-head { background: rgba(255,255,255,.72); }
.col-head .count { background: #edf0f5; }
.card {
  border-color: #e1e6ee;
  background: #fff;
}
.card:hover {
  border-color: #cbd3e1;
  border-left-color: var(--stc, var(--border));
  box-shadow: 0 14px 30px -18px rgba(25,36,58,.32);
}
.card .agency { color: #778195; }
.card .urgent { background: #fff0f0; }
.card .sched-pill { background: #f0f2f7; color: #566174; }
.card .meta { border-top-color: #edf0f4; }
.card.needs-info { background: #fdf6e8; border-color: #ecd9a8; }
.card.needs-rework { background: #f6eefc; border-color: #ddb9f2; }
.card .rework-flag {
  display: block; width: 100%; margin: 6px 0 0; padding: 6px 8px; border: none; border-radius: 7px;
  background: #f1e4fb; color: #7c3aed; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer;
}
.card .rework-flag:hover { background: #e6d1f8; }
.card .rework-flag:active { transform: scale(.98); }
.card .flag {
  display: block; width: 100%; margin: 0; border: none; background: #fff2f1;
  font-family: inherit; text-align: left; cursor: pointer;
}
.card .flag:hover { background: #ffe4e2; }
.card .flag:active { transform: scale(.98); }
.card .quote-flag {
  display: block; width: 100%; margin: 6px 0 0; padding: 6px 8px; border: none; border-radius: 7px;
  background: #eef1ff; color: #4057d0; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer;
}
.card .quote-flag:hover { background: #dfe4ff; }
.card .quote-flag:active { transform: scale(.98); }
#add-card-btn:hover { border-color: #8c9af0; background: #f3f5ff; color: #4057d0; }

table.orders-table,
.invoice-row,
.simple-card,
.agency-card,
.unmatched-card { border-color: #e1e6ee; }
table.orders-table th { background: #edf0f5; }
table.orders-table tr:hover { background: #f5f7fc; }
.invoice-row:hover,
.simple-card:hover,
.agency-card:hover,
.unmatched-card:hover { border-color: #c8d0e0; }
.invoice-row .icon { background: #eef1ff; }
.invoice-row:hover::after,
.simple-card:hover::after { color: #596fe8; }
.agency-card h3::before { background: #6679e8; box-shadow: 0 0 0 4px rgba(89,111,232,.1); }

#download-all-btn,
#edit-btn,
#save-btn,
.unmatched-card button.primary { background: #202938 !important; }
#download-all-btn:hover,
#edit-btn:hover,
#save-btn:hover,
.unmatched-card button.primary:hover { background: #2e3a50 !important; }

#drawer-backdrop.show { background: rgba(13,18,27,.5); }
#drawer { background: #fff; box-shadow: -24px 0 70px -28px rgba(20,30,48,.5); }
#drawer-header,
#drawer-actions { background: rgba(255,255,255,.92); }
#drawer .agency-label { color: #4e63d1; }
#drawer-close { background: #eff1f5; }
#drawer.editing .field input,
#drawer.editing .field textarea { background: #f6f7fa; }
#drawer.editing #edit-mode-banner,
#note-hint { border-color: #d7defe; background: #f2f4ff; color: #4c5daa; }
#invoice-file-card { background: #f0f2f6; }
.tl-item { border-left-color: #c7cff9; }

#invoice-modal-backdrop.show { background: rgba(13,18,27,.58); }
#invoice-modal .sub { color: #5267d6; }
#invoice-modal .divider { border-top-color: #dce1ee; }

@media (min-width: 861px) {
  #tabs-wrap {
    background:
      radial-gradient(circle at 0 100%, rgba(89,111,232,.14), transparent 20rem),
      var(--navy);
  }
  #tabs-wrap::before { color: rgba(181,192,255,.34); }
  #tabs button::before { color: rgba(162,176,255,.76); }
  #tabs button.active {
    border-color: rgba(129,147,244,.17);
    background: linear-gradient(90deg, rgba(89,111,232,.2), rgba(255,255,255,.045));
    box-shadow: inset 3px 0 #7587ed;
  }
  #tabs-wrap::after { background: linear-gradient(90deg, transparent, rgba(113,131,233,.28), transparent); }
}

/* Clear, consistent motion feedback */
.card,
.invoice-row,
.simple-card,
.agency-card,
.unmatched-card,
#tabs button,
.pill,
#drawer-actions button { will-change: transform; }

.pill:active { transform: scale(.96); }
.card:focus-visible,
.invoice-row:focus-visible,
.simple-card:focus-visible { box-shadow: 0 0 0 4px var(--ring); }

@media (hover: none) {
  .card:hover,
  .invoice-row:hover,
  .simple-card:hover,
  .agency-card:hover,
  .unmatched-card:hover { transform: none; box-shadow: var(--shadow-sm); }
}

/* ==========================================================
   Typography and density · Chinese-first product UI
   ========================================================== */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-number: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", "PingFang SC", monospace;
}

html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
}

h1, h2, h3, .serif {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -.025em;
}

.mono { font-family: var(--font-number); letter-spacing: -.02em; }
button, input, select, textarea { font-family: var(--font-ui); }

/* Brand and navigation hierarchy */
#topbar h1 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.018em;
}
#topbar .right { font-size: 12px; }
#tabs button {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}
#tabs-wrap::before { font-family: var(--font-ui); font-weight: 600; }

/* Controls */
.pill {
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
#filterbar input[type=date],
#invoice-search,
#clear-filters { font-size: 12px; }
#view-banner { font-size: 12px; line-height: 18px; }

/* Board hierarchy */
.col-head {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .01em;
}
.col-head .count { font-size: 11px; font-weight: 500; }
.card { font-size: 13px; }
.card .agency {
  font-size: 10px;
  font-weight: 650;
  line-height: 16px;
  letter-spacing: .045em;
}
.card .urgent { font-size: 10px; line-height: 16px; }
.card .address {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -.012em;
}
.card .job {
  font-size: 12px;
  line-height: 1.55;
}
.card .sched-pill {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
}
.card .meta {
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 17px;
}
.card .meta span:last-child { font-weight: 550; color: #566174; }
.card .flag { font-size: 11px; }
#add-card-btn { font-size: 12px; font-weight: 500; }

/* Data views */
table.orders-table { font-size: 13px; }
table.orders-table th {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .035em;
}
table.orders-table td { line-height: 1.45; }
.status-chip { font-size: 11px; font-weight: 550; }
.invoice-row { font-size: 13px; }
.invoice-row .fname {
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 18px;
}
.simple-card { font-size: 13px; }
.simple-card .t {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
}
.group-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.015em;
}
.agency-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 650;
}
.agency-stats { font-size: 12px; }
.agency-stats b {
  font-family: var(--font-ui);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.unmatched-card .src-tag { font-size: 10px; font-weight: 650; }
.unmatched-card .summary { font-size: 13px; line-height: 1.55; }
.unmatched-card .reason { font-size: 12px; }

/* Drawer typography */
#drawer .agency-label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .06em;
}
#d-address-view,
#f-address {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.025em;
}
#status-pills .pill { font-size: 11px; }
.field label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .04em;
}
.field input,
.field textarea,
.field select {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}
#timeline-list { font-size: 12px; }
.tl-item .tl-meta {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 550;
}
#drawer-actions button { font-size: 12px; font-weight: 550; }

/* Login and modal */
#login-box h1 {
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -.028em;
}
#login-box input,
#login-box button { font-size: 14px; }
#login-error { font-size: 12px; }
#invoice-modal { font-family: var(--font-ui); font-size: 13px; }
#invoice-modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 680;
}
#invoice-modal .sub { font-family: var(--font-ui); font-size: 10px; font-weight: 650; }
#invoice-modal .amount {
  font-family: var(--font-number);
  font-size: 19px;
  font-weight: 600;
}
#invoice-modal .footnote { font-family: var(--font-ui); font-size: 10px; }
.toast { font-size: 12px; font-weight: 500; }

/* Flatter surfaces keep type visually dominant */
.col,
.card,
.invoice-row,
.simple-card,
.agency-card,
.unmatched-card { border-radius: 10px; }
.col { border-radius: 12px; }
.card,
.invoice-row,
.simple-card,
.agency-card,
.unmatched-card { box-shadow: 0 1px 2px rgba(20,30,48,.035); }

@media (max-width: 860px) {
  body { font-size: 14px; }
  #topbar h1 { font-size: 16px; }
  #tabs button { font-size: 11px; }
  #d-address-view,
  #f-address { font-size: 19px; }
  .card .address { font-size: 14px; }
  .field input,
  .field textarea,
  .field select { font-size: 16px; }
}

/* ---------- Quote modal (报价单) ---------- */
#quote-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 30; transition: background-color .2s ease;
}
#quote-modal-backdrop.show { background: rgba(13,18,27,.58); }
#quote-modal {
  width: 460px; max-width: 92vw; background: var(--white); border-radius: 18px; padding: 32px;
  font-family: var(--font-ui, "IBM Plex Mono", monospace); font-size: 13px; position: relative;
  box-shadow: var(--shadow-lg, 0 24px 60px -12px rgba(0,0,0,0.35));
  transform: scale(0.96) translateY(8px); opacity: 0;
  transition: transform .2s cubic-bezier(.32,.72,.35,1), opacity .2s ease;
  max-height: 88vh; overflow-y: auto;
}
#quote-modal-backdrop.show #quote-modal { transform: scale(1) translateY(0); opacity: 1; }
#quote-modal .close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); font-family: sans-serif; }
#quote-modal h2 { font-family: var(--font-display, "Source Serif 4", serif); font-size: 22px; margin: 0 0 4px; }
#quote-modal .sub { color: var(--brass); font-size: 10px; font-weight: 650; letter-spacing: .1em; margin-bottom: 20px; }
#quote-modal .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
#quote-modal .row span:first-child { color: var(--muted); font-size: 12px; flex-shrink: 0; }
#quote-modal .row span:last-child { text-align: right; word-break: break-word; }
#quote-modal .qm-field {
  flex: 1; text-align: right; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 6px; font-family: inherit; font-size: 13px; color: var(--navy); background: transparent;
}
#quote-modal .qm-field:hover { border-color: var(--border); background: var(--surface-tint, var(--cream)); }
#quote-modal .qm-field:focus { outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16)); }
#quote-modal .divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
#quote-modal .amount { font-size: 18px; font-weight: 600; }
#quote-generate-btn {
  display: block; width: 100%; margin-top: 22px; padding: 12px; border: none; border-radius: 10px;
  background: var(--navy); color: white; font-size: 14px; font-weight: 600; cursor: pointer;
}
#quote-generate-btn:hover { background: var(--navy-2, #202938); }
#quote-generate-btn:disabled { opacity: .5; cursor: not-allowed; }
#quote-modal .footnote { font-family: var(--font-ui, sans-serif); font-size: 10px; color: var(--muted); margin-top: 14px; text-align: center; }

@media (max-width: 460px) {
  #quote-modal { padding: 24px 20px; }
}

.card a.address,
#d-address-view .address-link,
.simple-card a.address-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.card a.address:active,
#d-address-view .address-link:active,
.simple-card a.address-link:active {
  opacity: 0.7;
}

/* ---------- Invoice modal editable fields (发票) ---------- */
#invoice-modal .im-field {
  flex: 1; text-align: right; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 6px; font-family: inherit; font-size: 13px; color: var(--navy); background: transparent;
}
#invoice-modal .im-field:hover { border-color: var(--border); background: var(--surface-tint, var(--cream)); }
#invoice-modal .im-field:focus { outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16)); }
#invoice-generate-btn {
  display: block; width: 100%; margin-top: 22px; padding: 12px; border: none; border-radius: 10px;
  background: var(--navy); color: white; font-size: 14px; font-weight: 600; cursor: pointer;
}
#invoice-generate-btn:hover { background: var(--navy-2, #202938); }
#invoice-generate-btn:disabled { opacity: .5; cursor: not-allowed; }

.card .invoice-flag {
  display: block; width: 100%; margin: 6px 0 0; padding: 6px 8px; border: none; border-radius: 7px;
  background: #e3f6ea; color: #1f8a4c; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer;
}
.card .invoice-flag:hover { background: #cdeedc; }
.card .invoice-flag:active { transform: scale(.98); }

/* ---------- Dispatch (派送给员工) ---------- */
#dispatch-section { margin-bottom: 16px; }
#dispatch-section > label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.dispatch-row { display: flex; gap: 8px; margin-bottom: 8px; }
#dispatch-staff-select {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit; color: var(--navy);
}
#dispatch-amount {
  width: 110px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit; color: var(--navy); text-align: right;
}
#dispatch-confirm-btn {
  padding: 8px 14px; border: none; border-radius: 8px; background: var(--navy); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
#dispatch-confirm-btn:hover { background: var(--navy-2, #202938); }
#dispatch-assigned {
  background: var(--surface-tint, var(--cream)); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
#dispatch-assigned-text { font-size: 13px; color: var(--navy); margin-bottom: 8px; }
#dispatch-cancel-btn {
  padding: 8px 14px; border: none; border-radius: 8px; background: #b23b3b; color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
#dispatch-cancel-btn:hover { background: #952f2f; }

.card .dispatch-info { font-size: 11px; color: var(--muted); margin-top: 6px; }
.card .dispatch-pay { font-size: 11px; color: #1f8a4c; font-weight: 600; margin-top: 6px; }
.card .dispatch-done-flag {
  display: block; width: 100%; margin: 6px 0 0; padding: 6px 8px; border: none; border-radius: 7px;
  background: #e3f6ea; color: #1f8a4c; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer;
}
.card .dispatch-done-flag:hover { background: #cdeedc; }
.card .dispatch-done-flag:active { transform: scale(.98); }

/* ---------- Completion photos (drawer, admin view) ---------- */
#completion-photos-section { margin-bottom: 16px; }
#completion-photos-section > label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
#completion-photos-list { display: flex; flex-direction: column; gap: 8px; }
.completion-photo-row { display: flex; gap: 8px; align-items: stretch; }
.completion-photo-thumb {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 12px; font-family: inherit;
  color: var(--navy); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}
.completion-photo-thumb:hover { border-color: var(--brass); }
.completion-photo-dl {
  flex-shrink: 0; width: 36px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); color: var(--navy); font-size: 14px; cursor: pointer;
}
.completion-photo-dl:hover { border-color: var(--brass); background: var(--white); }

/* ---------- Complete-order modal (员工上传完工照片) ---------- */
#complete-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 30; transition: background-color .2s ease;
}
#complete-modal-backdrop.show { background: rgba(13,18,27,.58); }
#complete-modal {
  width: 420px; max-width: 92vw; background: var(--white); border-radius: 18px; padding: 32px;
  font-family: var(--font-ui, "IBM Plex Mono", monospace); font-size: 13px; position: relative;
  box-shadow: var(--shadow-lg, 0 24px 60px -12px rgba(0,0,0,0.35));
  transform: scale(0.96) translateY(8px); opacity: 0;
  transition: transform .2s cubic-bezier(.32,.72,.35,1), opacity .2s ease;
  max-height: 88vh; overflow-y: auto;
}
#complete-modal-backdrop.show #complete-modal { transform: scale(1) translateY(0); opacity: 1; }
#complete-modal .close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); font-family: sans-serif; }
#complete-modal h2 { font-family: var(--font-display, "Source Serif 4", serif); font-size: 22px; margin: 0 0 4px; }
#complete-modal .sub { color: var(--brass); font-size: 10px; font-weight: 650; letter-spacing: .1em; margin-bottom: 20px; }
#complete-photo-pick-btn {
  display: block; width: 100%; padding: 12px; border: 1px dashed var(--border); border-radius: 10px;
  background: var(--surface-tint, var(--cream)); color: var(--navy); font-size: 13px; font-family: inherit;
  font-weight: 600; cursor: pointer; margin-bottom: 14px;
}
#complete-photo-pick-btn:hover { border-color: var(--brass); }
#complete-photo-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.complete-photo-item {
  display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid var(--border); border-radius: 8px;
}
.complete-photo-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.complete-photo-item .cp-name { flex: 1; font-size: 12px; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.complete-photo-item .cp-status { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.complete-photo-item .cp-status.cp-ok { color: #1f8a4c; }
.complete-photo-item .cp-status.cp-error { color: #b23b3b; }
#complete-submit-btn {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--navy); color: white; font-size: 14px; font-weight: 600; cursor: pointer;
}
#complete-submit-btn:hover { background: var(--navy-2, #202938); }
#complete-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 460px) {
  #complete-modal { padding: 24px 20px; }
}

.table-photo-btn {
  padding: 3px 7px; margin: 0 3px 3px 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-tint, var(--cream)); font-size: 11px; font-family: inherit; color: var(--navy); cursor: pointer;
}
.table-photo-btn:hover { border-color: var(--brass); }

#documents-load-more {
  display: block; width: 100%; margin: 16px 0 8px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px;
  background: var(--surface-tint, var(--cream)); color: var(--navy); font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer;
}
#documents-load-more:hover { border-color: var(--brass); }

/* ---------- Quote/invoice modal: Bill To textarea + itemized lines ---------- */
.im-field-block, .qm-field-block {
  display: block; width: 100%; margin-bottom: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--navy); background: var(--surface-tint, var(--cream)); resize: vertical;
}
.im-field-block:focus, .qm-field-block:focus {
  outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16));
}
.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row .item-desc {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit; color: var(--navy);
}
.item-row .item-amount {
  width: 100px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit; color: var(--navy); text-align: right;
}
.item-row .item-desc:focus, .item-row .item-amount:focus {
  outline: none; border-color: var(--brass); background: var(--white); box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16));
}
.item-row .item-remove {
  flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.item-row .item-remove:hover { background: var(--surface-tint, var(--cream)); color: #b23b3b; }
.add-item-btn {
  display: block; width: 100%; margin-bottom: 16px; padding: 8px; border: 1px dashed var(--border); border-radius: 8px;
  background: transparent; color: var(--navy); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.add-item-btn:hover { border-color: var(--brass); background: var(--surface-tint, var(--cream)); }


/* ---------- Staff edits: notes + status changes visible to admin ---------- */
#staff-note-box { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
#staff-note-tip { font-size: 11px; color: var(--muted); }
/* 备注 is the one field staff may type in while the drawer is in view mode,
   so it must not look or behave like the locked fields around it. */
.staff-mode #drawer:not(.editing) #f-note {
  cursor: text; background: var(--white); border-color: var(--border);
}
.staff-mode #drawer:not(.editing) #f-note:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16));
}
#staff-note-btn {
  padding: 8px 14px; border: none; border-radius: 8px; background: var(--navy); color: white;
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#staff-note-btn:hover { background: var(--navy-2, #202938); }
#staff-note-btn:disabled { opacity: .6; cursor: default; }

/* Timeline entries written by a staff account — the admin should be able to
   spot "someone else changed this" at a glance. */
.tl-item.tl-staff { border-left-color: var(--brass); background: var(--surface-soft); border-radius: 0 6px 6px 0; }
.tl-photo { display:inline-flex; align-items:center; gap:6px; margin-top:5px; padding:5px 10px;
  border:1px solid var(--border); border-radius:8px; background:var(--white); cursor:pointer;
  font-family:inherit; font-size:12px; color:var(--navy); }
.tl-photo .ic { width:14px; height:14px; color:var(--brass); }
.tl-photo:active { background:var(--surface-tint); }
.tl-photo-admin { border-color: rgba(212,95,97,.4); }
.tl-photo-tag { font-style:normal; font-size:10px; font-weight:700; color:var(--red);
  background:rgba(212,95,97,.1); padding:1px 6px; border-radius:99px; margin-left:2px; }
.tl-item.tl-staff .tl-meta { color: var(--brass-dark); }
.tl-staff-tag {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: var(--brass); color: var(--white); font-size: 9px; font-weight: 700;
  letter-spacing: .04em; vertical-align: 1px;
}
.card .dispatch-info.staff-update { color: var(--brass-dark); font-weight: 600; }

/* Staff have no edit mode, so their three advisory checkboxes stay live in the
   view-mode drawer (they write immediately). Overrides the blanket
   "#drawer:not(.editing) label.checkbox { pointer-events: none }" above. */
.staff-mode #drawer:not(.editing) label.checkbox { pointer-events: auto; opacity: 1; cursor: pointer; }
.staff-mode #drawer:not(.editing) label.checkbox input { cursor: pointer; }
.staff-mode #drawer:not(.editing) label.checkbox input:disabled { cursor: progress; opacity: .5; }

/* ---------- 员工完工提醒 (admin) ---------- */
#staff-done-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 40; transition: background-color .2s ease;
}
#staff-done-modal-backdrop.show { background: rgba(13,18,27,.58); }
#staff-done-modal {
  width: min(440px, calc(100vw - 32px)); max-height: 80vh; overflow-y: auto;
  background: var(--white); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 22px 18px; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
#staff-done-modal-backdrop.show #staff-done-modal { transform: scale(1) translateY(0); opacity: 1; }
#staff-done-title {
  font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px;
}
.staff-done-row {
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; margin-bottom: 10px;
  background: var(--surface-tint, var(--cream));
}
.staff-done-row .sd-address { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 3px; }
.staff-done-row .sd-meta { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.staff-done-row .sd-open {
  padding: 5px 12px; border: 1px solid var(--brass); border-radius: 7px; background: transparent;
  color: var(--brass-dark); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.staff-done-row .sd-open:hover { background: var(--white); }
#staff-done-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
#staff-done-dismiss {
  padding: 8px 18px; border: none; border-radius: 8px; background: var(--navy); color: white;
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#staff-done-dismiss:hover { background: var(--navy-2, #202938); }

/* 派送金额 in the staff drawer — the only money figure staff are meant to see. */
#staff-pay-row { margin-bottom: 16px; }
#staff-pay-row > label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
#staff-pay-value {
  padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-tint, var(--cream));
  font-size: 17px; font-weight: 700; color: #1f8a4c; font-family: "IBM Plex Mono", monospace;
}

/* ---------- 今日上门 ---------- */
#today-toggle-btn {
  display: none; width: 100%; margin-bottom: 14px; padding: 9px 12px;
  border: 1px dashed var(--border); border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-align: center;
}
#today-toggle-btn:hover { border-color: var(--brass); color: var(--navy); }
#today-toggle-btn.on {
  border-style: solid; border-color: var(--brass); background: var(--surface-tint, var(--cream));
  color: var(--brass-dark);
}
.card .today-flag {
  display: block; width: 100%; margin: 6px 0 0; padding: 6px 8px; border: none; border-radius: 7px;
  background: #fdf1d9; color: #8d6935; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer;
}
.card .today-flag:hover { background: #f8e6c0; }
.card .today-flag:active { transform: scale(.98); }

/* ---------- 上门时间 + 加入日历 ---------- */
#schedule-row { display: none; margin-bottom: 16px; }
#schedule-row > label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.schedule-line { display: flex; gap: 8px; align-items: stretch; }
#f-scheduled-at {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); font-size: 13px; font-family: inherit; color: var(--navy);
}
#f-scheduled-at:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--ring, rgba(89,111,232,.16));
}
#ics-btn {
  flex-shrink: 0; padding: 8px 12px; border: 1px solid var(--brass); border-radius: 8px;
  background: transparent; color: var(--brass-dark); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
}
#ics-btn:hover:not(:disabled) { background: var(--surface-tint, var(--cream)); }
#ics-btn:disabled { opacity: .45; cursor: default; }
#schedule-tip { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Admin upload for completion photos — the WeChat pipeline only ever sees a
   screenshot, so originals have to come in by hand. */
#admin-photo-btn {
  display: block; width: 100%; margin-top: 8px; padding: 8px;
  border: 1px dashed var(--border); border-radius: 8px; background: transparent;
  color: var(--navy); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#admin-photo-btn:hover:not(:disabled) { border-color: var(--brass); background: var(--surface-tint, var(--cream)); }
#admin-photo-btn:disabled { opacity: .6; cursor: default; }

/* ---------- 电话：先问拨号还是短信 ---------- */
#phone-action-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 50; transition: background-color .2s ease;
}
#phone-action-backdrop.show { background: rgba(13,18,27,.58); }
#phone-action-sheet {
  width: min(320px, calc(100vw - 48px));
  background: var(--white); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
#phone-action-backdrop.show #phone-action-sheet { transform: scale(1) translateY(0); opacity: 1; }
#phone-action-number {
  text-align: center; font-family: "IBM Plex Mono", monospace; font-size: 16px;
  font-weight: 600; color: var(--navy); margin-bottom: 14px;
}
#phone-action-sheet button {
  display: block; width: 100%; margin-bottom: 8px; padding: 13px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-tint, var(--cream));
  font-size: 15px; font-weight: 600; font-family: inherit; color: var(--navy); cursor: pointer;
}
#phone-action-sheet button:hover { border-color: var(--brass); }
#phone-action-sheet button:active { transform: scale(.985); }
#phone-action-cancel {
  margin-bottom: 0 !important; background: transparent !important;
  border-color: transparent !important; color: var(--muted) !important; font-weight: 500 !important;
}
/* the phone entry is a <button> now, not an <a> — keep it looking identical */
#d-contact-view button.contact-link {
  border: none; background: none; padding: 0; font-family: inherit; text-align: left; cursor: pointer;
}

/* ---------- 新单推送 ---------- */
#notify-btn {
  padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; font-size: 14px; line-height: 1; cursor: pointer;
}
#notify-btn:hover { border-color: var(--brass); }
#notify-btn.on { border-color: var(--brass); background: var(--surface-tint, var(--cream)); }
#notify-help-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 55; transition: background-color .2s ease;
}
#notify-help-backdrop.show { background: rgba(13,18,27,.58); }
#notify-help-sheet {
  width: min(400px, calc(100vw - 40px)); max-height: 80vh; overflow-y: auto;
  background: var(--white); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
#notify-help-backdrop.show #notify-help-sheet { transform: scale(1) translateY(0); opacity: 1; }
#notify-help-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
#notify-help-body { font-size: 13px; line-height: 1.65; color: var(--ink-soft, var(--navy)); }
#notify-help-body p { margin: 0 0 10px; }
#notify-help-close {
  display: block; width: 100%; margin-top: 14px; padding: 10px;
  border: none; border-radius: 9px; background: var(--navy); color: white;
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}

/* The login inputs are direct flex children of #login-box; display:contents
   keeps that layout while the <form> wrapper exists purely so iOS recognises
   a sign-in and offers to save the password. */
#login-form { display: contents; }

/* 紧急工单页签上的计数徽章，沿用待归类那个的样式 */
#urgent-badge {
  display: none; margin-left: 5px; padding: 1px 6px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 1.5;
}

/* 员工看已完成的工单：可读不可改 */
.staff-locked #drawer:not(.editing) label.checkbox { pointer-events: none; opacity: .5; }
.staff-locked #f-scheduled-at:disabled,
.staff-locked #today-toggle-btn:disabled { opacity: .5; cursor: default; }
.staff-locked #drawer:not(.editing) #f-note { background: var(--surface-tint, var(--cream)); cursor: default; }

/* 因为今天有预约而自动进列表的，按钮不可点（没什么可标的） */
#today-toggle-btn:disabled { cursor: default; opacity: .8; }

/* 发票台账里的收款状态 */
.pay-tag {
  display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; line-height: 1.7;
}
.pay-tag.paid    { background: #e3f6ea; color: #1f8a4c; }
.pay-tag.pending { background: var(--surface-tint, #eceae2); color: var(--muted); }
.pay-tag.over30  { background: #fdf1d9; color: #8d6935; }
.pay-tag.over60  { background: #fbe4e0; color: #b23b3b; }
.pill.review-pill {
  border-color: #e0c98f; background: #fdf1d9; color: #8d6935;
}
.pill.unpaid-pill { border-color: #e3b7ab; background: #fbe4e0; color: #a8493a; }
.pill.unpaid-pill:hover { border-color: #c98d7e; background: #f8d6d0; }
.pill.unpaid-pill.active { background: #a8493a; border-color: #a8493a; color: #fff; }
.pill.unpaid-pill.empty { background: transparent; border-color: var(--border); color: var(--muted); }
.pill.review-pill.empty { background: transparent; border-color: var(--border); color: var(--muted); }
.pill.review-pill:hover { border-color: #c9ab6a; background: #fbe9c6; }
.pill.review-pill.active { background: #8d6935; border-color: #8d6935; color: #fff; }
.pay-tag.review  { background: #fdf1d9; color: #8d6935; }
.pay-tag.checked { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); margin-left: 6px; }
/* The doubt itself, spelled out under the tag -- a tag that only says
   "check this" sends the reader back to the PDFs to work out why. */
.pay-why {
  margin-top: 3px; font-size: 11px; line-height: 1.5; color: #8d6935;
  border-left: 2px solid #e0c98f; padding-left: 7px;
}
.pay-tag.void    { background: var(--surface-tint, #eceae2); color: var(--muted); text-decoration: line-through; }

/* 转派给子员工（员工端），沿用派单区的样式 */
#subdispatch-section { margin-bottom: 16px; }
#subdispatch-section > label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
#subdispatch-select {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit; color: var(--navy);
}
#subdispatch-amount {
  width: 110px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-tint, var(--cream)); font-size: 13px; font-family: inherit;
  color: var(--navy); text-align: right;
}
#subdispatch-confirm-btn {
  padding: 8px 14px; border: none; border-radius: 8px; background: var(--navy); color: white;
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#subdispatch-assigned {
  background: var(--surface-tint, var(--cream)); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
#subdispatch-assigned-text { font-size: 13px; color: var(--navy); margin-bottom: 8px; }
#subdispatch-cancel-btn {
  padding: 8px 14px; border: none; border-radius: 8px; background: #b23b3b; color: white;
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}

.pay-tag.paid.manual { background: transparent; box-shadow: inset 0 0 0 1px #1f8a4c; }


/* ==========================================================
   Date filters · one treatment for every page
   ==========================================================
   Every date filter in the app (board top bar, invoice ledger) used to style
   itself, and none of them fitted: a date input's intrinsic width is generous,
   so two of them plus a button wrapped onto a second row, and the mobile rule
   that squeezed them with flex:1 cut the value down to "1" / "7".

   The width has to be stated outright. It cannot be derived from the font
   either, because `@media (max-width: 860px) { input { font-size: 16px
   !important } }` pins the mobile font at 16px -- that rule stops iOS zooming
   the whole page when a field takes focus and must not be undercut here. 124px
   is the measured minimum that still shows DD/MM/YYYY in full at 16px; below
   that the year is clipped.

   Deliberately NOT applied to .field inputs in the drawer: those are form
   fields, not filters, and belong full-width. */
#filterbar input[type=date],
#documents-toolbar input[type=date] {
  flex: 0 0 auto;
  width: 124px;
  min-height: 0;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-tint);
  font-size: 12px;
  font-family: inherit;
  color: var(--navy);
}
#filterbar input[type=date]:focus,
#documents-toolbar input[type=date]:focus {
  outline: none;
  border-color: var(--brass);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--ring);
}
/* The native picker button is oversized and dark; shrink and mute it. */
#filterbar input[type=date]::-webkit-calendar-picker-indicator,
#documents-toolbar input[type=date]::-webkit-calendar-picker-indicator {
  width: 12px;
  height: 12px;
  padding: 0;
  margin-left: 2px;
  opacity: .4;
  cursor: pointer;
}
#filterbar input[type=date]::-webkit-calendar-picker-indicator:hover,
#documents-toolbar input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: .8; }
#filterbar input[type=date]::-webkit-date-and-time-value,
#documents-toolbar input[type=date]::-webkit-date-and-time-value { text-align: left; }

/* 手机上 input 被 @media(max-width:860px) 锁成 16px 字（防 iOS 聚焦时整页放大），
   124px 是那个字号下年份不被裁的下限，再窄就只能牺牲其中之一。电脑端字号是
   12px，实测 110px 会裁掉年份末位、114px 刚好贴住日历图标，取 118px。 */
@media (min-width: 861px) {
  #filterbar input[type=date],
  #documents-toolbar input[type=date] { width: 118px; }
}

/* 起止日期是一个区间，换行时要一起换 —— 手机上把 "从" 留在上一行、"到" 甩到
   下一行，读的人得把两半在脑子里拼回去。 */
.date-range { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.date-range .sep { display: inline !important; }

/* 看板的日期收起成一个小按钮；展开时整组日期换到下一行，不挤压筛选栏 */
#date-chip {
  flex: 0 0 auto; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-tint); color: var(--muted); font-size: 12px; font-family: inherit;
  cursor: pointer; line-height: 1.5;
}
#date-chip:hover { border-color: var(--brass); color: var(--navy); }
#date-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
#filterbar .date-range[hidden] { display: none; }
#filterbar .date-range { flex-basis: 100%; }

/* ==========================================================
   今天 · 我的 · 底部导航
   ========================================================== */
#icon-sprite{position:absolute;width:0;height:0;overflow:hidden}
/* 描边样式必须写在引用处，不能写在 <symbol> 上 —— fill/stroke 不会从 symbol
   继承到 <use>，只写在 symbol 上的话图标会被浏览器按默认 fill:black 填成黑块。 */
.nav-item svg, .trow .ic, .sheet-row svg, .v-pay .ic {
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---- 深色页眉：靠深浅分区，不靠颜色。logo 压到 5% 当水印 ---- */
.hero{position:relative;overflow:hidden;background:#191d1f;color:#fff;padding:14px 20px 17px;
  margin:10px 2px 6px;border-radius:20px;box-shadow:var(--shadow-md)}
.hero-mark{position:absolute;right:-46px;top:-26px;width:210px;height:210px;z-index:0;opacity:.055;
  background:url("icons/lazycat-logo.svg") no-repeat center/contain;filter:invert(1)}
.hero::before{content:"";position:absolute;inset:0;z-index:1;pointer-events:none;opacity:.035;
  background-image:radial-gradient(rgba(255,255,255,.5) .5px,transparent .5px);background-size:4px 4px}
.hero-in{position:relative;z-index:2}
.hero-date{font-size:11px;letter-spacing:.16em;color:rgba(255,255,255,.4);font-weight:650}
.hero-title{margin:12px 0 0;font-size:27px;font-weight:700;letter-spacing:-.03em;color:#fff}
.hero-sub{font-size:12.5px;color:rgba(255,255,255,.45);margin-top:4px}
.hero-stats{display:flex;margin-top:13px;padding-top:13px;border-top:1px solid rgba(210,167,101,.28)}
.hstat{flex:1;position:relative}
.hstat+.hstat::before{content:"";position:absolute;left:0;top:3px;bottom:3px;width:1px;
  background:linear-gradient(rgba(255,255,255,0),rgba(255,255,255,.13),rgba(255,255,255,0))}
.hstat b{display:block;font-size:27px;font-weight:700;letter-spacing:-.04em;line-height:1;
  font-variant-numeric:tabular-nums}
.hstat b i{font-style:normal;font-size:15px;color:rgba(255,255,255,.5)}
.hstat span{display:block;font-size:10.5px;color:rgba(255,255,255,.42);margin-top:7px;font-weight:560;letter-spacing:.04em}
.hstat.gold b{color:#d2a765}

.home-body{position:relative;z-index:2;padding:0 2px 20px}
.sect{display:flex;align-items:baseline;gap:9px;margin:17px 3px 9px}
.sect h3{margin:0;font-size:11.5px;font-weight:700;letter-spacing:.11em;color:var(--muted)}
.sect .rule{flex:1;height:1px;background:var(--border)}
.empty{color:var(--muted);font-size:13px;padding:6px 2px 4px}

/* 今日上门：一条竖轴串起来，比一张张独立卡片省掉一半高度 */
.tl{background:var(--white);border-radius:16px;box-shadow:var(--shadow-sm);overflow:hidden}
.tl-none{color:var(--muted);font-size:13px;padding:15px 16px;text-align:center}
.tl-i{display:flex;gap:11px;width:100%;padding:12px 15px 13px;border:0;background:none;
  font-family:inherit;text-align:left;cursor:pointer;position:relative}
.tl-i+.tl-i{border-top:1px solid var(--border)}
.tl-i:active{background:var(--surface-tint)}
.tl-dot{flex:0 0 8px;position:relative;margin-top:6px;align-self:stretch}
.tl-dot::before{content:"";position:absolute;left:0;top:0;width:8px;height:8px;border-radius:99px;
  background:var(--c,var(--brass))}
/* 连线要穿过下一条的分隔线，整条日程才连得起来 */
.tl-dot::after{content:"";position:absolute;left:3.5px;top:13px;bottom:-14px;width:1px;background:var(--border)}
.tl-i:last-child .tl-dot::after{display:none}
.tl-x{flex:1;min-width:0}
.tl-hd{display:flex;align-items:baseline;gap:6px}
.tl-hd b{font-size:13.5px;font-weight:700;letter-spacing:-.01em;font-variant-numeric:tabular-nums}
.tl-hd .sp{flex:1}
.tl-ap{font-size:10.5px;color:var(--muted)}
.tl-urg{font-size:10px;font-weight:700;color:var(--red);background:rgba(212,95,97,.1);
  padding:1px 6px;border-radius:99px;letter-spacing:.02em}
.tl-amt{font-size:12.5px;font-weight:680;font-variant-numeric:tabular-nums;color:var(--navy)}
.tl-amt.settled{color:var(--green)}
.tl-who{font-size:11.5px;color:var(--muted);max-width:132px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tl-ad{display:block;margin:3px 0 1px;font-size:15px;font-weight:620;letter-spacing:-.018em;color:var(--navy)}
.tl-jb{display:block;font-size:12.5px;color:var(--muted);line-height:1.4;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v-pay{margin-top:8px;display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;
  color:var(--navy);background:var(--surface-tint);padding:3px 9px;border-radius:7px}
.v-pay .ic{width:12px;height:12px}

.todo-list{background:var(--white);border-radius:16px;box-shadow:var(--shadow-sm);overflow:hidden}
.trow{display:flex;align-items:center;gap:12px;width:100%;padding:13px 15px;border:0;background:none;
  border-bottom:1px solid var(--border);font-family:inherit;text-align:left;cursor:pointer}
.trow:last-child{border-bottom:0}
.trow .t-n{font-size:20px;font-weight:700;letter-spacing:-.025em;font-variant-numeric:tabular-nums;min-width:26px}
.trow.gold .t-n{color:var(--brass)}.trow.red .t-n{color:var(--red)}.trow.violet .t-n{color:#6a6280}
.trow .t-x{flex:1;font-size:14.5px;font-weight:520;color:var(--navy)}
.trow .t-x small{display:block;font-size:11.5px;color:var(--muted);font-weight:400;margin-top:1px}
.trow .t-x.danger{color:var(--red)}
.trow .t-go{color:var(--muted);opacity:.5;font-size:19px;line-height:1}
.trow .t-pay{font-size:14px;font-weight:700;font-variant-numeric:tabular-nums}
.trow .ic{width:18px;height:18px;color:var(--muted)}

.panel{display:block;width:100%;text-align:left;border:0;font-family:inherit;cursor:pointer;
  background:var(--white);border-radius:16px;box-shadow:var(--shadow-sm);padding:16px 17px}
.p-top{display:flex;align-items:flex-end;justify-content:space-between}
.p-cap{font-size:11.5px;color:var(--muted);letter-spacing:.06em;font-weight:600;margin-bottom:5px}
.p-amt{font-size:27px;font-weight:700;letter-spacing:-.035em;line-height:1;font-variant-numeric:tabular-nums;color:var(--navy)}
.p-sec{font-size:16px;font-weight:680;font-variant-numeric:tabular-nums;color:var(--navy)}
.p-bar{display:flex;height:6px;border-radius:99px;overflow:hidden;margin:14px 0 10px;background:var(--surface-tint)}
.p-bar i{display:block;background:var(--green)}
.p-leg{display:flex;gap:14px;font-size:11.5px;color:var(--muted)}
.p-leg span{display:inline-flex;align-items:center;gap:5px}
.p-leg i{width:7px;height:7px;border-radius:2px}
.p-leg i.ok{background:var(--green)}.p-leg i.no{background:var(--brass)}
.p-warn{margin-top:12px;padding-top:11px;border-top:1px solid var(--border);font-size:12.5px;color:var(--red);font-weight:600}

/* ---- 底部导航 ---- */
/* 底栏钉在整个屏幕底部：独立合成层（translateZ）避免 iOS 滚动时位移/抖动；
   任何弹层（抽屉、各类弹窗，打开时 body 带 no-scroll）出现时隐藏，免得盖住弹层底部的保存/提交按钮。 */
body.no-scroll #bottomnav{display:none}
#bottomnav{-webkit-transform:translateZ(0);transform:translateZ(0);position:fixed;left:0;right:0;bottom:0;z-index:40;display:flex;padding:8px 4px calc(18px + env(safe-area-inset-bottom));
  background:rgba(255,254,250,.9);backdrop-filter:blur(20px) saturate(1.5);border-top:.5px solid var(--border)}
.nav-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;border:0;background:none;
  font-family:inherit;font-size:10px;font-weight:600;color:#a5a29a;position:relative;cursor:pointer;
  transition:color .16s ease}
.nav-item svg{width:23px;height:23px}
.nav-item.on{color:var(--navy)}
.nav-item:active{transform:scale(.94)}
.nav-badge{position:absolute;top:-4px;left:calc(50% + 5px);min-width:16px;height:16px;padding:0 4px;border-radius:99px;
  background:var(--red);color:#fff;font-size:9.5px;font-weight:700;display:grid;place-items:center;box-shadow:0 0 0 2px var(--white)}
#main{padding-bottom:86px}

/* ---- 更多面板 ---- */
.sheet-backdrop{position:fixed;inset:0;z-index:60;background:rgba(23,32,31,0);
  transition:background .22s ease;display:flex;align-items:flex-end}
.sheet-backdrop.show{background:rgba(23,32,31,.34)}
.sheet{width:100%;background:var(--white);border-radius:24px 24px 0 0;padding:10px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow:0 -18px 50px -20px rgba(23,32,31,.4);transform:translateY(100%);transition:transform .24s cubic-bezier(.22,.61,.36,1)}
.sheet-backdrop.show .sheet{transform:translateY(0)}
.grab{display:block;width:38px;height:4px;border-radius:99px;background:var(--border);margin:0 auto 14px}
.sheet-sect{font-size:11.5px;font-weight:700;letter-spacing:.11em;color:var(--muted);margin:14px 4px 8px}
.sheet-sect:first-child{margin-top:2px}
.sheet-group{background:var(--surface-soft);border-radius:14px;overflow:hidden}
.sheet-row{display:flex;align-items:center;gap:12px;width:100%;padding:13px 14px;border:0;background:none;
  border-bottom:1px solid var(--border);font-family:inherit;font-size:14.5px;text-align:left;cursor:pointer;color:var(--navy)}
.sheet-row:last-child{border-bottom:0}
.sheet-row svg{width:19px;height:19px;color:var(--muted)}
.sheet-row .sr-x{flex:1;font-weight:530}
.sheet-row .sr-x.danger{color:var(--red)}
.sheet-row .sr-go{color:var(--muted);opacity:.5;font-size:19px;line-height:1}
.sheet-row .sr-n{background:var(--red);color:#fff;font-size:11px;font-weight:700;border-radius:99px;padding:2px 8px}

/* ==========================================================
   工单卡片 · 最终样式
   一张卡最多要同时表达：状态、地址、维修内容、时间、钱、派送情况、
   以及最多五个待办。老版本把待办做成一摞通栏按钮，主次全平，列被拉得很长。
   现在的分层：状态和时间在顶，地址是主标题，派送情况是细行，待办收成小标签。
   ========================================================== */
.card{
  background:var(--white); border:0; border-left:3px solid var(--stc, var(--border));
  border-radius:14px; padding:13px 15px; margin-bottom:9px;
  box-shadow:var(--shadow-sm); cursor:pointer;
  transition:transform .18s ease, box-shadow .18s ease;
}
.card:active{transform:scale(.985); box-shadow:var(--shadow-md)}
.card .row1{display:flex;align-items:center;gap:7px;margin-bottom:6px;flex-wrap:wrap}
.card .st-tag{font-size:10.5px;font-weight:700;letter-spacing:.05em;color:var(--stc, var(--muted))}
.card .sched-pill{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:650;
  color:var(--brass-dark);background:rgba(183,139,74,.12);padding:2px 8px;border-radius:6px;margin:0}
.card .urgent{margin-left:auto;font-size:10.5px;font-weight:700;color:var(--red);
  border:1px solid rgba(182,95,74,.32);padding:2px 8px;border-radius:6px;background:none}
.card .address{display:block;font-size:15.5px;font-weight:650;letter-spacing:-.018em;color:var(--navy);
  margin:0 0 3px;text-decoration:none}
.card .job{font-size:12.5px;color:var(--muted);line-height:1.45;margin-bottom:9px;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.card .meta{display:flex;align-items:center;font-size:12px;color:var(--muted);gap:8px}
.card .meta .money{margin-left:auto;font-weight:680;color:var(--navy);font-variant-numeric:tabular-nums}

.card .notes{margin-top:9px;display:flex;flex-direction:column;gap:5px}
.card .note-line{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--muted)}
.card .note-line.staff-update{color:var(--brass-dark);font-weight:600}
.card .note-line.pay{color:var(--navy);font-weight:650}
.card .note-line .ic{width:13px;height:13px;flex:0 0 auto}

.card .chips-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px;padding-top:10px;
  border-top:1px solid var(--border)}
.c-chip{display:inline-flex;align-items:center;gap:5px;font-family:inherit;font-size:11.5px;font-weight:600;
  padding:5px 10px;border-radius:8px;border:0;cursor:pointer;
  background:var(--surface-tint);color:var(--ink-soft);transition:transform .15s ease}
.c-chip:active{transform:scale(.94)}
.c-chip .ic{width:13px;height:13px;opacity:.8}
.c-chip.warn{background:rgba(182,95,74,.1);color:var(--red)}
.c-chip.money{background:rgba(183,139,74,.14);color:var(--brass-dark)}
.c-chip.go{background:var(--navy);color:#fff}
.card .note-line .ic, .c-chip .ic, .card .sched-pill .ic{
  fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}

/* 页眉统一成跟「今天」同一块深色。原来是白底顶栏压着深色数字条，
   两个页眉叠在一起打架；铃铛和退出也搬进「更多」/「我的」了，留在这儿是重复的。 */
#topbar{position:relative;overflow:hidden;padding:14px 18px 13px;margin:10px 12px 6px;
  background:#191d1f;color:#fff;border-bottom:0;backdrop-filter:none;
  border-radius:20px;box-shadow:var(--shadow-md)}
#topbar::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.035;
  background-image:radial-gradient(rgba(255,255,255,.5) .5px,transparent .5px);background-size:4px 4px}
#topbar::after{content:"";position:absolute;right:-44px;top:-34px;width:170px;height:170px;opacity:.05;
  background:url("icons/lazycat-logo.svg") no-repeat center/contain;filter:invert(1)}
#topbar h1{position:relative;z-index:1;font-size:23px;font-weight:700;letter-spacing:-.03em;color:#fff}
/* 铃铛和退出收进「更多」/「我的」，这里只留标题 */
#topbar .right{display:none}
/* 收款页的标题栏下面还接着数字条，两块要连成一片：上面只圆上两角、
   下面只圆下两角，中间不留缝，看上去是一整张卡。 */
#topbar-extra[hidden]{display:none}
#topbar-extra{position:relative;z-index:1;width:100%;padding-top:11px}
.has-dark-head #topbar{display:block;padding-bottom:17px}
.has-dark-head #topbar h1{margin-bottom:0}
/* 行内图标：跟文字同高、随文字颜色 */
.ic{width:1em;height:1em;vertical-align:-.13em;fill:none;stroke:currentColor;
  stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.invoice-row .icon .ic{width:19px;height:19px;color:var(--muted)}
/* 信息待确认/需要返修原来整张卡染成米黄和淡紫，四张卡并排时像打翻了调色盘。
   状态已经由左边的窄条和顶部的文字表达，卡片底色统一回白，只在左条上区分。 */
.card.needs-info, .card.needs-rework{background:var(--white)}
.card.needs-info{border-left-color:var(--red)}
.card.needs-rework{border-left-color:#8d6ea8}
.card .address .pin{width:13px;height:13px;opacity:.5;margin-right:3px;vertical-align:-.1em}

/* ==========================================================
   收款（发票台账）· 页面骨架
   原来上面堆了四层：搜索 / 中介 / 日期 / 五个标签，再加一条常驻的六个批量按钮，
   而那六个按钮九成时间是灰的。现在数字上提、次要筛选收进折叠、批量按钮按需出现。
   ========================================================== */
.lh-cap{position:relative;z-index:1;font-size:10.5px;letter-spacing:.14em;color:rgba(255,255,255,.4);font-weight:650}
.lh-amt{position:relative;z-index:1;font-size:32px;font-weight:700;letter-spacing:-.04em;line-height:1.1;
  color:#d2a765;font-variant-numeric:tabular-nums;margin-top:5px}
.lh-sub{position:relative;z-index:1;font-size:12.5px;color:rgba(255,255,255,.5);margin-top:6px}
.lh-sub em{font-style:normal;color:#e0937f;font-weight:600}

#documents-toolbar{padding:0 16px;margin-bottom:12px}
#documents-toolbar #documents-search{width:100%;margin-bottom:9px}
#documents-toolbar .pill-group{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;padding-bottom:2px}
#documents-toolbar .pill-group::-webkit-scrollbar{display:none}
#documents-toolbar .pill{flex:0 0 auto}
.more-filter{margin-top:9px}
.more-filter summary{list-style:none;cursor:pointer;display:inline-flex;align-items:center;gap:5px;
  font-size:12px;color:var(--muted);font-weight:600;padding:4px 2px}
.more-filter summary::-webkit-details-marker{display:none}
.more-filter summary::after{content:"▾";font-size:10px;opacity:.6}
.more-filter[open] summary::after{content:"▴"}
.mf-body{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 0 2px}

#documents-selectbar{margin:0 16px 10px;padding:0 0 10px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:10px;overflow-x:auto;scrollbar-width:none}
#documents-selectbar::-webkit-scrollbar{display:none}
#documents-selectbar label.checkbox{flex:0 0 auto}
.sb-actions{display:flex;gap:6px;margin-left:auto;flex:0 0 auto}
.sb-actions button{flex:0 0 auto;white-space:nowrap;padding:6px 11px;font-size:12px}
#documents-list{padding:0 16px}
/* 结算状态：已收款是踏实的绿，待结算是不刺眼的灰 —— 待结算不是错误，
   只是还没轮到，不该用红色吓人。 */
.note-line em.settled, .t-pay.settled, .v-pay.settled{color:var(--green);font-style:normal;font-weight:650}
.note-line em.pending{color:var(--muted);font-style:normal}
.v-pay.settled{background:rgba(62,110,90,.12)}

/* ---------- 付给员工 ---------- */
.settle-wrap{padding:0 16px 20px}
#settle-bar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:10px;
  padding:10px 0 11px;margin-bottom:6px;background:var(--cream);border-bottom:1px solid var(--border)}
#settle-count{font-size:12.5px;color:var(--muted);font-weight:600}
#settle-btn{margin-left:auto;padding:7px 14px;border:0;border-radius:8px;background:var(--navy);
  color:#fff;font-family:inherit;font-size:13px;font-weight:620;cursor:pointer}
#settle-btn:disabled{opacity:.35;cursor:not-allowed}

.settle-person{background:var(--white);border-radius:16px;box-shadow:var(--shadow-sm);
  padding:4px 0;margin-bottom:12px;overflow:hidden}
.sp-head{display:flex;align-items:baseline;gap:10px;padding:12px 15px 9px}
.sp-name{font-size:15px;font-weight:650;letter-spacing:-.015em}
.sp-owed{margin-left:auto;font-size:12.5px;font-weight:650;color:var(--brass-dark);font-variant-numeric:tabular-nums}
.settle-row{display:flex;align-items:center;gap:11px;padding:11px 15px;border-top:1px solid var(--border);cursor:pointer}
.settle-row .sr-main{flex:1;font-size:14px;font-weight:530;min-width:0}
.settle-row .sr-main small{display:block;font-size:11.5px;color:var(--muted);font-weight:400;margin-top:2px}
.settle-row b{font-size:14px;font-weight:700;font-variant-numeric:tabular-nums}
.settle-row.done{opacity:.55;cursor:default}
.settle-row.done b{color:var(--green)}
.sp-history{border-top:1px solid var(--border)}
.sp-history summary{list-style:none;cursor:pointer;padding:10px 15px;font-size:12px;color:var(--muted);font-weight:600}
.sp-history summary::-webkit-details-marker{display:none}
.sp-history summary::after{content:" ▾";opacity:.6}
.sp-history[open] summary::after{content:" ▴"}
.settle-person .empty{padding:10px 15px 13px}
.sub-paid{font-size:12.5px;color:var(--muted);margin:6px 0 9px}
.sub-paid.settled{color:var(--green);font-weight:650}
/* 取消转派是把整条转派关系删掉，不能跟每单都要点的「标记已支付」并排站，
   而且不该是这一块里最扎眼的按钮。单独一行、靠右、白底红字。 */
.undo-row{justify-content:flex-end;margin:10px 0 0;padding-top:9px;border-top:1px solid var(--border)}
#subdispatch-cancel-btn{background:transparent;border:1px solid rgba(212,95,97,.4);
  color:var(--red);font-weight:600;padding:6px 12px;font-size:12.5px}
#subdispatch-cancel-btn:active{background:rgba(212,95,97,.08)}
#subpaid-btn{flex:1}
/* 顶栏原来固定写「懒猫工单看板」，前面配一个猫字角标。现在顶栏是每页自己的名字，
   「猫 工单」读不通，而且深色页眉右上角已经有 logo 水印了，两个品牌标记撞在一起。 */
#topbar h1::before{content:none}
#topbar .right::before{content:none}

/* ---------- 员工报单 modal ---------- */
#neworder-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 30; transition: background-color .2s ease;
}
#neworder-modal-backdrop.show { background: rgba(13,18,27,.58); }
#neworder-modal {
  width: 420px; max-width: 92vw; background: var(--white); border-radius: 18px; padding: 30px;
  font-family: inherit; font-size: 13px; position: relative; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0;
  transition: transform .2s cubic-bezier(.32,.72,.35,1), opacity .2s ease;
  max-height: 88vh; overflow-y: auto;
}
#neworder-modal-backdrop.show #neworder-modal { transform: scale(1) translateY(0); opacity: 1; }
#neworder-modal .close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
#neworder-modal h2 { font-family: "Source Serif 4", Georgia, serif; font-size: 22px; margin: 0 0 4px; }
#neworder-modal .sub { color: var(--brass); font-size: 10px; font-weight: 650; letter-spacing: .1em; margin-bottom: 20px; text-transform: uppercase; }
.no-field { display: block; margin-bottom: 14px; }
.no-field > span { display: block; font-size: 11px; color: var(--muted); font-weight: 650; margin-bottom: 5px; }
.no-field input, .no-field textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-tint); font-size: 14px; font-family: inherit; color: var(--navy);
}
.no-field input:focus, .no-field textarea:focus { outline: none; border-color: var(--brass); background: var(--white); }
.no-field textarea { resize: vertical; }
#neworder-submit-btn {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 10px; margin-top: 4px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#neworder-submit-btn:hover { background: var(--navy-2); }
#neworder-submit-btn:disabled { opacity: .55; cursor: default; }

/* 卡片上的审批小标 */
.card .row1 .appr { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.card .row1 .appr.pending { color: var(--brass-dark); background: rgba(183,139,74,.14); }
.card .row1 .appr.rejected { color: var(--red); background: rgba(212,95,97,.12); }
.card .row1 .appr + .appr, .card .row1 .urgent + .appr { margin-left: 6px; }

/* admin 员工报单待批列表 */
.appr-list { display: flex; flex-direction: column; gap: 10px; }
.appr-card { background: var(--white); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.appr-open { display: block; width: 100%; text-align: left; border: 0; background: none; font-family: inherit; cursor: pointer; padding: 14px 15px 10px; }
.appr-addr { font-size: 15px; font-weight: 650; letter-spacing: -.018em; color: var(--navy); }
.appr-job { font-size: 12.5px; color: var(--muted); margin: 3px 0 7px; line-height: 1.4; }
.appr-meta { font-size: 12.5px; color: var(--ink-soft); }
.appr-meta b { font-variant-numeric: tabular-nums; color: var(--navy); }
.appr-actions { display: flex; gap: 8px; padding: 0 15px 14px; }
.appr-ok, .appr-no { flex: 1; padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 650; font-family: inherit; cursor: pointer; }
.appr-ok { border: 0; background: var(--green); color: #fff; }
.appr-no { border: 1px solid rgba(212,95,97,.4); background: transparent; color: var(--red); }
.appr-ok:active, .appr-no:active { transform: scale(.98); }

/* ---------- 材料费 modal（复用报单 modal 的骨架）---------- */
#material-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(13,18,27,0);
  align-items: center; justify-content: center; z-index: 30; transition: background-color .2s ease;
}
#material-modal-backdrop.show { background: rgba(13,18,27,.58); }
#material-modal {
  width: 420px; max-width: 92vw; background: var(--white); border-radius: 18px; padding: 30px;
  font-family: inherit; font-size: 13px; position: relative; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0;
  transition: transform .2s cubic-bezier(.32,.72,.35,1), opacity .2s ease;
  max-height: 88vh; overflow-y: auto;
}
#material-modal-backdrop.show #material-modal { transform: scale(1) translateY(0); opacity: 1; }
#material-modal .close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
#material-modal h2 { font-family: "Source Serif 4", Georgia, serif; font-size: 22px; margin: 0 0 4px; }
#material-modal .sub { color: var(--brass); font-size: 10px; font-weight: 650; letter-spacing: .1em; margin-bottom: 20px; text-transform: uppercase; }
#mat-photo-pick-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px;
  border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-tint); color: var(--navy);
  font-size: 13px; font-family: inherit; font-weight: 600; cursor: pointer; margin: 4px 0 14px;
}
#mat-photo-pick-btn:hover { border-color: var(--brass); }
#mat-photo-pick-btn .ic { width: 15px; height: 15px; }
#mat-photo-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
#material-submit-btn {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
#material-submit-btn:hover { background: var(--navy-2); }
#material-submit-btn:disabled { opacity: .55; cursor: default; }

/* 结算行里的 工费+材料 明细 */
.settle-row b .sr-brk { display: block; font-size: 10px; font-weight: 500; color: var(--muted);
  font-variant-numeric: normal; margin-top: 2px; white-space: nowrap; }

/* 材料发票模块里的发票按钮 */
.mat-receipts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 15px 13px; }
.mat-rcpt { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--white); font-family: inherit; font-size: 12px; color: var(--navy); cursor: pointer; }
.mat-rcpt .ic { width: 13px; height: 13px; color: var(--brass); }
.mat-rcpt:active { background: var(--surface-tint); }
.mat-none { font-size: 12px; color: var(--muted); }

/* 员工报单按钮：工单页顶部常驻、显眼（不再埋在新单列里） */
#staff-report-btn {
  display: block; width: calc(100% - 24px); margin: 4px 12px 12px; padding: 13px;
  border: 0; border-radius: 12px; background: var(--navy); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 650; cursor: pointer;
  box-shadow: var(--shadow-md);
}
#staff-report-btn:active { transform: scale(.99); }

/* 材料费：派单勾选 + 已派送后的材料状态行 */
.dispatch-mat { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--navy); margin: 2px 0 10px; cursor: pointer; }
.dispatch-mat input { width: 16px; height: 16px; accent-color: var(--brass); margin: 0; }
#dispatch-material-line { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
#dispatch-material-line b { color: var(--navy); }
.no-hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: -4px 0 14px; }
#dispatch-material-btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--white, #fff); color: var(--navy);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
#dispatch-material-btn:hover { border-color: var(--brass); }
#dispatch-assigned .dispatch-row { margin-bottom: 0; }
#staff-pay-value small { display: block; margin-top: 3px; font-size: 12px; font-weight: 500; color: var(--muted); font-family: inherit; }

/* 报价/发票行在窄屏上：描述框允许收缩，× 按钮不再被挤出弹窗 */
.item-row .item-desc { min-width: 0; }
@media (max-width: 420px) { .item-row .item-amount { width: 76px; } .item-row { gap: 6px; } }

/* ---- 我的账（员工 / 子员工）：应收 / 应付 / 净赚 ---- */
.ledger { background: var(--white); border-radius: 16px; box-shadow: var(--shadow-sm); overflow: hidden; }
.ledger .lg-row { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ledger .lg-row:last-child { border-bottom: 0; }
.ledger .lg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ledger .lg-cap { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.ledger .lg-amt { font-size: 26px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ledger .lg-amt.sm { font-size: 20px; }
.ledger .recv .lg-amt { color: var(--green); }
.ledger .pay .lg-amt { color: var(--brass); }
.ledger .net { background: var(--surface-soft, #f6f4ee); }
.ledger .lg-sub { margin-top: 4px; font-size: 12.5px; color: var(--navy); }
.ledger .lg-meta { margin-top: 2px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.lg-out { margin: 8px 4px 0; font-size: 12px; color: var(--muted); }
.ledger .split { background: var(--white); }
.ledger .lg-bar { display: flex; gap: 2px; height: 12px; margin: 10px 0 8px; border-radius: 99px; overflow: hidden; }
.ledger .lg-bar i { display: block; min-width: 4px; }
.ledger .lg-leg { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.ledger .lg-leg span { display: inline-flex; align-items: center; gap: 5px; }
.ledger .lg-leg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ledger .seg-net { background: var(--green); }
.ledger .seg-sub { background: var(--brass); }
.ledger .seg-mat { background: #a9a597; }
.ledger .seg-own { background: #d6d2c4; }

/* ---- 询价池 ---- */
.enq-det > summary { list-style: none; }
.enq-det > summary::-webkit-details-marker { display: none; }
.enq-tl { padding: 4px 15px 12px; border-top: 1px solid var(--border); max-height: 260px; overflow-y: auto; }
.enq-msg { font-size: 13px; line-height: 1.5; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.enq-msg small { display: block; font-size: 11.5px; color: var(--muted); }
.enq-why { margin-top: 6px; font-size: 12.5px; color: var(--red); }
.enq-suspected { box-shadow: 0 0 0 1.5px rgba(212,95,97,.35), var(--shadow-sm); }
.appr-sub { flex: 1; padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 650; font-family: inherit; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--muted); }
.appr-sub:active { transform: scale(.98); }
.enq-shelved { margin-top: 18px; }
.enq-shelved > summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 8px 4px; }
.enq-shelved .appr-list { margin-top: 8px; opacity: .85; }

/* ---- 更早未核对（超过三个月、可能还没收到，不计入待收款）---- */
.pay-tag.stale { background: transparent; color: #8d6935; box-shadow: inset 0 0 0 1px #d9c08a; }
.pill.stale-pill { }
.stale-hint { margin: 4px 0 12px; padding: 10px 12px; border-radius: 10px; background: #fdf1d9; color: #6f5428; font-size: 12.5px; line-height: 1.6; }
.lh-stale { opacity: .85; font-size: 12px; margin-top: 2px; }
.p-note { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ---- 抽屉里挂上的发票 ---- */
#order-invoices { margin: 0 0 16px; }
#order-invoices .oi-row { padding: 9px 0; border-bottom: 1px dashed var(--border); }
#order-invoices .oi-open { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--navy); cursor: pointer; text-align: left; }
#order-invoices .oi-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
#order-invoices .oi-st { margin-top: 4px; }
#order-invoices .oi-unlink { margin-top: 6px; border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--muted); text-decoration: underline; cursor: pointer; }

/* ---- 收款页：待办 / 已结清 / 对账单 ---- */
.doc-seg { display: flex; gap: 6px; margin: 4px 0 10px; padding: 4px; background: var(--surface-tint, #eceae2); border-radius: 12px; }
.doc-seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.doc-seg button.active { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }
.doc-seg b { font-weight: 700; margin-left: 3px; font-variant-numeric: tabular-nums; }
.doc-sect { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 2px 8px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.doc-sect b { font-weight: 650; color: var(--navy); font-variant-numeric: tabular-nums; }
.doc-sect.need span { color: var(--red); }
.doc-card { background: var(--white); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.doc-card .invoice-row { border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--border); margin: 0; }
.doc-card .invoice-row:last-child { border-bottom: 0; }
.doc-grp { margin: 0 0 10px; }
.doc-grp > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 4px; cursor: pointer; }
.doc-grp > summary::-webkit-details-marker { display: none; }
.doc-grp .g-name { font-weight: 700; color: var(--navy); }
.doc-grp .g-meta { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-grp .g-meta em { font-style: normal; font-weight: 700; }
.doc-grp .g-meta em.warn { color: #8d6935; }
.doc-grp .g-meta em.late { color: var(--red); }
.doc-actions { display: flex; gap: 8px; margin-top: 8px; }
.doc-actions button { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: transparent; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--navy); cursor: pointer; }
.doc-actions button:first-child { background: var(--green); border-color: var(--green); color: #fff; }
.amt-missing { font-style: normal; color: var(--red); font-weight: 600; }
.doc-stale { margin-top: 22px; }
.doc-stale > summary { cursor: pointer; font-size: 13.5px; font-weight: 700; color: #8d6935; padding: 10px 2px; }
.doc-stale > summary small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.doc-stale .stale-all-wrap { margin: 4px 2px 8px; font-size: 12.5px; }
.doc-empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.settled-kinds { margin: 4px 0 2px; }

.doc-orphan-note { margin-top: 4px; font-size: 12px; color: var(--red); }
.doc-actions button.ghost { background: transparent; border-color: var(--border); color: var(--navy); }
.doc-actions button:first-child:not(.ghost) { background: var(--green); border-color: var(--green); color: #fff; }

/* ==== 总览 ==== */
.ov-hero{padding-bottom:18px}
.ov-cap{margin-top:16px;font-size:11px;letter-spacing:.16em;color:rgba(255,255,255,.45);font-weight:650}
.ov-fig{margin-top:6px;font-size:40px;font-weight:700;letter-spacing:-.04em;line-height:1;color:#d2a765;font-variant-numeric:tabular-nums}
.ov-fig i{font-style:normal;font-size:20px;font-weight:600;color:rgba(210,167,101,.55);letter-spacing:0}
.ov-meta{margin-top:8px;font-size:12.5px;color:rgba(255,255,255,.5)}
.ov-stats{margin-top:16px}
.ov-stats .hstat b{font-size:17px;letter-spacing:-.02em}
.ov-stats .hstat+.hstat{padding-left:14px}
.ov-stats .hstat+.hstat::before{left:0}
.ov-card{display:block;width:100%;text-align:left;font:inherit;border:0;background:var(--white);border-radius:18px;
  box-shadow:var(--shadow-sm);padding:16px 16px 14px;box-sizing:border-box}
button.ov-card{cursor:pointer}
.ov-bar{display:flex;gap:3px;height:10px;border-radius:6px;overflow:hidden;background:var(--surface-tint)}
.ov-bar i{display:block;min-width:4px}
.seg-enq{background:repeating-linear-gradient(135deg,var(--brass) 0 3px,rgba(183,139,74,.35) 3px 6px)}
.seg-prog{background:var(--st-new)}
.seg-inv{background:var(--st-to_invoice)}
.seg-pay{background:var(--st-invoiced)}
.ov-bar i.seg-enq{background:repeating-linear-gradient(135deg,#b78b4a 0 3px,rgba(183,139,74,.35) 3px 6px)}
.ov-legend{display:grid;grid-template-columns:repeat(2,1fr);gap:4px 10px;margin-top:14px}
.ov-lg{display:grid;grid-template-columns:10px auto 1fr;grid-template-rows:auto auto;column-gap:8px;align-items:baseline;
  text-align:left;border:0;background:none;font:inherit;cursor:pointer;padding:8px 6px;border-radius:10px}
.ov-lg:active{background:var(--surface-soft)}
.ov-lg .dot{width:8px;height:8px;border-radius:50%;align-self:center}
.ov-lg b{font-size:22px;font-weight:700;letter-spacing:-.03em;color:var(--navy);font-variant-numeric:tabular-nums;line-height:1}
.ov-lg .lbl{font-size:12.5px;font-weight:600;color:var(--ink-soft)}
.ov-lg small{grid-column:2 / 4;margin-top:3px;font-size:11px;color:var(--muted)}
.ov-foot{margin-top:10px;padding-top:10px;border-top:1px solid var(--border);font-size:11.5px;color:var(--muted)}
.age-ok{background:var(--green)}.age-warn{background:#c9973f}.age-late{background:var(--red)}
.ov-age-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:14px}
.ov-age{position:relative;display:block}
.ov-age .age-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px}
.ov-age em{font-style:normal;font-size:11.5px;font-weight:600;color:var(--muted)}
.ov-age b{display:block;margin-top:5px;font-size:15.5px;font-weight:700;letter-spacing:-.02em;color:var(--navy);font-variant-numeric:tabular-nums}
.ov-age small{display:block;margin-top:2px;font-size:11px;color:var(--muted)}
.ov-asks{padding:4px 0}
.ov-ask{display:flex;align-items:center;gap:13px;width:100%;border:0;background:none;font:inherit;text-align:left;cursor:pointer;padding:11px 16px;
  border-bottom:1px solid var(--border)}
.ov-ask:last-child{border-bottom:0}
.ov-ask:active{background:var(--surface-soft)}
.ov-badge{flex:none;min-width:34px;height:34px;padding:0 6px;box-sizing:border-box;border-radius:11px;display:grid;place-items:center;
  font-size:15px;font-weight:700;font-variant-numeric:tabular-nums;background:var(--surface-tint);color:var(--ink-soft)}
.ov-ask.red .ov-badge{background:rgba(182,95,74,.12);color:var(--red)}
.ov-ask.gold .ov-badge{background:rgba(183,139,74,.14);color:var(--brass-dark)}
.ov-ask.violet .ov-badge{background:rgba(119,94,142,.12);color:#6a6280}
.ov-ask-x{flex:1;min-width:0;font-size:14.5px;font-weight:600;color:var(--navy)}
.ov-ask-x small{display:block;margin-top:2px;font-size:11.5px;font-weight:400;color:var(--muted)}
.ov-go{color:var(--muted);opacity:.5;font-size:19px;line-height:1}
.ov-clear{text-align:center;color:var(--muted);font-size:13px}

/* 桌面端：左侧那条 218px 的侧栏早就不用了（导航换成了底部栏，#tabs-wrap 一直是 hidden），
   但页面还给它留着 218px 的左边距 → 网页版左边一大块空白。宽度归零，内容铺满。 */
@media (min-width: 861px) {
  #app { --sidebar-width: 0px; }
}
