/* HOU 页面共用的 iOS / macOS 风格组件。颜色都走变量，深色模式只改变量。 */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f9f9fb;
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .08);
  --seg-on: #ffffff;
  --sep: rgba(60, 60, 67, .16);
  --text: #1c1c1e;
  --muted: rgba(60, 60, 67, .62);
  --faint: rgba(60, 60, 67, .3);
  --blue: #007aff;
  --green: #248a3d;
  --green-bar: #34c759;
  --orange: #c93400;
  --orange-bar: #ff9500;
  --red: #d70015;
  --red-bar: #ff3b30;
  --tint-blue: rgba(0, 122, 255, .12);
  --tint-green: rgba(52, 199, 89, .16);
  --tint-orange: rgba(255, 149, 0, .16);
  --tint-red: rgba(255, 59, 48, .12);
  --material: rgba(242, 242, 247, .78);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, .18);
  --radius: 14px;
  --radius-lg: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Segoe UI Variable Display", "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #232325;
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .16);
    --seg-on: #636366;
    --sep: rgba(84, 84, 88, .6);
    --text: #f2f2f7;
    --muted: rgba(235, 235, 245, .6);
    --faint: rgba(235, 235, 245, .3);
    --blue: #0a84ff;
    --green: #30d158;
    --green-bar: #30d158;
    --orange: #ff9f0a;
    --orange-bar: #ff9f0a;
    --red: #ff453a;
    --red-bar: #ff453a;
    --tint-blue: rgba(10, 132, 255, .2);
    --tint-green: rgba(48, 209, 88, .18);
    --tint-orange: rgba(255, 159, 10, .2);
    --tint-red: rgba(255, 69, 58, .2);
    --material: rgba(22, 22, 24, .78);
    --shadow: none;
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); scroll-padding-top: calc(56px + env(safe-area-inset-top)); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; font-feature-settings: "kern"; letter-spacing: -.003em;
  animation: hou-enter .28s var(--ease) backwards;
}
h1, h2, .kpi strong { font-family: var(--font-display); }
svg { shape-rendering: geometricPrecision; }
img { image-rendering: auto; }
button, [role=button], .seg, .chip, .nav-back { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
a, button, input, select, textarea { touch-action: manipulation; }
@keyframes hou-enter { from { opacity: 0; } }
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: hou-vt-out .22s var(--ease) both; }
::view-transition-new(root) { animation: hou-vt-in .38s var(--ease-out) both; }
@keyframes hou-vt-out { to { opacity: 0; } }
@keyframes hou-vt-in { from { opacity: 0; transform: translateY(8px); } }
::selection { background: color-mix(in srgb, var(--blue) 28%, transparent); }
a { color: var(--blue); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: none; opacity: .8; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; border-radius: 8px; }
.num, strong, .kpi strong { font-variant-numeric: tabular-nums; }

/* 顶部导航：滚动时半透明毛玻璃，左返回、右操作，下面大标题。 */
.nav {
  position: sticky; top: 0; z-index: 30;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.nav-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: var(--page, 1100px); min-height: 44px; margin: 0 auto; }
.nav-back { display: inline-flex; align-items: center; gap: 2px; font-size: 17px; font-weight: 400; white-space: nowrap; }
.nav-back::before { content: ""; width: 10px; height: 10px; margin-right: 4px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(45deg); border-radius: 1px; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.title-block { max-width: var(--page, 1100px); margin: 0 auto; padding: 6px max(16px, env(safe-area-inset-left)) 10px; }
.title-block h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.022em; line-height: 1.15; word-break: break-all; }
.title-block p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .01em; }

.page { max-width: var(--page, 1100px); margin: 0 auto; padding: 4px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

/* 分段控件：所有选项等宽、一行排开；数字放在第二行小字。 */
.seg {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
  padding: 2px; border-radius: 9px; background: var(--fill); max-width: 100%;
}
.seg.full { display: grid; width: 100%; }
.seg button {
  position: relative; min-width: 0; padding: 6px 12px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text); font: inherit; font-size: 13px; font-weight: 500; line-height: 1.25; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .28s var(--ease), box-shadow .28s var(--ease), opacity .15s var(--ease);
}
.seg button small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg button small.bad { color: var(--red); font-weight: 600; }
.seg button.on { background: var(--seg-on); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.seg button:not(.on):hover { background: var(--fill-2); }
.seg button:active { opacity: .7; }

/* 分组列表（inset grouped）。 */
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 22px 16px 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.section-title b { color: var(--text); font-size: 15px; font-weight: 600; }
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.group + .group { margin-top: 12px; }
.cell { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 11px 16px; position: relative; }
.cell + .cell::before, .group > .cell-sep + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
a.cell, button.cell { color: inherit; font-weight: inherit; width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
a.cell, button.cell { transition: background .3s var(--ease); }
a.cell:hover, button.cell:hover { background: var(--fill-2); opacity: 1; }
a.cell:active, button.cell:active { background: var(--fill); transition-duration: 0s; }
.cell .grow { flex: 1; min-width: 0; }
.cell .sub { margin-top: 2px; color: var(--muted); font-size: 13px; word-break: break-word; }
.chev::after { content: ""; flex: none; width: 7px; height: 7px; margin-left: 4px; border-right: 2px solid var(--faint); border-top: 2px solid var(--faint); transform: rotate(45deg); }

/* 按钮。 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 16px;
  border: 0; border-radius: 10px; background: var(--blue); color: #fff; font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: opacity .2s var(--ease), transform .35s var(--spring), background .2s var(--ease);
}
.btn.tinted { background: var(--tint-blue); color: var(--blue); }
.btn.gray { background: var(--fill); color: var(--text); }
.btn.sm { min-height: 28px; padding: 0 11px; border-radius: 999px; font-size: 13px; }
.btn.lg { min-height: 44px; border-radius: 12px; font-size: 17px; }
.btn:hover { opacity: .88; }
.btn:active { opacity: .6; transform: scale(.97); transition-duration: .08s; }
.btn:disabled { opacity: .35; cursor: default; }

/* 小标签。 */
.chip {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 600; line-height: 18px; vertical-align: 1px; white-space: nowrap;
}
.chip.blue, .chip.vc, .chip.wait { background: var(--tint-blue); color: var(--blue); }
.chip.green, .chip.done { background: var(--tint-green); color: var(--green); }
.chip.orange, .chip.go { background: var(--tint-orange); color: var(--orange); }
.chip.red, .chip.sfp, .chip.late { background: var(--red-bar); color: #fff; }
.chip.warn { background: var(--tint-red); color: var(--red); }
.chip.warn::before { content: "!"; display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; background: var(--red-bar); color: #fff; font-size: 10px; font-weight: 800; }

/* 搜索框。 */
.search-field { display: flex; align-items: flex-start; gap: 8px; min-height: 40px; padding: 9px 12px; border-radius: 11px; background: var(--fill); }
.search-field::before {
  content: ""; flex: none; width: 15px; height: 15px; margin-top: 3px; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search-field textarea, .search-field input {
  flex: 1; min-width: 0; max-height: 140px; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.4; outline: none; resize: none; field-sizing: content;
}
.search-field textarea::placeholder, .search-field input::placeholder { color: var(--muted); }
.search-row { display: flex; gap: 8px; align-items: flex-start; }
.search-row .search-field { flex: 1; min-width: 0; }
.search-row .btn { min-height: 40px; }

/* 指标卡。 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi strong { display: block; margin-top: 2px; font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.red strong { color: var(--red); }
.kpi.orange strong { color: var(--orange); }
.kpi.green strong { color: var(--green); }

/* 进度条。 */
.track { height: 5px; margin-top: 5px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width .6s var(--ease-out); }
.track i.green { background: var(--green-bar); }
.track i.orange { background: var(--orange-bar); }
.track i.red { background: var(--red-bar); }
.track i.grey { background: var(--faint); }

.meta { margin: 10px 4px 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty { padding: 36px 20px; border-radius: var(--radius); background: var(--card); color: var(--muted); text-align: center; box-shadow: var(--shadow); }
.loading { padding: 36px 20px; color: var(--muted); text-align: center; }
.loading::before { content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 10px; border-radius: 50%; border: 2.5px solid var(--fill); border-top-color: var(--muted); animation: hou-spin .8s linear infinite; }
@keyframes hou-spin { to { transform: rotate(360deg); } }

/* 表格（桌面），手机上各页自己转成卡片。 */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: top; border-top: .5px solid var(--sep); }
.table thead th { border-top: 0; background: var(--card-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.table tbody tr:hover td { background: var(--fill-2); }

/* 弹出卡片：桌面右上浮层，手机底部抽屉。 */
.sheet {
  position: fixed; z-index: 60; top: 72px; right: 20px; width: min(380px, calc(100% - 32px));
  max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); overflow: auto; overscroll-behavior: contain; padding: 16px 18px; border-radius: 16px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-pop); animation: hou-pop .32s var(--spring);
}
.sheet h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
.sheet .kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-variant-numeric: tabular-nums; }
.sheet .kv + .kv { border-top: .5px solid var(--sep); }
.sheet .kv span { color: var(--muted); }
.sheet p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
@keyframes hou-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes hou-rise { from { transform: translateY(100%); } }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .nav-back { min-height: 44px; min-width: 0; }
  .nav .eyebrow { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .title-block h1 { font-size: 26px; display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; row-gap: 2px; }
  .title-block p { font-size: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; border-radius: var(--radius); min-width: 0; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi strong { font-size: 24px; overflow-wrap: anywhere; }
  .seg { display: grid; width: 100%; }
  .seg button { min-height: 44px; padding: 6px 4px; font-size: 13px; white-space: normal; }
  .btn, .btn.sm, .search-row .btn { min-height: 44px; }
  .btn.sm { padding: 0 12px; }
  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 70vh; max-height: 70dvh; border-radius: 16px 16px 0 0;
    padding: 10px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); animation: hou-rise .5s var(--spring);
  }
  .sheet::before { content: ""; display: block; width: 36px; height: 5px; margin: 0 auto 12px; border-radius: 999px; background: var(--faint); }
  .table tbody tr:hover td { background: transparent; }
}
/* 长列表只绘制屏幕附近的行，几百行时滚动也不掉帧。 */
.orow, .group > .cell, .group > .person { content-visibility: auto; contain-intrinsic-size: auto 64px; }

/* iOS 会把字号小于 16px 的输入框在聚焦时自动放大页面。 */
@media (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select { font-size: 16px !important; }
  /* 苹果触控最小点击区 44pt；行内链接只扩大点击区，不改变排版。 */
  .nav-back, .btn { min-height: 44px; }
  .cost-btn, .btn.sm, a.wms { position: relative; }
  .cost-btn::after, .btn.sm::after, a.wms::after { content: ""; position: absolute; inset: -8px -3px; }
  .seg button { min-height: 36px; }
  .no > a, a.ib-no, a.wms, td a { padding-block: 12px; margin-block: -12px; }
}
/* 触屏没有悬停，hover 样式会在点过之后一直留着。 */
@media (hover: none) {
  a:hover { opacity: 1; }
  .btn:hover { opacity: 1; }
  a.cell:hover, button.cell:hover, .seg button:not(.on):hover, .table tbody tr:hover td { background: transparent; }
  a:active { opacity: .55; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
