/* ============================================================================
   Hayward Sales OS — v3
   Built to feel like an iPhone app on an iPhone and a Mac app on a Mac: system
   type, grouped inset lists, a floating glass tab bar, sheets for small tasks,
   pages that swap in place. Status colour is the client's own law — green PO
   won, yellow on hold, red lost — and the brand green is never a control.
   See docs/design.md.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:        #F2F4F7;
  --surface:   #FFFFFF;
  --surface-2: #F7F8FA;
  --fill:      rgba(120, 120, 128, .12);
  --fill-2:    rgba(120, 120, 128, .08);
  --fill-3:    rgba(120, 120, 128, .18);

  --label:   #000000;
  --label-2: rgba(60, 60, 67, .62);
  --label-3: rgba(60, 60, 67, .34);
  --hair:    rgba(60, 60, 67, .16);
  --hair-2:  rgba(60, 60, 67, .28);

  /* The droplet in the mark. Text on white uses the deeper step. */
  --tint:        #0A7AC0;
  --tint-ink:    #0A6BA8;
  --tint-soft:   #E5F2FA;
  --tint-strong: #1AA0E0;
  --tint-deep:   #075A8C;

  --won:  #1E8A4E; --won-bg:  #E3F5EA; --won-ink:  #146B3B;
  --hold: #C7791A; --hold-bg: #FDF1DC; --hold-ink: #8A5A0E;
  --lost: #D0342C; --lost-bg: #FCE8E6; --lost-ink: #A32A23;
  --open: var(--tint); --open-bg: var(--tint-soft); --open-ink: var(--tint-ink);

  --fill-won: #1E8446; --fill-open: #1C6FA8; --fill-hold: #E0A800; --fill-lost: #BE2F20;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue",
          "Segoe UI", Roboto, Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino", "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --cjk: "PingFang SC", "PingFang TC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;

  /* iOS text styles */
  --t-large: 34px; --t-title1: 28px; --t-title2: 22px; --t-title3: 20px;
  --t-head: 17px; --t-body: 17px; --t-callout: 16px; --t-sub: 15px;
  --t-foot: 13px; --t-cap: 12px; --t-cap2: 11px;
  --lh: 1.35;

  --r-card: 14px; --r-ctl: 12px; --r-sm: 9px;
  --gutter: 16px;
  --cell-y: 12px;
  --maxw: 700px;

  --bar-h: 50px;
  --tabs-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --sh-float: 0 10px 34px rgba(16, 32, 44, .16), 0 1px 0 rgba(255, 255, 255, .6) inset;
  --sh-sheet: 0 -8px 40px rgba(16, 32, 44, .22);
  --glass: rgba(246, 248, 250, .82);
  --glass-line: rgba(60, 60, 67, .14);
}

/* Teresa reads across a room: every step grows, less fits on screen. */
[data-density="roomy"] {
  --t-large: 38px; --t-title1: 32px; --t-title2: 26px; --t-title3: 23px;
  --t-head: 20px; --t-body: 20px; --t-callout: 19px; --t-sub: 17.5px;
  --t-foot: 15.5px; --t-cap: 14px; --t-cap2: 13px;
  --cell-y: 15px; --tabs-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--sans); font-size: var(--t-body); line-height: var(--lh);
  color: var(--label); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: var(--t-title1); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: var(--t-title3); }
h3 { font-size: var(--t-head); }
p { margin: 0 0 .6em; } p:last-child { margin-bottom: 0; }
a { color: var(--tint-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 45%, transparent); outline-offset: 2px; border-radius: 8px; }
.sym { flex: none; vertical-align: -.2em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.zh { font-family: var(--cjk); }

/* ── shell ──────────────────────────────────────────────────────────────── */
.shell {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--gutter) calc(var(--tabs-h) + var(--safe-b) + 40px);
}
#page { min-height: 60vh; }
/* Signed out (the sign-in page): no tab bar and no sidebar to leave room for. */
.shell.bare { padding-bottom: 0; }

/* Navigation bar: glass, sticky, the compact title fades in once the large
   title has scrolled away. */
.appbar {
  position: sticky; top: 0; z-index: 50;
  padding-top: var(--safe-t);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.appbar.stuck { border-bottom-color: var(--glass-line); }
.appbar-in {
  max-width: var(--maxw); margin: 0 auto; height: var(--bar-h);
  padding: 0 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
}
.appbar .lead { display: flex; align-items: center; gap: 4px; justify-self: start; }
.appbar .trail { display: flex; align-items: center; gap: 4px; justify-self: end; }
.appbar .mini {
  min-width: 0; text-align: center; font-size: var(--t-head); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw;
  opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .2s var(--ease-out);
}
.appbar.stuck .mini { opacity: 1; transform: none; }

/* Bar buttons: a symbol, 44pt of finger. */
.tb {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: var(--tint-ink); cursor: pointer;
  transition: background .15s ease, transform .15s var(--ease);
}
.tb:hover { background: var(--fill-2); text-decoration: none; }
.tb:active { transform: scale(.9); background: var(--fill); }
.tb::before { content: ""; position: absolute; inset: -2px; }
.tb[data-count]:not([data-count="0"])::after {
  content: attr(data-count); position: absolute; top: 3px; right: -1px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; line-height: 16px; font-size: 10.5px;
  background: var(--lost); color: #fff; font-weight: 700; text-align: center;
  border: 2px solid var(--bg); pointer-events: none;
}
.tb-text {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; border-radius: 10px;
  font-size: var(--t-head); font-weight: 600; color: var(--tint-ink); background: transparent; border: 0; cursor: pointer;
}
.tb-text:hover { background: var(--fill-2); text-decoration: none; }
.tb-text:active { transform: scale(.96); }
.tb-text.back { padding-left: 2px; gap: 0; font-weight: 500; }
.tb.solid, .tb-text.solid { background: var(--tint); color: #fff; }
.tb.solid:hover, .tb-text.solid:hover { background: var(--tint-ink); }

.large-title { padding: 10px 0 4px; }
.large-title h1 { font-size: var(--t-large); font-weight: 700; letter-spacing: -.03em; line-height: 1.12; }
.large-title .sub { margin-top: 4px; color: var(--label-2); font-size: var(--t-sub); }

/* ── floating tab bar ───────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 10px); z-index: 60;
  height: var(--tabs-h); border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(170%) blur(22px); backdrop-filter: saturate(170%) blur(22px);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--sh-float);
}
.tabbar-in {
  height: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: stretch; padding: 4px 6px;
}
.tabbar-in a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--label-2); font-size: 10.5px; font-weight: 500; letter-spacing: -.01em; border-radius: 999px;
  transition: color .15s ease;
}
.tabbar-in a:hover { text-decoration: none; }
.tabbar-in a .tico { display: grid; place-items: center; width: 34px; height: 30px; }
.tabbar-in a .tico .on { display: none; }
.tabbar-in a[aria-current="page"] { color: var(--tint-ink); }
.tabbar-in a[aria-current="page"] .tico .on { display: block; }
.tabbar-in a[aria-current="page"] .tico .off { display: none; }
.tabbar-in a:active .tico { transform: scale(.88); }
.tabbar-in a .tico { transition: transform .15s var(--ease); }
[data-density="roomy"] .tabbar-in a { font-size: 12px; }
.tabbar .navbrand, .tabbar .navuser { display: none; }

/* ── grouped lists ──────────────────────────────────────────────────────── */
.group-title {
  margin: 22px 0 7px; padding: 0 2px;
  font-size: var(--t-sub); font-weight: 600; color: var(--label-2); letter-spacing: -.005em;
  display: flex; align-items: baseline; gap: 10px;
}
.group-title h2 { font-size: inherit; font-weight: inherit; flex: 1 1 auto; min-width: 0; }
.group-title .aside { font-size: var(--t-foot); font-weight: 500; color: var(--label-3); white-space: nowrap; }
.group-title .aside a { font-weight: 600; }
.group-title:first-child, .large-title + .group-title { margin-top: 12px; }
.group {
  background: var(--surface); border-radius: var(--r-card); overflow: hidden;
  border: 1px solid rgba(60, 60, 67, .06);
}
.group + .group { margin-top: 14px; }
.group-foot { padding: 7px 6px 0; font-size: var(--t-foot); color: var(--label-3); }
.group > .pad { padding: 14px var(--gutter); }
.group .pad + .pad, .group .cell + .pad, .group .pad + .cell { border-top: 1px solid var(--hair); }

/* A cell: an optional leading symbol, the words, then whatever sits on the
   right — a status, a number, a chevron. Text wraps; nothing scrolls sideways. */
.cell {
  position: relative; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center;
  padding: var(--cell-y) var(--gutter); color: inherit; min-height: 52px;
  transition: background .12s ease;
}
.cell.lead { grid-template-columns: auto 1fr auto; }
.cell + .cell { border-top: 1px solid var(--hair); }
.cell + .cell.lead { border-top: none; }
.cell + .cell.lead::before { content: ""; position: absolute; left: calc(var(--gutter) + 44px); right: 0; top: 0; height: 1px; background: var(--hair); }
a.cell:hover { text-decoration: none; background: var(--surface-2); }
a.cell:active, .cell.link:active { background: var(--fill-2); }
.cell .ico {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--tint-soft); color: var(--tint-ink); flex: none;
}
.cell .ico.won { background: var(--won-bg); color: var(--won-ink); }
.cell .ico.hold { background: var(--hold-bg); color: var(--hold-ink); }
.cell .ico.lost { background: var(--lost-bg); color: var(--lost-ink); }
.cell .ico.grey { background: var(--fill); color: var(--label-2); }
.cell .main { min-width: 0; }
.cell .t, .cell .s { display: block; }
.cell .t a { color: inherit; }
.cell .t { font-size: var(--t-body); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.cell .t small { font-weight: 400; color: var(--label-2); }
.cell .s { margin-top: 2px; font-size: var(--t-sub); color: var(--label-2); line-height: 1.3; overflow-wrap: anywhere; }
.cell .m { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: var(--t-foot); color: var(--label-3); align-items: center; }
.cell .m b { font-weight: 500; color: var(--label-2); }
.cell .tr { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; text-align: right; }
.cell .tr .ibtn { width: 34px; height: 34px; }
.cell .tr .v { font-size: var(--t-body); color: var(--label-2); }
.cell .tr .v.strong { color: var(--label); font-weight: 600; }
.cell .chev { color: var(--label-3); margin-right: -4px; }
.cell .acts { grid-column: 1 / -1; margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cell .acts .ibtn { width: 34px; height: 34px; }
.cell .acts:empty { display: none; }
.cell .said { grid-column: 1 / -1; margin-top: 6px; font-size: var(--t-sub); color: var(--label-2); }
.cell.tall { align-items: start; }

/* The round tinted buttons beside a person: call, WhatsApp, email. */
.ibtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--tint-soft); color: var(--tint-ink); border: 0; cursor: pointer; flex: none;
  transition: transform .15s var(--ease), background .15s ease;
}
.ibtn:hover { background: color-mix(in srgb, var(--tint) 20%, white); text-decoration: none; }
.ibtn:active { transform: scale(.9); }
.ibtn.wa { background: #E3F5EA; color: #167A43; }
.ibtn.wa:hover { background: #D2EEDD; }
.ibtn.muted { background: var(--fill-2); color: var(--label-3); }
.ibtn-row { display: inline-flex; gap: 8px; align-items: center; }
.ibtn-row .num { font-size: var(--t-sub); color: var(--label-2); }
/* A wide button with a symbol and a word, for the record pages. */
.abtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 1 1 0; min-width: 0;
  padding: 10px 8px; border-radius: var(--r-ctl); background: var(--tint-soft); color: var(--tint-ink);
  font-size: var(--t-sub); font-weight: 600; border: 0; cursor: pointer; text-align: center;
  transition: transform .15s var(--ease), background .15s ease;
}
.abtn:hover { text-decoration: none; background: color-mix(in srgb, var(--tint) 18%, white); }
.abtn:active { transform: scale(.96); }
.abtn.wa { background: #E3F5EA; color: #167A43; }
.abtn.muted { background: var(--fill-2); color: var(--label-3); pointer-events: none; }
.abtn-row { display: flex; gap: 8px; }

/* ── tags, dots ─────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: var(--t-foot); font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.tag.win  { background: var(--won-bg);  color: var(--won-ink); }
.tag.warn { background: var(--hold-bg); color: var(--hold-ink); }
.tag.lost { background: var(--lost-bg); color: var(--lost-ink); }
.tag.info { background: var(--tint-soft); color: var(--tint-ink); }
.tag.neutral { background: var(--fill); color: var(--label-2); }
.tag.solid { background: var(--tint); color: #fff; }
.tag.lead { background: #EEE7FB; color: #5B3BA6; }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-foot); color: var(--label-2); }
.cat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--hue) var(--sat, 46%) 50%); flex: none; }
.quiet-bar { display: inline-block; vertical-align: middle; height: 4px; width: 56px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.quiet-bar i { display: block; height: 100%; background: var(--tint); border-radius: 2px; }
.quiet-bar.warm i { background: var(--hold); }
.quiet-bar.cold i { background: var(--lost); }
.mono { font-family: var(--mono); font-size: .92em; }
.dim { color: var(--label-3); }
.sub { color: var(--label-2); font-size: var(--t-sub); }
.foot { color: var(--label-3); font-size: var(--t-foot); }

/* ── the Today card: the one loud surface ───────────────────────────────── */
.today {
  position: relative; margin-top: 14px; padding: 22px var(--gutter) 20px;
  background: var(--surface); border-radius: 18px; overflow: hidden;
  border: 1px solid rgba(60, 60, 67, .06);
}
.today::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, #9EDDF6 0%, var(--tint-strong) 40%, #7ED3F7 70%, #C7ECF8 100%);
}
.today::after {
  content: ""; position: absolute; inset: 5px 0 auto 0; height: 150px; pointer-events: none;
  background: radial-gradient(60% 100% at 12% 0%, rgba(26, 160, 224, .14), transparent 70%),
              radial-gradient(50% 90% at 90% 0%, rgba(126, 211, 247, .2), transparent 70%);
}
.today > * { position: relative; }
.today .eyebrow { font-size: var(--t-foot); font-weight: 600; color: var(--tint-ink); margin-bottom: 8px; letter-spacing: .01em; }
.today .say { font-family: var(--serif); font-weight: 400; letter-spacing: -.012em; font-size: clamp(27px, 7.4vw, 40px); line-height: 1.12; max-width: 18ch; }
.today .say b { font-weight: 600; }
.today .say-zh { font-family: var(--cjk); font-size: clamp(17px, 4.6vw, 24px); font-weight: 500; margin-top: 6px; color: var(--label-2); }
.today .under { margin-top: 10px; color: var(--label-2); font-size: var(--t-sub); max-width: 46ch; }
.today .btnrow { margin-top: 14px; }

/* PO alert: the only thing that arrives on its own. */
.alertband {
  display: flex; gap: 12px; align-items: center; margin-top: 14px; padding: 14px var(--gutter);
  border-radius: var(--r-card); color: #fff;
  background: linear-gradient(120deg, var(--tint-deep), var(--tint) 60%, var(--tint-strong));
  box-shadow: 0 8px 26px rgba(10, 122, 192, .28);
  animation: rise .4s var(--ease-out) both;
}
.alertband .pulse { width: 10px; height: 10px; border-radius: 50%; background: #fff; flex: none; box-shadow: 0 0 0 0 rgba(255, 255, 255, .6); animation: pulse 2.2s ease-out infinite; }
.alertband h2 { font-size: var(--t-head); color: #fff; }
.alertband p { margin: 2px 0 0; font-size: var(--t-sub); opacity: .9; }
.alertband .go { margin-left: auto; flex: none; background: #fff; color: var(--tint-ink); }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── stats ──────────────────────────────────────────────────────────────── */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-top: 14px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat {
  display: block; color: inherit; background: var(--surface); border-radius: var(--r-card); padding: 13px 14px 12px;
  border: 1px solid rgba(60, 60, 67, .06); transition: transform .15s var(--ease);
}
a.stat:hover { text-decoration: none; background: var(--surface-2); }
a.stat:active { transform: scale(.97); }
.stat .n { display: block; font-size: var(--t-title1); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; }
.stat .k { display: block; margin-top: 3px; font-size: var(--t-foot); color: var(--label-2); font-weight: 500; }
.stat .zh { display: block; font-size: var(--t-cap); color: var(--label-3); margin-top: 1px; }
.stat .d { display: block; margin-top: 4px; font-size: var(--t-cap); font-weight: 600; }
.stat.won .n { color: var(--won-ink); } .stat.hold .n { color: var(--hold-ink); }
.stat.lost .n { color: var(--lost-ink); } .stat.open .n { color: var(--tint-ink); }
.up { color: var(--won-ink); } .down { color: var(--lost-ink); } .flat { color: var(--label-3); }

/* ── controls ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 0;
  font-size: var(--t-head); font-weight: 600; letter-spacing: -.01em;
  background: var(--tint); color: #fff; cursor: pointer; text-decoration: none;
  transition: transform .15s var(--ease), background .15s ease, opacity .15s ease;
}
.btn:hover { background: var(--tint-ink); text-decoration: none; }
.btn:active { transform: scale(.96); }
.btn.secondary { background: var(--tint-soft); color: var(--tint-ink); }
.btn.secondary:hover { background: color-mix(in srgb, var(--tint) 18%, white); }
.btn.ghost { background: var(--fill); color: var(--label); }
.btn.ghost:hover { background: var(--fill-3); }
.btn.danger { background: var(--lost-bg); color: var(--lost-ink); }
.btn.danger:hover { background: #F8D5D1; }
.btn.win { background: var(--won); color: #fff; }
.btn.sm { min-height: 36px; padding: 6px 14px; font-size: var(--t-sub); }
.btn.xs { min-height: 30px; padding: 4px 11px; font-size: var(--t-foot); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.btnrow.end { justify-content: flex-end; }
.btnrow.center { justify-content: center; }

/* Segmented control: a capsule track, the chosen segment lifted white. */
.seg {
  display: flex; flex-wrap: wrap; padding: 3px; border-radius: 12px; background: var(--fill); margin-top: 12px;
}
.seg a, .seg button {
  flex: 1 1 0; min-width: max-content; text-align: center; padding: 7px 10px; border-radius: 9px; border: 0;
  font-size: var(--t-sub); font-weight: 500; color: var(--label); background: transparent; cursor: pointer;
  white-space: nowrap; transition: background .15s ease, box-shadow .15s ease;
}
.seg a:hover { text-decoration: none; }
.seg a[aria-current="true"], .seg button[aria-current="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 3px 8px rgba(0, 0, 0, .06); }
.seg a b { font-weight: 600; color: var(--label-3); margin-left: 4px; }
.seg a[aria-current="true"] b { color: var(--label-2); }

/* Chips: quick filters that wrap, never scroll. */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chips a, .chips button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--hair); color: var(--label); font-size: var(--t-sub); font-weight: 500;
  cursor: pointer; transition: transform .15s var(--ease), background .15s ease;
}
.chips a:hover { text-decoration: none; background: var(--surface-2); }
.chips a:active { transform: scale(.95); }
.chips a[aria-current="true"], .chips button[aria-current="true"] { background: var(--label); border-color: var(--label); color: #fff; }
.chips a b { font-weight: 600; opacity: .55; }
.chips a[data-zero] { color: var(--label-3); }
.chips a .x { opacity: .5; font-size: 15px; line-height: 1; }

/* Toolbar under a title: search + filter button. */
.fbtn.desk-only { display: none; }
@media (max-width: 600px) { .seg a b { display: none; } }
.toolrow { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.search { position: relative; flex: 1 1 auto; min-width: 0; }
.search input[type=search] {
  width: 100%; height: 40px; padding: 0 34px 0 36px; border: 0; border-radius: 11px;
  background: var(--fill); color: var(--label); font: inherit; font-size: var(--t-body); -webkit-appearance: none;
  transition: box-shadow .15s ease, background .15s ease;
}
.search input[type=search]::placeholder { color: var(--label-3); }
.search input[type=search]:focus { outline: none; background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 30%, transparent), 0 0 0 1px var(--tint); }
.search input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
.search .sym { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--label-3); pointer-events: none; z-index: 1; }
.fbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 13px; border-radius: 11px; border: 0;
  background: var(--fill); color: var(--tint-ink); font-size: var(--t-sub); font-weight: 600; cursor: pointer; flex: none;
}
.fbtn:hover { background: var(--fill-3); text-decoration: none; }
.fbtn .n { min-width: 18px; height: 18px; border-radius: 9px; background: var(--tint); color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 5px; }
.applied { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.applied a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--tint-soft); color: var(--tint-ink); font-size: var(--t-foot); font-weight: 600; }
.applied a:hover { text-decoration: none; }
.applied .clear { background: transparent; color: var(--label-3); font-weight: 500; }

/* ── forms ──────────────────────────────────────────────────────────────── */
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 560px) { .fields.two { grid-template-columns: 1fr; } }
.field { min-width: 0; }
.field > label { display: block; font-size: var(--t-foot); font-weight: 600; color: var(--label-2); margin-bottom: 5px; }
.field .help { font-size: var(--t-foot); color: var(--label-3); margin-top: 5px; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=url],
input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; font: inherit; font-size: var(--t-body); color: var(--label);
  min-height: 46px; padding: 11px 13px; border: 1px solid transparent; border-radius: var(--r-ctl);
  background: var(--fill-2); -webkit-appearance: none; appearance: none;
  transition: box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--tint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 25%, transparent); }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238E8E93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1.2 1.6 6 6.4l4.8-4.8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; }
input[type=file] { border: 1px dashed var(--hair-2); background: var(--surface-2); padding: 12px; font-size: var(--t-sub); }
.inputwrap { position: relative; }
.inputwrap textarea { padding-right: 48px; }
.mic {
  position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--tint-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); cursor: pointer; display: grid; place-items: center;
}
.mic[aria-pressed="true"] { background: var(--lost); color: #fff; animation: pulse 1.6s ease-out infinite; }
.mic[hidden] { display: none; }
.optrow { display: flex; flex-wrap: wrap; gap: 7px; }
.optrow label { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 13px; border-radius: 999px; background: var(--fill-2); font-size: var(--t-sub); font-weight: 500; cursor: pointer; border: 1px solid transparent; }
.optrow input { position: absolute; opacity: 0; width: 0; height: 0; }
.optrow input:checked + span, .optrow label:has(input:checked) { background: var(--label); color: #fff; }
.optrow label:has(input:focus-visible) { outline: 2px solid var(--tint); }

/* Stage choices on a record. */
.nextstep { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nextstep .note { font-size: var(--t-sub); color: var(--label-2); flex: 1 1 100%; }
.nextstep .note b { color: var(--label); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.choices button {
  text-align: left; padding: 11px 13px; border-radius: var(--r-ctl); border: 1px solid var(--hair);
  background: var(--surface); color: var(--label-2); font-size: var(--t-sub); font-weight: 600; cursor: pointer; width: 100%;
  transition: transform .15s var(--ease), background .15s ease;
}
.choices button small { display: block; font-weight: 400; font-size: var(--t-foot); color: var(--label-3); margin-top: 2px; }
.choices button:active { transform: scale(.97); }
.choices button[disabled] { opacity: .5; cursor: not-allowed; }
.choices button[aria-pressed="true"] { border-color: var(--tint); background: var(--tint-soft); color: var(--tint-ink); }
.choices button[aria-pressed="true"].win  { border-color: var(--won-bg);  background: var(--won-bg);  color: var(--won-ink); }
.choices button[aria-pressed="true"].warn { border-color: var(--hold-bg); background: var(--hold-bg); color: var(--hold-ink); }
.choices button[aria-pressed="true"].lost { border-color: var(--lost-bg); background: var(--lost-bg); color: var(--lost-ink); }
details.fold > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: var(--t-sub); font-weight: 600; color: var(--tint-ink); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .sym { transition: transform .2s ease; }
details.fold[open] > summary .sym { transform: rotate(90deg); }
details.fold > .body { margin-top: 10px; }

/* Stage track: eight notches. */
.track { display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; }
.track li { flex: 1; min-width: 0; }
.track .bar { display: block; height: 6px; border-radius: 3px; background: var(--fill); }
.track li.done .bar { background: var(--tint); }
.track li.now .bar { background: var(--tint); box-shadow: 0 0 0 3px var(--tint-soft); }
.track li.dead .bar { background: var(--lost-bg); }
.track li.held .bar { background: var(--hold-bg); }
.track .lbl { display: none; margin-top: 6px; font-size: var(--t-cap); color: var(--label-3); line-height: 1.2; }
.track-now { margin: 9px 0 0; font-size: var(--t-sub); font-weight: 600; color: var(--tint-ink); }
.track-now span { color: var(--label-3); font-weight: 400; }

/* Facts: label over value, in a grid. */
.facts { display: grid; gap: 12px 20px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.fact .k { font-size: var(--t-foot); color: var(--label-3); }
.fact .v { font-size: var(--t-body); font-weight: 500; margin-top: 1px; overflow-wrap: anywhere; }

/* ── timeline, documents ────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 13px 0; border-top: 1px solid var(--hair); }
.timeline li:first-child { border-top: none; padding-top: 0; }
.timeline .icon { width: 30px; height: 30px; border-radius: 50%; background: var(--fill-2); display: grid; place-items: center; color: var(--label-2); }
.timeline .when { font-size: var(--t-foot); color: var(--label-3); }
.timeline .said { margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-callout); }
.timeline .then { margin-top: 5px; font-size: var(--t-sub); color: var(--tint-ink); }
@media (hover: hover) { .timeline li form { opacity: 0; transition: opacity .15s ease; } .timeline li:hover form, .timeline li:focus-within form { opacity: 1; } }
.docs { display: grid; gap: 8px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--r-ctl); background: var(--surface-2); color: inherit; transition: transform .15s var(--ease); }
.doc:hover { text-decoration: none; background: var(--fill-2); }
.doc:active { transform: scale(.985); }
.doc .sym { color: var(--tint-ink); }
.doc .kind { display: block; font-weight: 600; font-size: var(--t-sub); }
.doc .file { display: block; font-size: var(--t-foot); color: var(--label-3); overflow-wrap: anywhere; }
.doc .size { margin-left: auto; font-size: var(--t-foot); color: var(--label-3); white-space: nowrap; }

/* ── empty states ───────────────────────────────────────────────────────── */
.empty { padding: 34px var(--gutter); text-align: center; }
.empty .glyph { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; color: var(--tint-ink); background: var(--tint-soft); }
.empty .big { font-size: var(--t-title3); font-weight: 600; letter-spacing: -.015em; }
.empty p { font-size: var(--t-sub); color: var(--label-2); max-width: 36ch; margin: 5px auto 0; }
.empty .btnrow { justify-content: center; }

/* ── charts ─────────────────────────────────────────────────────────────── */
.chart { display: grid; gap: 10px; }
.chart-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; }
.chart-row .lab { font-size: var(--t-sub); color: var(--label-2); overflow-wrap: anywhere; }
.chart-row .val { font-size: var(--t-sub); font-weight: 600; text-align: right; min-width: 44px; }
.stack { display: flex; gap: 2px; height: 24px; background: var(--fill-2); border-radius: 6px; overflow: hidden; }
.stack span { display: grid; place-items: center; min-width: 2px; font-size: 11px; font-weight: 600; color: #fff; overflow: hidden; }
.stack .s-won { background: var(--fill-won); } .stack .s-open { background: var(--fill-open); }
.stack .s-hold { background: var(--fill-hold); color: #4A3600; } .stack .s-lost { background: var(--fill-lost); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; font-size: var(--t-foot); color: var(--label-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.pair { display: grid; gap: 3px; }
.pair .b { height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.pair .b.quoted { background: var(--fill-open); } .pair .b.won { background: var(--fill-won); }
@media (max-width: 560px) { .chart-row { grid-template-columns: 84px 1fr auto; gap: 9px; } .chart-row .lab { font-size: var(--t-foot); } }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 54px; }
.spark i { flex: 1 1 0; background: var(--tint-soft); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.spark i.won { background: var(--fill-won); }
.spark i.now { background: var(--tint); }

/* Date range (Insights): presets and a typed range. */
.range { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.range .field { flex: 1 1 130px; }

/* ── sheets: a small task, slid up over the page ────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet > .dim { position: absolute; inset: 0; background: rgba(0, 0, 0, .34); animation: dim .25s ease both; }
.sheet .card {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100dvh - var(--safe-t) - 24px);
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--sh-sheet);
  display: flex; flex-direction: column; animation: sheetup .34s var(--ease) both;
  padding-bottom: var(--safe-b);
}
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--hair-2); margin: 8px auto 0; flex: none; touch-action: none; }
.sheet .head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 8px 8px; flex: none; }
.sheet .head h2 { font-size: var(--t-head); text-align: center; }
.sheet .head .l { justify-self: start; } .sheet .head .r { justify-self: end; }
.sheet .body { padding: 6px var(--gutter) 20px; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet.closing .card { animation: sheetdown .22s var(--ease) both; }
.sheet.closing > .dim { animation: undim .22s ease both; }
@keyframes sheetup { from { transform: translateY(100%); } }
@keyframes sheetdown { to { transform: translateY(100%); } }
@keyframes dim { from { opacity: 0; } }
@keyframes undim { to { opacity: 0; } }
body.has-sheet { overflow: hidden; }

/* ── toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 22px); transform: translateX(-50%);
  z-index: 95; max-width: min(92vw, 520px); display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: 999px; background: rgba(28, 30, 34, .92); color: #fff;
  font-size: var(--t-sub); font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  animation: toastin .3s var(--ease) both;
}
.toast.bad { background: var(--lost); }
.toast.gone { animation: toastout .25s ease both; }
.toast .sym { color: #7ED3F7; }
.toast.bad .sym { color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes toastout { to { opacity: 0; transform: translate(-50%, 8px); } }
/* A server flash is shown as is, then app.js turns it into a toast. */
.flash { display: flex; gap: 8px; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--tint-soft); color: var(--tint-ink); font-weight: 500; font-size: var(--t-sub); }
.flash.bad { background: var(--lost-bg); color: var(--lost-ink); }

/* A row that opens a record but also carries buttons: the title link covers
   the whole cell, and the buttons sit above it. */
.cell .stretch::after { content: ""; position: absolute; inset: 0; }
.cell .tr, .cell .acts, .cell .said { position: relative; z-index: 2; }
.cell .tr .ibtn-row { pointer-events: auto; }

/* ── login ──────────────────────────────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter) 40px; }
.login .box { width: 100%; max-width: 380px; }
.login .brandmark { display: block; width: 92px; height: 92px; margin: 0 auto 14px; }
.login h1 { text-align: center; font-size: var(--t-title1); }
.login .sub { text-align: center; margin-top: 4px; }
.login .group { margin-top: 22px; }
.login .group input { background: transparent; border-radius: 0; border: 0; min-height: 50px; padding: 12px var(--gutter); }
.login .group input:focus { box-shadow: none; background: var(--surface-2); }
.login .group .row + .row { border-top: 1px solid var(--hair); }
.login .foot { text-align: center; margin-top: 18px; }
.login .err { margin-top: 14px; padding: 11px 14px; border-radius: var(--r-ctl); background: var(--lost-bg); color: var(--lost-ink); font-size: var(--t-sub); font-weight: 500; }

/* ── more / settings menus ──────────────────────────────────────────────── */
.menu a { min-height: 50px; }
.menu .ico { width: 30px; height: 30px; border-radius: 8px; color: #fff; background: var(--tint); }
.menu .ico.g { background: #8E8E93; } .menu .ico.gr { background: #34A853; } .menu .ico.o { background: #F09A19; } .menu .ico.r { background: var(--lost); } .menu .ico.p { background: #6B4FD0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff; background: linear-gradient(140deg, var(--tint-strong), var(--tint-deep)); flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 12.5px; }

/* ── board (desktop pipeline) ───────────────────────────────────────────── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-top: 14px; }
.board .col { background: var(--fill-2); border-radius: var(--r-card); padding: 10px; min-height: 200px; }
.board .col h3 { font-size: var(--t-sub); font-weight: 600; color: var(--label-2); padding: 2px 4px 8px; display: flex; justify-content: space-between; }
.board .card { display: block; color: inherit; background: var(--surface); border-radius: 11px; padding: 10px 12px; margin-top: 8px; border: 1px solid rgba(60, 60, 67, .06); }
.board .card:hover { text-decoration: none; box-shadow: 0 3px 10px rgba(0, 0, 0, .08); }
.board .card .t { font-weight: 600; font-size: var(--t-sub); }
.board .card .s { font-size: var(--t-foot); color: var(--label-2); margin-top: 2px; }

/* ── drag to reorder ────────────────────────────────────────────────────── */
.sortable .cell { touch-action: pan-y; }
.sortable .grip { color: var(--label-3); padding: 6px; margin: -6px -6px -6px 0; cursor: grab; touch-action: none; border-radius: 8px; }
.cell.dragging { background: var(--surface); box-shadow: 0 8px 26px rgba(0, 0, 0, .16); z-index: 5; border-radius: var(--r-ctl); transform: scale(1.015); }
.cell.shifting { transition: transform .2s var(--ease); }

/* ── navigation feedback ────────────────────────────────────────────────── */
.navbar-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; background: var(--tint); transform-origin: 0 50%; transform: scaleX(0); opacity: 0; pointer-events: none; }
.navbar-progress.on { opacity: 1; animation: creep 8s cubic-bezier(.1, .8, .2, 1) forwards; }
@keyframes creep { 0% { transform: scaleX(0); } 30% { transform: scaleX(.55); } 70% { transform: scaleX(.85); } 100% { transform: scaleX(.96); } }

/* Pages swap in place: the new one lifts in. */
#page.entering { animation: pagein .28s var(--ease-out) both; }
#page.entering.back { animation-name: pageback; }
@keyframes pagein { from { opacity: 0; transform: translateY(10px); } }
@keyframes pageback { from { opacity: 0; transform: translateY(-6px); } }
::view-transition-old(page) { animation: vtout .16s ease both; }
::view-transition-new(page) { animation: pagein .26s var(--ease-out) both; }
[data-nav="back"]::view-transition-new(page) { animation-name: pageback; }
@keyframes vtout { to { opacity: 0; } }
#page { view-transition-name: page; }

.hr { height: 1px; background: var(--hair); border: 0; margin: 14px 0; }
.stack-y { display: grid; gap: 10px; }
.cols { display: grid; gap: 0; }
.cols > .col { min-width: 0; }
.slimrow { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px var(--gutter); background: var(--surface); border-radius: var(--r-card); font-size: var(--t-sub); color: var(--label-2); border: 1px solid rgba(60, 60, 67, .06); }
.slimrow .sym { color: var(--tint-ink); }
.slimrow a { margin-left: auto; white-space: nowrap; font-weight: 600; }
.prose { font-size: var(--t-callout); }
.prose ol, .prose ul { padding-left: 20px; line-height: 1.55; }
.prose li + li { margin-top: 4px; }
.kbd { font-family: var(--mono); font-size: .85em; background: var(--fill); padding: 1px 6px; border-radius: 5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  .appbar, .tabbar, .btnrow, .search, .toolrow, .chips, .seg, .fbtn, .navbar-progress, .toast, .sheet { display: none !important; }
  body { background: #fff; } .shell { max-width: none; padding: 0; }
  .group { border-color: #ccc; break-inside: avoid; }
}

/* ── wide screens: a sidebar instead of a tab bar ───────────────────────── */
@media (min-width: 940px) {
  :root { --maxw: 1180px; --nav-w: 250px; --gutter: 18px; }
  [data-density="roomy"] { --maxw: 1080px; --nav-w: 268px; }
  .shell { margin-left: var(--nav-w); padding: 0 28px 60px; }
  .appbar { margin-left: var(--nav-w); }
  .shell.bare { margin-left: auto; }
  .appbar-in { padding: 0 20px; }
  .appbar:not(.has-back) .mini { text-align: left; }
  .appbar:not(.has-back) .appbar-in { grid-template-columns: auto 1fr auto; }

  .tabbar {
    left: 0; right: auto; top: 0; bottom: 0; width: var(--nav-w); height: auto; border-radius: 0;
    padding: var(--safe-t) 0 0; border: 0; border-right: 1px solid var(--glass-line); box-shadow: none;
    display: flex; flex-direction: column;
  }
  .tabbar-in { height: auto; grid-auto-flow: row; grid-auto-columns: auto; align-content: start; gap: 2px; padding: 8px 12px; }
  .tabbar-in a { flex-direction: row; justify-content: flex-start; gap: 11px; padding: 9px 12px; border-radius: 10px; font-size: max(15px, var(--t-sub)); font-weight: 500; }
  .tabbar-in a .tico { width: 24px; height: 24px; }
  .tabbar-in a[aria-current="page"] { background: var(--tint-soft); font-weight: 600; }
  .tabbar-in a:hover:not([aria-current]) { background: var(--fill-2); color: var(--label); }
  .tabbar .navbrand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 10px; color: inherit; }
  .tabbar .navbrand:hover { text-decoration: none; }
  .tabbar .navbrand img { width: 34px; height: 34px; }
  .tabbar .navbrand b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
  .tabbar .navbrand span span { display: block; font-size: 12px; color: var(--label-3); }
  .tabbar .navuser { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--glass-line); color: inherit; }
  .tabbar .navuser:hover { background: var(--fill-2); text-decoration: none; }
  .tabbar .navuser b { display: block; font-size: 14.5px; font-weight: 600; }
  .tabbar .navuser span span { display: block; font-size: 12px; color: var(--label-3); }

  .large-title { padding-top: 18px; }
  .large-title h1 { font-size: 32px; }
  .stats, .stats.three { grid-template-columns: repeat(4, 1fr); }
  [data-density="roomy"] .stats { grid-template-columns: repeat(3, 1fr); }
  .today .say { font-size: clamp(30px, 2.6vw, 40px); max-width: 24ch; }

  /* Dashboards read in two columns. */
  .shell.columns { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: start; }
  .shell.columns > * { grid-column: 1 / -1; }
  .shell.columns > .sec { grid-column: auto; }
  .fbtn.desk-only { display: inline-flex; }
  /* A record page is a split view. */
  .cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); column-gap: 20px; align-items: start; }
  .track .lbl { display: block; } .track-now { display: none; }
  .sheet { align-items: center; }
  .sheet .card { border-radius: 18px; max-height: min(88vh, 760px); padding-bottom: 0; animation-name: sheetpop; }
  .sheet.closing .card { animation-name: sheetpopout; }
  @keyframes sheetpop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
  @keyframes sheetpopout { to { opacity: 0; transform: translateY(8px) scale(.98); } }
  .toast { bottom: 28px; }
}
@media (min-width: 1500px) { :root { --maxw: 1320px; } }
@media (min-width: 620px) and (max-width: 939px) { :root { --maxw: 720px; } .shell { padding-left: 24px; padding-right: 24px; } }

/* ── desktop-only sidebar links ─────────────────────────────────────────── */
.tabbar-in a.desk { display: none; }
@media (min-width: 940px) {
  .tabbar-in a.desk { display: flex; }
  /* The owner's larger type must not shrink the sidebar labels. */
  [data-density="roomy"] .tabbar-in a { font-size: max(15px, var(--t-sub)); }
}

/* ── documents ──────────────────────────────────────────────────────────── */
.dropzone { margin-top: 14px; }
.dropzone .drop {
  position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 22px 18px; border-radius: var(--r-card); background: var(--surface);
  border: 1.5px dashed color-mix(in srgb, var(--tint) 45%, transparent); color: var(--label);
  transition: background .15s ease, border-color .15s ease, transform .15s var(--ease);
}
.dropzone .drop:hover, .dropzone.over .drop { background: var(--tint-soft); border-color: var(--tint); }
.dropzone.over .drop { transform: scale(1.01); }
.dropzone .drop:active { transform: scale(.99); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--tint-soft); color: var(--tint-ink); margin-bottom: 4px; }
.dropzone .dz-t { font-size: var(--t-head); font-weight: 600; }
.dropzone .dz-s { font-size: var(--t-foot); color: var(--label-2); max-width: 46ch; }
.dropzone.sending .drop { pointer-events: none; opacity: .6; }
.dropzone:focus-within .drop { outline: 3px solid color-mix(in srgb, var(--tint) 40%, transparent); outline-offset: 2px; }

.readnote { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-ctl);
  background: var(--fill-2); color: var(--label); font-size: var(--t-sub); line-height: 1.4; }
.readnote .sym { flex: none; margin-top: 1px; color: var(--label-2); }
.readnote.ok { background: var(--won-bg); } .readnote.ok .sym { color: var(--won-ink); }
.readnote.warn { background: var(--hold-bg); } .readnote.warn .sym { color: var(--hold-ink); }
.readnote.bad { background: var(--lost-bg); } .readnote.bad .sym { color: var(--lost-ink); }
.readnote a { font-weight: 600; }

.picks { display: grid; gap: 6px; }
.pick { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--fill-2);
  cursor: pointer; font-size: var(--t-sub); line-height: 1.35; border: 1.5px solid transparent; }
.pick input { margin: 2px 0 0; accent-color: var(--tint); width: 18px; height: 18px; flex: none; }
.pick:has(input:checked) { background: var(--tint-soft); border-color: var(--tint); }
.pick .tag { margin-left: 4px; vertical-align: 1px; }
.filedon { padding: 10px 12px; border-radius: var(--r-ctl); background: var(--tint-soft); border: 1px solid var(--tint); }
.filedon .tag { margin-left: 4px; vertical-align: 1px; }
.pick .sub { font-size: var(--t-foot); }
ul.why { margin: 0; padding-left: 18px; font-size: var(--t-foot); color: var(--label-2); }
ul.why li + li { margin-top: 4px; }

table.items { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: var(--t-foot); }
table.items th { text-align: left; font-weight: 600; color: var(--label-2); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--hair); }
table.items td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--hair-2); vertical-align: top; }
table.items th:nth-child(n+2), table.items td:nth-child(n+2) { text-align: right; white-space: nowrap; }
.preview { display: block; border-radius: var(--r-ctl); overflow: hidden; background: var(--fill-2); }
.preview img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; }

.docread { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin: -2px 0 2px; padding: 0 12px 0 44px; font-size: var(--t-foot); color: var(--label-2); }
.docacts { display: flex; gap: 6px; justify-content: flex-end; margin: 2px 0 6px; }
.docacts form { margin: 0; }

/* ── sourcing: price comparison ─────────────────────────────────────────── */
.platforms { display: flex; flex-wrap: wrap; gap: 8px; }
.platforms a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  background: var(--fill-2); color: var(--label); font-size: var(--t-sub); font-weight: 600; }
.platforms a:hover { background: var(--tint-soft); color: var(--tint-ink); text-decoration: none; }
.platforms a .zh { font-weight: 500; color: var(--label-3); font-size: var(--t-cap); }
.offer .rank { display: inline-block; font-size: var(--t-cap); font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.offer .rank.low { background: var(--won-bg); color: var(--won-ink); }
.offer .rank.high { background: var(--lost-bg); color: var(--lost-ink); }
.spread { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.spread div { background: var(--fill-2); border-radius: var(--r-ctl); padding: 10px 12px; }
.spread b { display: block; font-size: var(--t-title3); letter-spacing: -.02em; }
.spread span { font-size: var(--t-foot); color: var(--label-2); }
.rangebar { position: relative; height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--fill-won), var(--fill-hold), var(--fill-lost)); margin: 14px 0 4px; }
.rangebar i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: var(--label); transform: translateX(-2px); }
@media (max-width: 560px) { .spread { grid-template-columns: 1fr 1fr; } }

/* ── duplicates ─────────────────────────────────────────────────────────── */
.dpair { display: block; }
.dpair .dhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.dpair .dhead form { margin: 0; }
.dpair .dsides { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dpair .dside { min-width: 0; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--fill-2); }
.dpair .dside a b { overflow-wrap: anywhere; }
@media (max-width: 420px) { .dpair .dsides { grid-template-columns: 1fr; } }
.btn.warnish { color: var(--hold-ink); background: var(--hold-bg); }
.cell.total { background: var(--fill-2); }

/* ── the Sales & Marketing report ───────────────────────────────────────── */
.report-head { margin-top: 12px; padding: 18px 20px; border-radius: var(--r-card); background: var(--surface); }
.report-head .k { font-size: var(--t-foot); font-weight: 600; color: var(--tint-ink); }
.report-head h1 { margin: 2px 0 4px; font-size: var(--t-title1); letter-spacing: -.02em; }
table.rtable { width: 100%; border-collapse: collapse; font-size: var(--t-foot); line-height: 1.4; }
table.rtable th { text-align: left; font-weight: 600; color: var(--label-2); padding: 6px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.rtable td { padding: 8px; border-bottom: 1px solid var(--hair-2); vertical-align: top; overflow-wrap: anywhere; }
table.rtable td:first-child, table.rtable th:first-child { padding-left: 0; }
table.rtable tr.touched td { background: color-mix(in srgb, var(--won-bg) 60%, transparent); }
table.rtable .tag { margin-top: 4px; }
.report-sec .pad { overflow-x: auto; }
table.rtable .br { display: block; }
table.rtable .c-date .m { display: none; }
/* On a phone each row becomes a few lines: who, what, what they said, what next. */
@media (max-width: 700px) {
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 10px 0; border-bottom: 1px solid var(--hair); }
  table.rtable td { border: 0; padding: 1px 0; }
  table.rtable td.c-no, table.rtable td.empty { display: none; }
  table.rtable .c-client .br { display: none; }
  table.rtable .c-client .sub::before, table.rtable .c-client .dim::before { content: ' · '; }
  table.rtable td.c-date { float: right; margin-left: 8px; width: auto; color: var(--label-3); font-size: var(--t-cap); }
  table.rtable td.c-date .m { display: inline; }
  table.rtable td.c-item { color: var(--label); }
  table.rtable td.c-feedback { color: var(--label-2); margin-top: 3px; }
  table.rtable td.c-next::before { content: 'Next: '; font-weight: 600; color: var(--label-2); }
  table.rtable td.c-when { color: var(--label-3); font-size: var(--t-cap); }
}
@media print {
  .report-head .btnrow, .chips { display: none !important; }
  table.rtable { font-size: 9pt; }
  table.rtable tr { break-inside: avoid; }
  .report-sec { break-inside: auto; }
}
details.group-fold { margin-top: 18px; }
details.group-fold > summary { font-weight: 600; }
