/* OWNER LOCK douyin-language-v6 — dotted bg · soft white cards · multi-color · LOG · odometer KPI · causal map motion */
:root {
  --bg: #F0F1F4;
  --bg-dot: #D8DCE3;
  --bg-raised: #FFFFFF;
  --bg-panel: #FFFFFF;
  --bg-hover: #F4F5F7;
  --bg-active: rgba(13, 148, 136, 0.08);
  --line: #EEF0F3;
  --line-strong: #E2E6EB;
  --brand: #0D9488;
  --brand-ink: #0F766E;
  --brand-soft: rgba(13, 148, 136, 0.12);
  --text: #111827;
  --text-dim: #4B5563;
  --muted: #9CA3AF;
  --amber: #D97706;
  --green: #059669;
  --violet: #7C3AED;
  --danger: #DC2626;
  --pink: #E11D48;
  --blue: #2563EB;
  --shadow: 0 2px 8px rgba(17, 24, 39, 0.04), 0 1px 2px rgba(17, 24, 39, 0.03);
  --shadow-lg: 0 12px 40px rgba(17, 24, 39, 0.08), 0 2px 8px rgba(17, 24, 39, 0.04);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 280ms;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

/* —— Motion —— */
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.45); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); opacity: 0.85; }
}
@keyframes mk-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--mk-glow, rgba(13, 148, 136, 0.35)), 0 1px 4px rgba(17,24,39,0.18); }
  50% { box-shadow: 0 0 0 10px rgba(13, 148, 136, 0), 0 1px 4px rgba(17,24,39,0.18); }
}
@keyframes mk-appear {
  from { transform: scale(0.35); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes mk-ring {
  0% { transform: scale(0.55); opacity: 0.6; }
  100% { transform: scale(2.8); opacity: 0; }
}
@keyframes mk-wash {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.55; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes dock-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dash-reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes log-row-in {
  from { opacity: 0; transform: translateY(-8px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 48px; }
}
@keyframes digit-roll {
  from { transform: translateY(-100%); opacity: 0.35; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes packet-fly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
}
@keyframes trail-fade {
  from { opacity: 0.55; }
  to { opacity: 0; }
}

/* —— Login —— */
#login-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: 14px 14px;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
#login-gate.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.login-shell {
  width: min(420px, 92vw);
  padding: 2.75rem 2.5rem 2.25rem;
  background: var(--bg-raised);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: fade-up 420ms var(--ease) both;
}
.login-kicker {
  margin: 0 0 0.65rem; text-align: center;
  font-size: 0.7rem; font-weight: 650; letter-spacing: 0.16em;
  color: var(--muted); text-transform: uppercase;
}
.login-shell h1 {
  margin: 0; text-align: center;
  font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em;
}
.login-sub {
  margin: 0.5rem 0 2rem; text-align: center;
  color: var(--text-dim); font-size: 1.05rem;
}
.field { margin-bottom: 1.2rem; }
.field label {
  display: block; margin-bottom: 0.4rem;
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.field input {
  width: 100%; padding: 0.9rem 1rem;
  background: var(--bg-hover); border: 1px solid transparent;
  border-radius: var(--radius-xs); outline: none; font-size: 1.05rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: #fff;
}
.btn-enter {
  width: 100%; margin-top: 0.5rem; padding: 0.95rem;
  background: var(--text); border: none;
  color: #fff; font-weight: 650; font-size: 1.05rem;
  border-radius: var(--radius-xs);
  transition: background .15s, transform .15s;
}
.btn-enter:hover { background: #000; }
.btn-enter:active { transform: scale(0.98); }
.login-error { margin: 0.9rem 0 0; color: var(--danger); font-size: 0.95rem; text-align: center; }
.login-hint { margin: 1.25rem 0 0; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* —— Dashboard shell —— */
.dashboard {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  background: transparent;
}
.dashboard.reveal { animation: dash-reveal 480ms var(--ease) both; }

.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1rem 1.35rem 0.75rem;
  background: transparent;
  border-bottom: none;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 220px; flex-shrink: 0; }
.brand-mark {
  width: 36px; height: 36px;
  background: linear-gradient(145deg, #111827 0%, #374151 100%);
  border-radius: 12px; flex-shrink: 0;
  box-shadow: var(--shadow);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 10px 9px 12px;
  border-radius: 6px;
  background: #fff;
  opacity: 0.92;
}
.brand-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.brand-sub {
  font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem;
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
}
.brand-sub .oncall {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--green); font-weight: 600;
}
.brand-sep { opacity: 0.45; }

/* —— KPI pills (odometer) —— */
.kpi-row {
  display: flex; gap: 0.55rem; flex: 1; justify-content: center; flex-wrap: wrap;
}
.kpi {
  min-width: 92px;
  padding: 0.55rem 0.85rem 0.45rem;
  background: var(--bg-raised);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-align: left;
  animation: fade-up 400ms var(--ease) both;
}
.kpi:nth-child(1) { animation-delay: 40ms; }
.kpi:nth-child(2) { animation-delay: 80ms; }
.kpi:nth-child(3) { animation-delay: 120ms; }
.kpi:nth-child(4) { animation-delay: 160ms; }
.kpi:nth-child(5) { animation-delay: 200ms; }
.kpi:nth-child(6) { animation-delay: 240ms; }
.kpi .kpi-tag {
  font-size: 0.62rem; font-weight: 650;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.15rem;
}
.kpi .v, .kpi .odo {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.85rem;
  font-weight: 700; color: var(--text);
  letter-spacing: -0.04em; line-height: 1.1;
  height: 1.15em; overflow: hidden;
  display: flex; align-items: flex-start;
}
.kpi .odo-digit {
  display: inline-block;
  height: 1.15em;
  overflow: hidden;
  position: relative;
  width: 0.62em;
  text-align: center;
}
.kpi .odo-digit > span {
  display: block;
  line-height: 1.15em;
}
.kpi .odo-digit.rolling > span {
  animation: digit-roll 420ms var(--ease) both;
}
.kpi.cyan .v, .kpi.cyan .odo, .kpi.cyan { color: var(--brand); }
.kpi.warn .v, .kpi.warn .odo, .kpi.warn { color: var(--amber); }
.kpi.hot .v, .kpi.hot .odo { color: var(--text-dim); }
.kpi.ok .v, .kpi.ok .odo, .kpi.ok { color: var(--green); }
.kpi.violet .v, .kpi.violet .odo { color: var(--violet); }
.kpi .l { display: none; }

.topbar-right { display: flex; align-items: center; gap: 0.65rem; flex-shrink: 0; }
.live-pill {
  display: flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono); font-size: 0.8rem; font-variant-numeric: tabular-nums;
  color: var(--text-dim); padding: 0.4rem 0.75rem;
  background: var(--bg-raised); border: none; border-radius: 999px;
  box-shadow: var(--shadow);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: live-pulse 1.8s ease-in-out infinite;
}
.btn-ghost {
  background: var(--bg-raised); border: none; color: var(--text-dim);
  border-radius: 999px; padding: 0.45rem 0.9rem; font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow);
  transition: color .15s, background .15s;
}
.btn-ghost:hover { color: var(--text); background: #fff; }

/* —— Main grid —— */
.main {
  display: grid;
  --rail-w: clamp(300px, 28vw, 360px);
  grid-template-columns: 1fr var(--rail-w);
  gap: 0.85rem;
  flex: 1; min-height: 0;
  padding: 0 1.15rem 0.65rem;
  position: relative;
}
.rail {
  background: transparent; border: none; border-radius: 0; box-shadow: none;
  overflow-y: auto; padding: 0;
  display: flex; flex-direction: column; gap: 0;
}
.rail-right {
  background: var(--bg-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: none;
  padding: 1.15rem 1.1rem;
  animation: slide-in-right 420ms var(--ease) both;
}

.block { padding: 0.95rem 0.1rem; border-bottom: none; }
.block + .block { border-top: 1px solid var(--line); }
.block:first-child { padding-top: 0.1rem; }
.block:last-child { padding-bottom: 0.1rem; }
.block h2 {
  margin: 0 0 0.65rem;
  font-size: 0.68rem; font-weight: 650;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.chk-stack { display: flex; flex-direction: column; gap: 0.05rem; }
.chk {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.92rem; color: var(--text);
  padding: 0.4rem 0.35rem; cursor: pointer;
  border-radius: var(--radius-xs); min-height: 2rem;
  transition: background .15s;
}
.chk:hover { background: var(--bg-hover); }
.chk input {
  accent-color: var(--brand);
  width: 16px; height: 16px; flex-shrink: 0; margin: 0; cursor: pointer;
}
.legend { display: flex; flex-direction: column; gap: 0.55rem; }
.legend-item {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 0.92rem; color: var(--text-dim); padding: 0.15rem 0;
}
.swatch {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.map-wrap {
  position: relative; min-height: 0; background: #E4E8EE;
  border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: fade-in 360ms var(--ease) both;
}
#map { position: absolute; inset: 0; }
.map-fx {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none; overflow: hidden;
}
.map-hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 4;
  font-size: 0.8rem; color: var(--text-dim);
  background: rgba(255,255,255,0.94); padding: 0.4rem 0.95rem;
  border: none; border-radius: 999px; box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap;
}

/* —— Floating filter dock (bottom-right) —— */
.map-dock {
  position: absolute;
  right: 14px; bottom: 14px; z-index: 5;
  display: flex; flex-direction: column-reverse; align-items: flex-end;
  gap: 8px;
  max-width: min(300px, calc(100% - 28px));
  pointer-events: none;
}
.map-dock > * { pointer-events: auto; }
.dock-toggle {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem;
  background: #fff; color: var(--text);
  border: none; border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem; font-weight: 650;
  transition: background .2s, color .2s, transform .15s, box-shadow .2s;
}
.dock-toggle:hover { background: var(--bg-hover); }
.dock-toggle:active { transform: scale(0.97); }
.dock-toggle[aria-expanded="true"] {
  background: var(--text); color: #fff;
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.22);
}
.dock-toggle-ico {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.dock-panel {
  width: min(280px, 86vw);
  max-height: min(48vh, 400px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: none;
  padding: 0.6rem 0.7rem 0.75rem;
  transform-origin: bottom right;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
  animation: dock-in 380ms var(--ease) both;
}
.dock-panel.is-collapsed {
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  visibility: hidden;
  pointer-events: none;
  max-height: 0; padding: 0; border: none; overflow: hidden;
}
.dock-block { padding: 0.7rem 0.1rem; }
.dock-block + .dock-block { border-top: 1px solid var(--line); }
.dock-block h2 { margin-bottom: 0.4rem; }
.dock-panel .chk { font-size: 0.88rem; min-height: 1.9rem; padding: 0.3rem 0.3rem; }

.maplibregl-ctrl-group {
  background: #fff !important; border: none !important;
  border-radius: var(--radius-xs) !important; box-shadow: var(--shadow) !important;
}
.maplibregl-ctrl-group button {
  background: transparent !important; width: 34px !important; height: 34px !important;
}
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-scale {
  background: rgba(255,255,255,0.92) !important; color: var(--text-dim) !important;
  border-color: var(--line-strong) !important; font-size: 11px !important; border-radius: 4px !important;
}

/* —— Markers: wrap is MapLibre-positioned (no transform); .mk animates inside —— */
.mk-wrap {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  /* NEVER set transform here — MapLibre owns it for lat/lng placement */
}
.mk {
  position: relative;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2.5px solid #fff; cursor: pointer;
  box-shadow: 0 1px 4px rgba(17,24,39,0.2);
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), background-color .35s var(--ease), border-color .35s var(--ease);
  animation: mk-appear 420ms var(--ease) both, mk-pulse 2.2s ease-in-out 350ms infinite;
  --mk-glow: rgba(13, 148, 136, 0.45);
  --mk-ring: var(--brand);
  z-index: 1;
}
.mk:hover { transform: scale(1.32); animation-play-state: paused; }
.mk.hot::before {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--mk-ring, var(--brand));
  pointer-events: none;
  animation: mk-ring 1.9s ease-out infinite;
}
.mk.active {
  transform: scale(1.35);
  box-shadow:
    0 0 0 3px var(--mk-ring, var(--brand)),
    0 0 0 10px color-mix(in srgb, var(--mk-ring, var(--brand)) 22%, transparent),
    0 2px 8px rgba(17,24,39,0.18);
  animation: none;
  z-index: 4;
}
.mk.active::after {
  content: "";
  position: absolute; inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--mk-ring, var(--brand)) 28%, transparent) 0%, transparent 70%);
  pointer-events: none;
  animation: mk-wash 1.6s ease-in-out infinite;
  z-index: -1;
}
.mk.recent {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mk-ring, var(--brand)) 35%, transparent), 0 1px 4px rgba(17,24,39,0.18);
}
.mk.full {
  width: 13px; height: 13px; background: transparent !important;
  border: 2.5px solid var(--violet); box-shadow: none;
  animation: mk-appear 320ms var(--ease) both;
  --mk-ring: var(--violet);
}
.mk.full.active {
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.45), 0 0 0 10px rgba(124, 58, 237, 0.15);
}
.mk.flash { animation: mk-appear 280ms var(--ease) both; }

/* Flying intel packet */
.fx-packet {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 3px;
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.7), 0 2px 8px rgba(17,24,39,0.25);
  will-change: left, top, opacity;
}
.fx-trail {
  position: absolute;
  height: 0; border-top: 1.5px dashed rgba(17,24,39,0.28);
  transform-origin: 0 0;
  pointer-events: none; z-index: 5;
  animation: trail-fade 1.4s ease-out forwards;
}

.empty-hint { color: var(--muted); font-size: 0.95rem; line-height: 1.65; padding: 0.5rem 0; }
#detail-body { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
#detail-body.detail-enter { animation: fade-up 320ms var(--ease) both; }
#detail-body .title {
  font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin-bottom: 1rem; color: var(--text);
}
#detail-body .meta { display: grid; gap: 0.6rem; font-size: 0.95rem; }
#detail-body .meta > div {
  display: grid; grid-template-columns: 5.5em 1fr; gap: 0.7rem;
  padding-bottom: 0.55rem; border-bottom: 1px solid var(--line); align-items: baseline;
}
#detail-body .meta > div:last-child { border-bottom: none; }
#detail-body .k { font-size: 0.72rem; color: var(--muted); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }

.pill {
  display: inline-block; padding: 0.2rem 0.55rem;
  font-size: 0.75rem; font-weight: 600; border-radius: 999px; border: none;
  background: var(--bg); color: var(--text-dim);
}
.pill.new { color: var(--brand); background: var(--brand-soft); }
.pill.soon { color: var(--amber); background: rgba(217,119,6,0.12); }
.pill.closed { color: var(--muted); background: #F3F4F6; }
.pill.won { color: var(--green); background: rgba(5,150,105,0.12); }
.pill.full { color: var(--violet); background: rgba(124,58,237,0.1); }

.btn-link {
  display: inline-block; margin-top: 1.1rem; padding: 0.6rem 1.05rem;
  border: none; border-radius: var(--radius-xs);
  color: #fff; text-decoration: none; font-size: 0.9rem; font-weight: 650;
  background: var(--text);
  transition: background .15s, transform .15s;
}
.btn-link:hover { background: #000; color: #fff; }

.list-block { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.list-head h2 {
  margin: 0; font-size: 0.68rem; font-weight: 650;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.count-pill {
  font-family: var(--mono); font-size: 0.85rem; font-weight: 650; color: var(--text);
  padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--bg-hover);
  transition: transform .2s var(--ease);
}
.count-pill.bump { transform: scale(1.12); }

.tender-list {
  overflow-y: auto; display: flex; flex-direction: column; gap: 0.4rem;
  max-height: calc(100vh - 420px);
}
.tender-card {
  padding: 0.85rem 0.9rem; border-radius: var(--radius-xs);
  border: none; background: var(--bg-hover); cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .15s;
  animation: fade-up 320ms var(--ease) both;
  opacity: 0;
}
.tender-card:nth-child(1) { animation-delay: 20ms; }
.tender-card:nth-child(2) { animation-delay: 45ms; }
.tender-card:nth-child(3) { animation-delay: 70ms; }
.tender-card:nth-child(4) { animation-delay: 95ms; }
.tender-card:nth-child(5) { animation-delay: 120ms; }
.tender-card:nth-child(6) { animation-delay: 145ms; }
.tender-card:nth-child(7) { animation-delay: 170ms; }
.tender-card:nth-child(8) { animation-delay: 195ms; }
.tender-card:nth-child(n+9) { animation-delay: 210ms; }
.tender-card:hover { background: #EBEDF0; transform: translateX(2px); }
.tender-card.active {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--brand), var(--shadow);
}
.tender-card .tc-estate { font-weight: 700; font-size: 1rem; color: var(--text); line-height: 1.35; }
.tender-card .tc-title {
  font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tender-card .tc-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.55rem; gap: 0.45rem;
}
.tender-card .tc-sales { font-size: 0.82rem; color: var(--text-dim); }
.sales-swatch {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 0.35rem; vertical-align: middle; border: none;
}

/* —— Visible LOG card —— */
.log-card {
  flex-shrink: 0;
  margin: 0 1.15rem 0.95rem;
  background: var(--bg-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.7rem 1rem 0.75rem;
  display: flex; flex-direction: column;
  max-height: 148px;
  min-height: 112px;
  animation: fade-up 480ms var(--ease) both;
}
.log-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 0.45rem;
}
.log-tag {
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text);
}
.log-meta {
  font-family: var(--mono); font-size: 0.68rem; color: var(--muted);
}
.log-body {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.2rem;
  flex: 1; min-height: 0;
}
.log-row {
  display: grid;
  grid-template-columns: 3.2em auto 8px 1fr;
  gap: 0.55rem; align-items: center;
  padding: 0.28rem 0.15rem;
  font-size: 0.8rem;
  animation: log-row-in 360ms var(--ease) both;
  transition: opacity 600ms var(--ease);
}
.log-row.fade { opacity: 0.35; }
.log-row .t {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--muted); font-size: 0.72rem;
}
.log-row .pill {
  justify-self: start; min-width: 3.6em; text-align: center;
  font-size: 0.68rem; padding: 0.15rem 0.45rem;
}
.log-row .dot {
  width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0;
}
.log-row .msg {
  color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-row .msg strong { color: var(--text); font-weight: 650; }

.rail::-webkit-scrollbar,
.tender-list::-webkit-scrollbar,
.dock-panel::-webkit-scrollbar,
.log-body::-webkit-scrollbar { width: 5px; }
.rail::-webkit-scrollbar-thumb,
.tender-list::-webkit-scrollbar-thumb,
.dock-panel::-webkit-scrollbar-thumb,
.log-body::-webkit-scrollbar-thumb {
  background: #D1D5DB; border-radius: 4px;
}

@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr minmax(270px, 320px); }
  .kpi { min-width: 78px; padding: 0.45rem 0.65rem 0.35rem; }
  .kpi .v, .kpi .odo { font-size: 1.55rem; }
  .brand { min-width: 170px; }
  .log-card { max-height: 130px; }
}
@media (max-width: 860px) {
  /* v9.1: stacking / drawer owned by mobile-first block below (≤1023) */
}

/* —— v6.2 relevance toggle + EV core markers + review tag —— */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #F1F3F6; border-radius: 12px; }
.seg-opt { position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: block; padding: 0.4rem 0.95rem; border-radius: 9px; font-size: 0.95rem; font-weight: 600; color: var(--text-dim); transition: background .2s, color .2s, box-shadow .2s; }
.seg-opt input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(17,24,39,0.12); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.mk.core { width: 21px; height: 21px; border-width: 3px; box-shadow: 0 0 0 3px rgba(220,38,38,0.85), 0 2px 8px rgba(17,24,39,0.25); z-index: 3; }
.mk.core::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid #DC2626; pointer-events: none; animation: mk-ring 1.6s ease-out infinite; }
.mk.core.active { box-shadow: 0 0 0 3px #DC2626, 0 0 0 12px rgba(220,38,38,0.18), 0 2px 8px rgba(17,24,39,0.2); }
.pill.core { background: rgba(220,38,38,0.1); color: #B91C1C; }
.pill.broad { background: #F1F3F6; color: var(--text-dim); }
.pill.review { background: rgba(217,119,6,0.12); color: #B45309; }

/* sales-assign · conflict corner on tender markers (minimal) */
.mk.conflict { z-index: 2; }
.mk-conflict {
  position: absolute; top: -3px; right: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #D97706; border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(180,83,9,0.35);
  pointer-events: none; z-index: 3;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 0.6rem; }
.detail-tags:empty { display: none; }

/* —— v7 · estate polygons (屋苑板塊) —— */
.map-nodata-tag {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em; color: #B45309;
  background: rgba(255,255,255,0.94); padding: 0.3rem 0.7rem;
  border-radius: 999px; box-shadow: var(--shadow); pointer-events: none;
}
.map-nodata-tag[hidden] { display: none; }
/* v8.5 visible map error state (basemap / data fetch failed) — never a silent blank */
.map-error-tag {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 4; max-width: 70%;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.03em; color: #991B1B;
  background: rgba(254,242,242,0.97); border: 1px solid #FCA5A5; padding: 0.35rem 0.8rem;
  border-radius: 8px; box-shadow: var(--shadow); pointer-events: none; text-align: center;
}
.map-error-tag[hidden] { display: none; }
.mk.solo:not(.core) { width: 11px; height: 11px; border-width: 2px; }
.kpi.estate .odo, .kpi.estate .v { color: var(--blue); }
#detail-body .micro-k { font-size: 0.7rem; color: var(--muted); font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.15rem; }
.rel-head { margin: 1rem 0 0.5rem; font-size: 0.72rem; color: var(--muted); font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; }
.rel-list { display: flex; flex-direction: column; gap: 8px; }
.rel-item {
  padding: 0.65rem 0.75rem; border-radius: var(--radius-sm); background: var(--bg-hover);
  cursor: pointer; transition: background .2s var(--ease), box-shadow .2s var(--ease);
}
.rel-item:hover { background: #fff; box-shadow: var(--shadow); }
.rel-title { font-size: 0.92rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 0.35rem; }
.rel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rel-dl { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.rel-link { margin-left: auto; font-size: 0.82rem; font-weight: 600; color: var(--text); text-decoration: none; }
.rel-link:hover { text-decoration: underline; }
.rel-link.off { color: var(--muted); font-weight: 500; }
.rel-empty { font-size: 0.9rem; color: var(--muted); padding: 0.4rem 0; }

/* —— v7 · 銷售作戰圖: estate states, ranking, rail LOG, slide-in card —— */
.est-sw-none { background: #0D9488; box-shadow: 0 0 0 2px rgba(13,148,136,0.2); }
.est-sw-open { background: #F59E0B; animation: est-swatch-pulse 1.6s ease-in-out infinite; }
.est-sw-tendered { background: #6B7280; box-shadow: inset 0 0 0 1.5px #374151; }
.est-sw-full { background: #7C3AED; }
@keyframes est-swatch-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); } 50% { box-shadow: 0 0 0 4px rgba(245,158,11,0); } }
.chk-n { margin-left: auto; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill.opp { color: #0F766E; background: rgba(13,148,136,0.14); }
.pill.soon-lite { color: #B45309; background: rgba(245,158,11,0.14); }
.score-val { float: right; font-family: var(--mono); letter-spacing: 0; color: var(--text); text-transform: none; }
.score-range { width: 100%; accent-color: var(--brand); }
.dock-more > summary {
  cursor: pointer; list-style: none; font-size: 0.68rem; font-weight: 650;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.dock-more > summary::-webkit-details-marker { display: none; }
.dock-more > summary::before { content: "＋ "; }
.dock-more[open] > summary::before { content: "－ "; }
.dock-more[open] > summary { margin-bottom: 0.4rem; }
.dock-more .block { padding: 0.6rem 0; }

/* right rail: ranking (top) + LOG (bottom) + overlay card */
.rail-right { position: relative; overflow: hidden; display: flex; flex-direction: column; }
.rank-block { flex: 1 1 54%; min-height: 0; display: flex; flex-direction: column; }
.rank-sub { font-size: 0.72rem; color: var(--muted); margin: -0.35rem 0 0.55rem; }
.rank-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.rank-row {
  display: grid; grid-template-columns: 1.8em 1fr auto; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.6rem; border-radius: var(--radius-xs); cursor: pointer;
  background: transparent; box-shadow: inset 3px 0 0 var(--rk, var(--brand));
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
  animation: fade-up 320ms var(--ease) both;
}
.rank-row:hover { background: var(--bg-hover); transform: translateX(2px); }
.rank-row.active { background: #fff; box-shadow: inset 4px 0 0 var(--rk, var(--brand)), var(--shadow); }
.rank-row.ping { animation: rank-ping 1.2s var(--ease); }
@keyframes rank-ping { 0% { background: color-mix(in srgb, var(--rk) 22%, transparent); } 100% { background: transparent; } }
.rk-n { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rk-main { min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.rk-name { font-size: 0.98rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-name .pill { font-size: 0.6rem; padding: 0.05rem 0.35rem; vertical-align: 2px; }
.rk-sub { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; }
.rk-sub .pill { font-size: 0.66rem; padding: 0.1rem 0.4rem; }
.rk-score { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; color: var(--rk, var(--text)); font-variant-numeric: tabular-nums; }

.log-card.in-rail {
  flex: 1 1 46%; min-height: 0; max-height: none; margin: 0;
  padding: 0.85rem 0.1rem 0; border-radius: 0; box-shadow: none; background: transparent;
  border-top: 1px solid var(--line); animation: none;
}
.log-card.in-rail .log-row { grid-template-columns: 3em auto 7px 1fr; gap: 0.45rem; }

.estate-card {
  position: absolute; z-index: 6;
  top: 0; right: 1.15rem; bottom: 0.65rem; left: auto;
  width: var(--rail-w, 360px);
  background: var(--bg-raised); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.2rem; overflow-y: auto;
  transform: translateX(104%); opacity: 0; visibility: hidden;
  transition: transform 420ms var(--ease), opacity 300ms var(--ease), visibility 0s linear 420ms, height 280ms var(--ease);
  box-shadow: var(--shadow-lg);
}
.estate-card.open {
  transform: translateX(0); opacity: 1; visibility: visible;
  transition: transform 420ms var(--ease), opacity 260ms var(--ease), visibility 0s, height 280ms var(--ease);
}
.ec-head-actions { display: flex; align-items: center; gap: 0.25rem; }
.ec-expand {
  display: none;
  width: 44px; height: 44px; border: none; border-radius: 50%; cursor: pointer;
  background: var(--bg-hover); color: var(--text-dim); font-size: 0.95rem;
}
.filter-sheet-head, .rank-sheet-head { display: none; }
.kpi-strip {
  display: flex; align-items: center; gap: 0.45rem;
  flex: 1 1 auto; min-width: 0; justify-content: center;
}
.kpi-fold-btn { display: none; }
.bottom-nav { display: none; }
.sheet-close-btn {
  width: 44px; height: 44px; border: none; border-radius: 50%; cursor: pointer;
  background: var(--bg-hover); color: var(--text-dim); font-size: 1rem; flex-shrink: 0;
}
.ec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.ec-head h2 { margin: 0; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ec-close {
  width: 32px; height: 32px; border: none; border-radius: 50%; cursor: pointer;
  background: var(--bg-hover); color: var(--text-dim); font-size: 0.9rem;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.ec-close:hover { background: var(--text); color: #fff; transform: rotate(90deg); }
.ec-back {
  border: none; background: none; padding: 0; margin-bottom: 0.6rem; cursor: pointer;
  font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-dim);
}
.ec-back:hover { color: var(--text); }
#detail-body .ec-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.ec-score { display: flex; align-items: baseline; gap: 0.5rem; margin: 0.1rem 0 0.8rem; }
.ec-score-v { font-family: var(--mono); font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.na { color: var(--muted); font-size: 0.85rem; }

/* ===== v7.1 — real estates data · 招標口徑 switch · missing-boundary points ===== */
.dock-block h2 .micro-k { font-size: 0.6rem; letter-spacing: 0.04em; text-transform: none; font-weight: 500; color: var(--muted); margin-left: 0.35rem; }
.missing-note { display: block; margin-top: 0.45rem; font-size: 0.66rem; color: var(--muted); }
.pm-search { width: 100%; box-sizing: border-box; margin: 0 0 0.4rem; padding: 0.3rem 0.5rem; font: inherit; font-size: 0.74rem;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; outline: none; }
.pm-search:focus { border-color: #0D9488; box-shadow: 0 0 0 3px rgba(13,148,136,0.12); }
.pm-scroll { max-height: 9.5rem; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.pm-scroll .chk[hidden] { display: none; }
.pm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-more { padding: 0.5rem 0.25rem 0.3rem; text-align: center; font-size: 0.66rem; color: var(--muted); }
.ec-basis { display: block; width: 100%; margin-top: 0.15rem; font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ec-score { flex-wrap: wrap; }
.ec-en, .ec-reason { font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.ec-reason { margin-top: 0.5rem; }
a.src { font-size: 0.6rem; color: var(--muted); text-decoration: none; border-bottom: 1px dotted currentColor; margin-left: 0.25rem; vertical-align: 1px; }
a.src:hover { color: #0D9488; }
.rel-title.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; }
.rel-item.static { cursor: default; }
.ec-basis .eb-row { display: grid; grid-template-columns: 3.2em 2.8em 1fr; gap: 0.35rem; align-items: baseline; padding: 0.12rem 0; border-top: 1px dashed var(--line); }
.ec-basis .eb-row:first-child { border-top: 0; }
.eb-k { color: var(--muted); }
.eb-v { font-family: var(--mono); font-weight: 650; color: #374151; text-align: right; }
.eb-note { font-size: 0.62rem; color: var(--muted); line-height: 1.35; }

/* —— v8: awards / EHSS 線索 / 待覆核 —— */
.pill.lead { color: #0E7490; background: rgba(6,182,212,0.14); }
.est-sw-lead { background: #06B6D4; }
.est-sw-review { background: #F59E0B; }
.aw-item .aw-meta, .lead-item .aw-meta { margin: 0 0 0.4rem; }
.aw-item .aw-meta > div, .lead-item .aw-meta > div { padding: 0.18rem 0; }
.lead-item .rel-row .rel-link + .rel-link { margin-left: 0.6rem; }

/* ===== v8.1 — rank search · plain-繁中 review block · tender id secondary · LOG click/pause ===== */
.rank-search {
  width: 100%; box-sizing: border-box; margin: -0.2rem 0 0.55rem;
  padding: 0.55rem 0.8rem; border-radius: 12px; border: 1px solid rgba(17, 24, 39, 0.1);
  background: #F8FAFC; font: inherit; font-size: 0.9rem; color: var(--text); outline: none;
}
.rank-search:focus { border-color: #0D9488; background: #fff; box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14); }
.tid { font-size: 0.66rem; color: var(--muted); opacity: 0.75; margin-left: 0.35rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.ec-review { margin: 0.6rem 0 0.2rem; display: flex; flex-direction: column; gap: 0.35rem; }
.ec-rv-row { font-size: 0.82rem; line-height: 1.45; color: var(--text); background: rgba(245, 158, 11, 0.08); border-radius: 10px; padding: 0.45rem 0.6rem; }
.ec-rv-k { font-weight: 700; color: #B45309; margin-right: 0.4rem; }
.ec-rv-row .tid { display: block; margin: 0.2rem 0 0; }
.ec-basis .eb-row { grid-template-columns: 3.4em 1fr; }
.ec-basis .eb-row .eb-note { font-size: 0.76rem; color: #374151; }
.log-row.go { cursor: pointer; }
.log-row.go:hover { background: rgba(13, 148, 136, 0.07); border-radius: 8px; }
.log-body.paused .log-row { transition: none; animation: none; }

/* v8.6 · 其他同事跟進 (excluded_from_targets) — light grey + dashed, distinct from 已招標 dark grey */
.est-sw-excluded { background: rgba(229,231,235,0.55); box-shadow: none; outline: 1.5px dashed #9CA3AF; outline-offset: -1.5px; }
.pill.excl { color: #6B7280; background: #F9FAFB; border: 1px dashed #9CA3AF; }
.ec-excl-reason { color: var(--muted); font-size: 12px; }
/* v8.6 · 聯絡 */
.ct-head { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.ct-meta { margin-top: 4px; }
.ct-meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ct-src { margin-top: 4px; }
.ct-foot { margin: 4px 0 8px; }

/* v8.6 · 找誰談 / 關鍵人物 / 聯絡 / 地點 */
.pill.tag-public { color: #0369A1; background: #E0F2FE; }
.pill.tag-sales { color: #9A3412; background: #FFEDD5; }
.pill.tag-verified { color: #166534; background: #DCFCE7; }
.pill.conf-high { color: #166534; background: #DCFCE7; }
.pill.conf-med { color: #92400E; background: #FEF3C7; }
.pill.conf-low { color: #6B7280; background: #F3F4F6; opacity: 0.85; }
.ec-primary-talk { margin: 0.5rem 0 0.25rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dm-why { margin: 4px 0; font-size: 0.85rem; }
.dm-basis { margin: 4px 0 0 1rem; padding: 0; font-size: 0.75rem; color: var(--muted); }
.dm-basis-fold { margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.dm-hint { margin-top: 2px; font-style: italic; }
.kc-hint { margin: 0.25rem 0 0.5rem; }
.kc-item .kc-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.kc-edit-btn, .kc-del-btn, .kc-copy-btn {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 6px; border: 1px solid #E5E7EB;
  background: #fff; cursor: pointer; color: var(--muted);
}
.kc-del-btn { color: #B91C1C; }
.kc-copy-btn { margin-left: 4px; }
.kc-form { display: grid; gap: 6px; margin: 8px 0; padding: 10px; border: 1px solid #E5E7EB; border-radius: 10px; background: #FAFAFA; }
.kc-form label { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); }
.kc-form input, .kc-form select, .kc-form textarea {
  font: inherit; padding: 6px 8px; border: 1px solid #E5E7EB; border-radius: 8px; background: #fff; color: inherit;
}
.kc-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.kc-form-err { color: #B91C1C; font-size: 0.75rem; }
.kc-notes { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.kc-add-btn { margin-top: 8px; }
.pill.rel-強 { color: #166534; background: #DCFCE7; }
.pill.rel-中 { color: #92400E; background: #FEF3C7; }
.pill.rel-弱, .pill.rel-未建立 { color: #6B7280; background: #F3F4F6; }
.site-item { margin-bottom: 4px; }

/* v8.7 KPI definition tooltips */
.kpi { position: relative; cursor: help; }
.kpi .kpi-tip {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translate(-50%, -4px);
  width: 300px; padding: 0.55rem 0.7rem; z-index: 60;
  background: #111827; color: #F9FAFB; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: 0.72rem; line-height: 1.45; font-weight: 450; letter-spacing: 0; text-transform: none;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 120ms, transform 120ms;
}
.kpi .kpi-tip::before { content: ""; position: absolute; top: -5px; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top: 0; border-bottom-color: #111827; }
.kpi .kpi-tip > div + div { margin-top: 0.3rem; color: #D1D5DB; }
.kpi:hover .kpi-tip, .kpi:focus-visible .kpi-tip, .kpi.tip-open .kpi-tip { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.topbar { position: relative; z-index: 50; }

/* v8.7 people sections with real data */
.ec-primary-talk { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .45rem .6rem; margin: .4rem 0 .5rem; background: #EEF2FF; border-radius: 8px; font-size: .8rem; }
.ec-primary-talk .k { font-weight: 700; color: #4338CA; }
.ec-primary-talk .pt-org { font-weight: 600; color: var(--text); }
.ec-primary-talk .ec-excl-reason { flex-basis: 100%; color: var(--muted); font-size: .72rem; }
.ec-primary-talk.none { background: #F3F4F6; }
.ec-primary-talk.none .k { color: var(--muted); }
.pill.dm-first { background: #4338CA; color: #fff; }
.dm-item.primary { box-shadow: inset 3px 0 0 #4338CA; }
.dm-item.low { opacity: .62; filter: grayscale(1); }
.dm-item.low .pill.conf-low { background: #E5E7EB; color: #4B5563; }
.ct-head .ct-ot { font-size: .7rem; color: var(--muted); }
.ct-item .ct-org, .dm-item .ct-org { font-weight: 600; font-size: .82rem; margin: .15rem 0; }
.ct-meta a, .ct-src a { color: var(--brand); text-decoration: none; }
.ct-meta a:hover { text-decoration: underline; }
.rel-more > summary { cursor: pointer; font-size: .75rem; color: var(--brand); padding: .35rem .1rem; list-style: none; }
.rel-more > summary::-webkit-details-marker { display: none; }
.rel-more > summary::before { content: "▸ "; }
.rel-more[open] > summary::before { content: "▾ "; }
/* v8.7 compact people items */
.dm-item, .ct-item { padding: .45rem .6rem !important; }
.dm-item .dm-why { font-size: .76rem; line-height: 1.4; color: var(--text-dim, #4B5563); margin: 2px 0; }
.dm-item .dm-basis-fold, .dm-item .dm-basis { font-size: .7rem; margin-top: 2px; }
.ct-meta { display: grid; grid-template-columns: 1fr; gap: 1px; font-size: .76rem; }
.ct-meta > div { display: flex; gap: .5rem; }
.ct-meta .k { flex: 0 0 2.4em; color: var(--muted); }
.ct-src { font-size: .7rem; margin-top: 2px; }
.ct-head .pill { font-size: .66rem; }

/* v8.9 業務範圍 pill (biz_category_zh) */
.pill.biz { background: #ECFDF5; color: #047857; border: 1px solid #A7F3D0; }

/* v8.9 標書文件 */
.tdocs-head{display:flex;align-items:center;gap:8px;justify-content:space-between}
.tdocs-fmt{font-size:11px;font-weight:500;color:#0369a1;text-decoration:none}
.tdocs-fmt:hover,.tdoc-orig:hover,.tdoc-ref:hover{text-decoration:underline}
.tdocs{margin:4px 0 10px;display:flex;flex-direction:column;gap:6px}
.tdoc-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
.tdoc{display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:12px;line-height:1.35}
.tdoc-local{color:#111827;text-decoration:underline;text-underline-offset:2px;flex:1 1 160px;min-width:0;word-break:break-word}
.tdoc-orig,.tdoc-ref{font-size:11px;color:#0369a1;text-decoration:none;white-space:nowrap}
.tdocs-gated{display:flex;flex-wrap:wrap;gap:4px;align-items:center}
.pill.gated{background:rgba(245,158,11,.18);color:#b45309;border:1px solid rgba(245,158,11,.45)}
.pill.gated-r{background:rgba(148,163,184,.14);color:#374151;border:1px solid rgba(148,163,184,.35)}
.pill.tdocs-pill{background:rgba(3,105,161,.08);color:#0369a1;border:1px solid rgba(3,105,161,.3)}
.pill.tdocs-pill.gated{background:rgba(245,158,11,.14);color:#b45309;border-color:rgba(245,158,11,.4)}
.tdocs-note{flex-basis:100%;font-size:11px;color:#6b7280;line-height:1.4}
.tdocs-facts{width:100%;border-collapse:collapse;font-size:12px;line-height:1.4}
.tdocs-facts th{width:88px;text-align:left;vertical-align:top;color:#6b7280;font-weight:500;padding:4px 6px 4px 0;border-top:1px solid rgba(148,163,184,.15)}
.tdocs-facts td{padding:4px 0;border-top:1px solid rgba(148,163,184,.15);color:#111827;word-break:break-word}
.tdocs-facts td a{color:#0369a1}
.tdocs-facts .na{color:#9ca3af}
.tdocs-est{border:1px solid rgba(148,163,184,.18);border-radius:8px;padding:6px 8px;margin-bottom:6px}
.tdocs-est summary{cursor:pointer;font-size:12px;color:#111827}
.tdocs-est .tid{color:#9ca3af;font-size:10px}

/* ===== v9.1 — mobile-first shell · bottom nav · sheets · desktop ≥1024 amplifies same DOM ===== */
.drawer-scrim {
  display: none;
  position: fixed; inset: 0; z-index: 70;
  background: rgba(17, 24, 39, 0.38);
  -webkit-tap-highlight-color: transparent;
}
.ec-handle {
  display: none;
  width: 44px; height: 5px; border-radius: 999px;
  background: #D1D5DB; margin: 0.45rem auto 0.2rem;
  touch-action: none;
}
.rail-collapse-btn {
  display: none;
  margin-left: auto;
  font: inherit; font-size: 0.72rem; font-weight: 650;
  color: var(--text-dim); background: var(--bg-hover);
  border: none; border-radius: 999px; padding: 0.35rem 0.75rem;
  min-height: 36px; cursor: pointer;
}

/* —— Phone + tablet: mobile-first chrome —— */
@media (max-width: 1023px) {
  html, body { height: 100%; height: 100dvh; overflow: hidden; }
  .dashboard {
    height: 100dvh;
    height: 100dvh;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: 0;
  }

  /* Topbar: grid — row1 logo+nav+logout · row2 KPI strip */
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand nav right"
      "kpi kpi kpi";
    align-items: center;
    gap: 0.35rem 0.45rem;
    padding: calc(0.4rem + env(safe-area-inset-top, 0px)) 0.7rem 0.3rem;
  }
  .brand { grid-area: brand; min-width: 0; flex: unset; gap: 0.45rem; }
  .brand-title { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-sub { display: none; }
  .brand-mark { width: 26px; height: 26px; border-radius: 8px; }
  .site-nav { grid-area: nav; margin-right: 0; order: unset; }
  .site-nav-item { padding: 0.35rem 0.65rem; font-size: 0.72rem; min-height: 36px; display: inline-flex; align-items: center; }
  .topbar-right { grid-area: right; order: unset; gap: 0.25rem; }
  .topbar-right .live-pill { display: none; }
  .topbar-right .btn-ghost {
    min-height: 40px; min-width: 40px; padding: 0.35rem 0.6rem; font-size: 0.72rem;
  }
  .kpi-strip { grid-area: kpi; }

  /* KPI: full-width row under brand/nav, horizontal scroll */
  .kpi-strip {
    display: flex; align-items: stretch; gap: 0.35rem;
    padding: 0.05rem 0 0.05rem;
    min-width: 0;
    width: 100%;
  }
  .kpi-fold-btn {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; min-width: 44px; min-height: 44px;
    border: none; border-radius: 12px; background: var(--bg-raised);
    box-shadow: var(--shadow); font: inherit; font-size: 0.65rem; font-weight: 700;
    letter-spacing: 0.06em; color: var(--muted); cursor: pointer;
  }
  .kpi-row {
    display: flex; flex-wrap: nowrap; gap: 0.4rem;
    flex: 1 1 auto; justify-content: flex-start;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  .kpi-row::-webkit-scrollbar { display: none; }
  .kpi {
    flex: 0 0 auto; min-width: 88px; width: auto;
    padding: 0.4rem 0.7rem 0.35rem;
    scroll-snap-align: start;
  }
  .kpi .v, .kpi .odo { font-size: 1.25rem; }
  .kpi .kpi-tag { font-size: 0.55rem; }
  .dashboard.kpi-collapsed .kpi-row { display: none; }
  .dashboard.kpi-collapsed .kpi-fold-btn { color: var(--brand); }
  .kpi .kpi-tip {
    width: min(280px, calc(100vw - 24px));
    left: 0; right: auto; transform: translate(0, -4px);
  }
  .kpi .kpi-tip::before { left: 24px; margin-left: 0; }
  .kpi:hover .kpi-tip, .kpi:focus-visible .kpi-tip, .kpi.tip-open .kpi-tip {
    transform: translate(0, 0);
  }
  @media (hover: none) {
    .kpi:hover .kpi-tip { opacity: 0; visibility: hidden; }
    .kpi.tip-open .kpi-tip, .kpi:focus-visible .kpi-tip { opacity: 1; visibility: visible; }
  }

  /* Main: map only (~60–70% of remaining viewport); rail/filter are sheets */
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    padding: 0 0.55rem 0;
    min-height: 0;
    flex: 1 1 auto;
  }
  .map-wrap {
    min-height: 0;
    height: 100%;
    border-radius: 16px;
    grid-column: 1; grid-row: 1;
  }
  #map { touch-action: pan-x pan-y; }
  .map-hint {
    display: block !important;
    bottom: 56px; /* above MapLibre attribution + bottom chrome */
    z-index: 6;
    font-size: 0.7rem;
    padding: 0.35rem 0.7rem;
    white-space: normal;
    max-width: calc(100% - 28px);
    text-align: center;
    left: 50%;
    transform: translateX(-50%);
  }
  /* Compact / tuck attribution so it does not cover the hint chip (~390px) */
  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    max-width: 46%;
  }
  .maplibregl-ctrl-attrib {
    font-size: 9px !important;
    line-height: 1.25 !important;
    background: rgba(255,255,255,0.72) !important;
    padding: 2px 5px !important;
  }
  .maplibregl-ctrl-attrib.maplibregl-compact {
    min-height: 20px;
  }
  @media (max-width: 430px) {
    /* Keep only the small 「i」; never expand long credits over the hint chip */
    .maplibregl-ctrl-attrib.maplibregl-compact,
    .maplibregl-ctrl-attrib {
      max-width: 28px !important;
      min-width: 24px;
      overflow: hidden !important;
      padding: 2px !important;
    }
    .maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-inner,
    .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
      display: none !important;
    }
    .maplibregl-ctrl-attrib.maplibregl-compact-show {
      max-width: 28px !important;
      width: 28px !important;
    }
    .map-hint {
      bottom: 64px;
      z-index: 6;
    }
  }
  .map-nodata-tag, .map-error-tag { max-width: 92%; font-size: 0.68rem; top: 10px; left: 10px; transform: none; }

  /* Bottom tab bar */
  .bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    flex-shrink: 0;
    gap: 0;
    padding: 0.2rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255,255,255,0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 28px rgba(17,24,39,0.06);
    z-index: 40;
    backdrop-filter: blur(10px);
  }
  .bn-item {
    flex: 1 1 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.1rem;
    min-height: 52px;
    padding: 0.25rem 0.2rem;
    border: none; background: transparent;
    color: var(--muted); text-decoration: none;
    font: inherit; font-size: 0.68rem; font-weight: 650;
    letter-spacing: 0.02em; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-radius: 12px;
  }
  .bn-ico { font-size: 1.05rem; line-height: 1; color: inherit; }
  .bn-item.is-active { color: var(--brand-ink); background: var(--brand-soft); }
  .bn-item:active { background: var(--bg-hover); }

  /* Rank → full-screen list sheet (same #rail-right) */
  .rail-right {
    position: fixed !important;
    left: 0; right: 0;
    top: env(safe-area-inset-top, 0px);
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    z-index: 65;
    max-height: none;
    min-height: 0;
    height: auto;
    margin: 0;
    border-radius: 0;
    padding: 0.75rem 0.85rem 1rem;
    transform: translateY(108%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 320ms var(--ease), opacity 240ms var(--ease), visibility 0s linear 320ms;
    animation: none;
    display: flex; flex-direction: column;
  }
  body.mode-rank .rail-right {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 320ms var(--ease), opacity 220ms var(--ease), visibility 0s;
  }
  .rank-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.35rem; flex-shrink: 0;
  }
  .rank-sheet-title {
    margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text);
  }
  .rail-right .list-head { display: none; } /* use sheet head on mobile */
  .rail-collapse-btn { display: none !important; }
  .rank-search {
    min-height: 44px; font-size: 1rem; padding: 0.55rem 0.75rem;
  }
  .rank-list { max-height: none; flex: 1; -webkit-overflow-scrolling: touch; }
  .rank-row { min-height: 48px; padding: 0.65rem 0.55rem; }
  .rank-row:hover { transform: none; }
  .log-card.in-rail {
    flex: 0 0 auto; max-height: 7.5rem; overflow: hidden;
    margin-top: 0.5rem;
  }
  .log-card.in-rail .log-body { max-height: 5rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* Filter → bottom sheet (reuse #map-dock / #dock-panel) */
  .map-dock {
    position: fixed !important;
    left: 0; right: 0; bottom: 0; top: auto;
    right: 0; bottom: 0;
    z-index: 75;
    max-width: none;
    width: 100%;
    display: flex; flex-direction: column;
    align-items: stretch;
    gap: 0;
    pointer-events: none;
    transform: translateY(110%);
    transition: transform 320ms var(--ease);
  }
  body.mode-filter .map-dock {
    transform: translateY(0);
    pointer-events: auto;
  }
  .dock-toggle { display: none !important; } /* bottom-nav is the entry */
  .filter-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.35rem 0.25rem 0.55rem;
    flex-shrink: 0;
  }
  .filter-sheet-title {
    margin: 0; font-size: 1.02rem; font-weight: 700; color: var(--text);
  }
  .dock-panel {
    width: 100%;
    max-width: none;
    max-height: min(78dvh, 640px);
    border-radius: 20px 20px 0 0;
    padding: 0.35rem 1rem calc(1rem + 56px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -12px 40px rgba(17, 24, 39, 0.18);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto;
  }
  .dock-panel.is-collapsed {
    /* keep sheet usable when opened via bottom-nav even if aria says collapsed */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    max-height: min(78dvh, 640px) !important;
  }
  body.mode-filter .dock-panel.is-collapsed {
    display: block !important;
  }
  .dock-panel .chk, .dock-panel .seg-opt span {
    min-height: 44px;
    display: inline-flex; align-items: center;
  }
  .dock-panel .chk { width: 100%; }
  .seg-opt span { padding: 0.55rem 0.9rem; }

  /* Shared scrim for filter / detail / rank */
  .drawer-scrim { display: block; }
  .drawer-scrim[hidden] { display: none !important; }
  body.mode-filter .drawer-scrim,
  body.mode-rank .drawer-scrim,
  body.is-mobile-drawer-open .drawer-scrim {
    /* shown via JS removing [hidden] */
  }
  body.mode-filter, body.mode-rank, body.is-mobile-drawer-open { /* lock scroll */ }

  /* Detail → bottom sheet (half → expanded) */
  .ec-handle { display: block; }
  .ec-expand {
    display: inline-flex; align-items: center; justify-content: center;
  }
  .estate-card {
    position: fixed !important;
    left: 0; right: 0; bottom: 0; top: auto;
    inset: auto 0 0 0;
    width: 100% !important;
    height: min(58dvh, 520px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 52px);
    border-radius: 20px 20px 0 0;
    padding: 0.1rem 1rem calc(1.05rem + 56px + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%);
    opacity: 0;
    visibility: hidden;
    z-index: 80;
    box-shadow: 0 -12px 40px rgba(17, 24, 39, 0.18);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .estate-card.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  .estate-card.is-expanded {
    height: min(92dvh, 900px);
  }
  .ec-close, .ec-expand, .sheet-close-btn {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    font-size: 1rem; flex-shrink: 0;
  }
  .ec-head {
    position: sticky; top: 0; background: var(--bg-raised); z-index: 2;
    padding-top: 0.1rem;
  }
  #detail-body .ec-title { font-size: 1.35rem; }

  /* Hide floating dock chrome when detail open */
  body.is-mobile-drawer-open .map-dock { visibility: hidden; pointer-events: none; }

  .maplibregl-ctrl-group button {
    width: 44px !important; height: 44px !important;
  }
  .tender-card:hover { transform: none; }

  /* Map height: leave room for top chrome + bottom nav ≈ 60–70% */
  .dashboard .main {
    /* flex child already fills leftover between kpi + bottom-nav */
  }
}

/* Desktop: amplify same components — hide mobile chrome */
@media (min-width: 1024px) {
  .bottom-nav,
  .kpi-fold-btn,
  .filter-sheet-head,
  .rank-sheet-head,
  .ec-handle,
  .ec-expand,
  .rail-collapse-btn { display: none !important; }
  .drawer-scrim { display: none !important; }
  .kpi-strip {
    display: flex; align-items: center; gap: 0.45rem;
    flex: 1 1 auto; min-width: 0; justify-content: center;
  }
  body.mode-rank .rail-right,
  body.mode-filter .map-dock {
    /* desktop ignores mode classes for layout */
  }
  .dock-panel.is-collapsed {
    /* restore original collapsed behavior on desktop */
  }
}

/* Tablet bridge already covered by ≤1023 mobile-first shell */
