  :root {
    color-scheme: light;
    /* 品牌与界面 */
    --brand: #2a78d6;
    --brand-ink: #ffffff;
    --sidebar: #14263b;
    --sidebar-ink: #c7d3e2;
    --page: #f9f9f7;
    --surface: #ffffff;
    --surface-2: #f2f2ee;
    --border: rgba(11,11,11,0.10);
    --hairline: #e1e0d9;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #898781;

    /* 数据色（dataviz 规范） */
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
    --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
    --seq: #2a78d6; --seq-100: #cde2fb; --seq-400: #3987e5; --seq-600: #184f95;

    /* 状态色（固定） */
    --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;

    --r: 10px; --r-sm: 6px;
    --shadow: 0 1px 2px rgba(11,11,11,0.05), 0 4px 16px rgba(11,11,11,0.05);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5;
  }
  button { font-family: inherit; cursor: pointer; }

  /* ===== 登录页 ===== */
  #login {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #14263b 0%, #1d3a5f 55%, #2a78d6 130%);
  }
  .login-card {
    width: 360px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  }
  .login-card .logo { font-size: 20px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
  .login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
  .field { margin-bottom: 16px; }
  .field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
  .field input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
    font-size: 14px; outline: none;
  }
  .field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42,120,214,0.15); }
  .btn-login {
    width: 100%; padding: 11px; background: var(--brand); color: #fff; border: none; border-radius: var(--r-sm);
    font-size: 15px; font-weight: 600; margin-top: 4px;
  }
  .btn-login:hover { background: #256abf; }
  .login-tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

  /* ===== 布局 ===== */
  #app { display: none; height: 100vh; }
  #app.on { display: flex; }

  .sidebar {
    width: 220px; flex: 0 0 220px; background: var(--sidebar); color: var(--sidebar-ink);
    display: flex; flex-direction: column; padding: 20px 12px;
  }
  .sidebar .brand { padding: 4px 12px 20px; font-size: 17px; font-weight: 700; color: #fff; }
  .sidebar .brand small { display: block; font-size: 11px; color: var(--sidebar-ink); font-weight: 400; }
  .nav { flex: 1; overflow-y: auto; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
    color: var(--sidebar-ink); text-decoration: none; cursor: pointer; margin-bottom: 2px; font-size: 14px;
  }
  .nav-item:hover { background: rgba(255,255,255,0.08); }
  .nav-item.active { background: var(--brand); color: #fff; }
  .nav-item .ic { width: 18px; text-align: center; opacity: 0.9; }
  .sidebar .user {
    display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid rgba(255,255,255,0.1);
  }
  .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  }
  .sidebar .user .name { color: #fff; font-size: 13px; }
  .sidebar .user .role { color: var(--sidebar-ink); font-size: 11px; }

  .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .topbar {
    height: 60px; flex: 0 0 60px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
  }
  .topbar .title { font-size: 17px; font-weight: 700; }
  .topbar .search {
    margin-left: auto; width: 260px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 20px; outline: none;
  }
  .content { flex: 1; overflow-y: auto; padding: 24px; }

  .page { display: none; }
  .page.on { display: block; }

  /* ===== 组件 ===== */
  .grid { display: grid; gap: 16px; }
  .cols-4 { grid-template-columns: repeat(4, 1fr); }
  .cols-2 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(3, 1fr); }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
  .card .card-h { padding: 14px 18px; border-bottom: 1px solid var(--hairline); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
  .card .card-b { padding: 18px; }

  .tile { padding: 18px; }
  .tile .label { color: var(--ink-2); font-size: 13px; }
  .tile .value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; margin: 6px 0 2px; }
  .tile .delta { font-size: 12px; }
  .delta.up { color: #006300; }
  .delta.down { color: var(--crit); }
  .delta.flat { color: var(--muted); }

  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--hairline); font-size: 12px; }
  td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); }
  tbody tr:hover { background: var(--surface-2); }
  .num { font-variant-numeric: tabular-nums; }
  .link { color: var(--brand); cursor: pointer; }
  .link:hover { text-decoration: underline; }

  .tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); }
  .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
  .tag.good { background: #e6f6e6; color: #006300; } .dot.good { background: var(--good); }
  .tag.warn { background: #fdf3d8; color: #7a5600; } .dot.warn { background: var(--warn); }
  .tag.serious { background: #fdeae1; color: #9c4a1e; } .dot.serious { background: var(--serious); }
  .tag.crit { background: #fbe5e5; color: #a32626; } .dot.crit { background: var(--crit); }
  .tag.blue { background: #e6effb; color: #1c5cab; }

  .btn { padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: #fff; font-size: 13px; }
  .btn:hover { background: var(--surface-2); }
  .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
  .btn.primary:hover { background: #256abf; }
  .btn.ghost { border: 1px dashed var(--brand); color: var(--brand); background: transparent; }

  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 16px; }
  .tab { padding: 9px 16px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; font-size: 13px; }
  .tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
  .tabpane { display: none; }
  .tabpane.on { display: block; }

  .toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
  .toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; outline: none; }
  .toolbar .spacer { flex: 1; }

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

  /* 图表 */
  .legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
  .legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
  .legend .sw { width: 10px; height: 10px; border-radius: 3px; }

  .hstack { display: flex; height: 24px; border-radius: 4px; overflow: hidden; gap: 2px; }
  .hstack .seg { height: 100%; }
  .hstack .seg:first-child { border-radius: 4px 0 0 4px; }
  .hstack .seg:last-child { border-radius: 0 4px 4px 0; }

  .bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
  .bar-row .nm { width: 90px; text-align: right; color: var(--ink-2); font-size: 13px; }
  .bar-row .track { flex: 1; height: 22px; background: var(--surface-2); border-radius: 4px; }
  .bar-row .bar { height: 22px; background: var(--seq); border-radius: 4px 4px 4px 4px; color: #fff; font-size: 12px; padding: 2px 8px; text-align: right; font-variant-numeric: tabular-nums; }
  .bar-row .bar.light { color: var(--ink-2); background: var(--seq-100); }

  .filter-pills { display: flex; gap: 8px; }
  .pill { padding: 5px 12px; border-radius: 20px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; color: var(--ink-2); }
  .pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }

  /* 手机打卡模拟 */
  .phone {
    width: 260px; margin: 0 auto; border: 8px solid #14263b; border-radius: 26px; overflow: hidden; background: #fff;
  }
  .phone .ph-bar { background: #14263b; color: #fff; padding: 10px; text-align: center; font-size: 13px; }
  .phone .ph-body { padding: 20px; }
  .loc-pin { text-align: center; font-size: 40px; margin: 6px 0; }
  .loc-status { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 14px; }

  .modal-bg { position: fixed; inset: 0; background: rgba(11,11,11,0.4); display: none; align-items: center; justify-content: center; z-index: 90; }
  .modal-bg.on { display: flex; }
  .modal { position: relative; width: 560px; max-height: 84vh; overflow-y: auto; background: #fff; border-radius: 12px; padding: 22px; }
  .modal h3 { margin-bottom: 16px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid .full { grid-column: 1 / -1; }
  .form-grid label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
  .form-grid input, .form-grid select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); }
  .modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

  .toast { position: fixed; top: 76px; right: 24px; background: #14263b; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; display: none; z-index: 200; }
  .toast.on { display: block; }

  .muted { color: var(--muted); }
  .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
  .flex { display: flex; align-items: center; gap: 10px; }
  .section-title { font-size: 15px; font-weight: 700; margin: 20px 0 10px; }

  /* ===== 通用组件补充 ===== */
  .btn-block { display: block; width: 100%; text-align: center; }
  .modal-close { display: none; }
  .tabbar { display: none; }

  /* ===== 订单明细卡片（桌面 + 手机通用） ===== */
  .order-items { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
  .item-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); box-shadow: var(--shadow); }
  .ic-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .ic-idx { font-weight: 700; color: var(--brand); font-size: 14px; }
  .ic-del { font-size: 13px; }
  .ic-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
  .ic-row > label { font-size: 12px; color: var(--muted); }
  .ic-row input, .ic-row select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; background: #fff; }
  .ic-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .stepper { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .stepper button { width: 44px; height: 44px; border: none; background: var(--surface-2); font-size: 20px; line-height: 1; color: var(--ink); flex: none; }
  .stepper button:active { background: #e6e6e0; }
  .stepper input { flex: 1; min-width: 0; border: none; text-align: center; font-size: 16px; height: 44px; padding: 0; -moz-appearance: textfield; }
  .stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
  .ic-total { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--hairline); padding-top: 10px; font-weight: 700; font-size: 16px; }
  .ic-total .o_amount { color: var(--brand); font-variant-numeric: tabular-nums; }
  .order-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .order-btns { display: flex; gap: 10px; }
  .order-summary { font-size: 14px; color: var(--ink-2); }
  .order-summary b { color: var(--brand); font-size: 17px; font-variant-numeric: tabular-nums; }

  /* ===== 汉堡按钮与移动侧栏遮罩 ===== */
  .hamburger { display: none; background: none; border: none; font-size: 22px; color: var(--ink); line-height: 1; padding: 4px 8px; }
  .sidebar-bg { display: none; position: fixed; inset: 0; background: rgba(11,11,11,0.4); z-index: 60; }

  /* ===== 移动端（手机优先，≤768px） ===== */
  @media (max-width: 768px) {
    body { font-size: 15px; }
    .hamburger { display: none; }               /* 手机改用底部 tabbar */
    .sidebar {
      position: fixed; left: 0; top: 0; bottom: 0; z-index: 70;
      width: 264px; flex: 0 0 264px;
      transform: translateX(-100%); transition: transform 0.25s ease;
    }
    #app.nav-open .sidebar { transform: translateX(0); }
    #app.nav-open .sidebar-bg { display: block; }

    .main { width: 100%; }
    .topbar { height: 52px; flex: 0 0 52px; padding: 0 16px; }
    .topbar .title { font-size: 16px; }
    .content { padding: 14px 14px 24px; }

    .login-card { width: calc(100vw - 32px); }

    /* 指标卡片两列 */
    .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .tile { padding: 14px; }
    .tile .value { font-size: 22px; }
    .form-grid { grid-template-columns: 1fr; }

    /* 列表表格 → 卡片 */
    table.as-cards { display: block; width: 100%; }
    table.as-cards thead { display: none; }
    table.as-cards tbody { display: block; }
    table.as-cards tr { display: block; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 4px 14px; background: var(--surface); box-shadow: var(--shadow); }
    table.as-cards tbody tr:hover { background: var(--surface); }
    table.as-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--hairline); text-align: right; }
    table.as-cards td:last-child { border-bottom: none; }
    table.as-cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex: 0 0 82px; text-align: left; font-weight: 500; }
    table.as-cards td.row-actions, table.as-cards td[data-label=""] { display: block; text-align: right; border-top: 1px dashed var(--hairline); padding-top: 10px; }
    table.as-cards td.row-actions::before, table.as-cards td[data-label=""]::before { display: none; }
    table.as-cards td.row-actions .link, table.as-cards td[data-label=""] .link { display: inline-block; padding: 7px 12px; margin-left: 6px; font-size: 14px; }

    /* 弹窗 → 底部全屏面板 */
    .modal-bg { align-items: flex-end; }
    .modal { width: 100% !important; max-width: 100% !important; max-height: 96vh; border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
    .modal h3 { font-size: 17px; padding-right: 32px; }
    .modal-close { display: block; position: absolute; top: 16px; right: 14px; width: 32px; height: 32px; border: none; background: var(--surface-2); border-radius: 50%; font-size: 15px; color: var(--ink-2); }
    .modal .foot { flex-wrap: wrap; }
    .modal .foot .btn { flex: 1; min-width: 96px; padding: 12px 16px; font-size: 15px; }

    /* 表单与按钮加大触控 */
    .form-grid input, .form-grid select, .toolbar input, .toolbar select { min-height: 44px; font-size: 15px; }
    .btn { min-height: 40px; padding: 9px 16px; font-size: 14px; }
    .toolbar { gap: 8px; }
    .toolbar input { width: 100% !important; }
    .toolbar .btn { flex: 1; }
    .toolbar .spacer { display: none; }

    /* 底部 tabbar */
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 58px; background: var(--surface); border-top: 1px solid var(--border); z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
    .tb-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); cursor: pointer; }
    .tb-item .tb-ic { font-size: 20px; line-height: 1; }
    .tb-item .tb-label { font-size: 11px; }
    .tb-item.active { color: var(--brand); font-weight: 600; }

    .toast { left: 14px; right: 14px; top: auto; bottom: 76px; text-align: center; }
  }
