/* ============ Design tokens ============ */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --text: #121826;
  --muted: #5d6677;
  --faint: #8a93a3;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;

  --brand: #0f5c4d;          /* deep teal — primary actions */
  --brand-ink: #ffffff;
  --brand-soft: #e1f1ec;
  --brand-text: #0b5446;

  --info: #2d5bd7;   --info-soft: #e5ecfc;
  --warn: #9a5b00;   --warn-soft: #fdf0d9;
  --danger: #b42318; --danger-soft: #fde7e5;
  --ai: #6a4fd1;     --ai-soft: #efeafd;

  --bubble-in: #ffffff;
  --bubble-out: #e1f1ec;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --appbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1d222a;
    --surface-3: #262c36;
    --text: #e9ecf1;
    --muted: #a3acba;
    --faint: #7c8594;
    --line: #2a303a;
    --line-strong: #394150;
    --brand: #3fb59a;
    --brand-ink: #06231c;
    --brand-soft: #16342d;
    --brand-text: #6fd3b9;
    --info: #86a6f5;   --info-soft: #1c2742;
    --warn: #f2b863;   --warn-soft: #3a2c14;
    --danger: #f59087; --danger-soft: #43201d;
    --ai: #b3a1f7;     --ai-soft: #2a2442;
    --bubble-in: #1d222a;
    --bubble-out: #16342d;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.icon { display: inline-flex; flex: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.two-col { display: grid; gap: 16px; align-items: start; }
@media (min-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); } }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ============ App shell ============ */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner { max-width: 1180px; margin: 0 auto; height: var(--appbar-h); padding: 0 16px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000));
  color: var(--brand-ink); font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
@media (prefers-color-scheme: dark) { .brand-mark { background: var(--brand); } }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 16px; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.nav-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 9px; color: var(--muted); font-weight: 560; font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-text); }
.bottomnav { display: none; }

@media (max-width: 759px) {
  .topnav { display: none; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; }
  .bottomnav .nav-item.active { background: none; }
  body[data-view="app"] .page { padding-bottom: 96px; }
}

.page { max-width: 1180px; margin: 0 auto; padding: 18px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* legacy simple bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 650; }
.topbar .sub { color: var(--muted); font-size: 13px; }

/* ============ Controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 560; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon-btn { padding: 0; width: 38px; }
.btn.icon { padding: 0 10px; }

input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 560; color: var(--text); }
label.field > span.help { font-weight: 400; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card.stack .card-head { margin-bottom: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6;
  background: var(--surface-3); color: var(--muted);
}
.badge.accent { background: var(--brand-soft); color: var(--brand-text); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.danger.solid { background: var(--danger); color: #fff; }
.chip { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); font-weight: 560; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius); background: var(--info-soft); color: var(--info); font-size: 14px; }
.banner a { color: inherit; font-weight: 650; text-decoration: underline; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.callout { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }

/* ============ Board ============ */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; box-shadow: var(--shadow-sm);
}
.stat:hover { border-color: var(--line-strong); }
.stat.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 560; }
.stat.danger .stat-value { color: var(--danger); }
.stat.accent .stat-value { color: var(--brand-text); }

.searchbox { position: relative; }
.searchbox .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.searchbox input { padding-left: 38px; background: var(--surface); }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 560; font-size: 14px; color: var(--muted);
}
.tab:hover { color: var(--text); border-color: var(--line-strong); }
.tab.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tab .count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.tab .count.hot { background: var(--danger); color: #fff; }
.tab.active .count { background: color-mix(in srgb, var(--bg) 25%, transparent); color: var(--bg); }

.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead-card {
  position: relative; display: flex; gap: 12px; padding: 14px 16px 14px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  color: inherit; box-shadow: var(--shadow-sm); overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.lead-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow); }
.lead-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-strong); }
.lead-card.tone-danger::before { background: var(--danger); }
.lead-card.tone-warn::before { background: var(--warn); }
.lead-card.tone-info::before { background: var(--info); }
.lead-card.tone-accent::before { background: var(--brand); }
.lead-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lead-top { display: flex; align-items: center; gap: 8px; }
.lead-top .name { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-top .time { margin-left: auto; color: var(--faint); font-size: 13px; white-space: nowrap; }
.lead-card.unread .name { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.lead-card .service { font-size: 14px; display: flex; gap: 10px; align-items: baseline; }
.lead-card .preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lead-card .meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lead-card .value { font-weight: 700; }

.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  font-weight: 700; letter-spacing: .02em; color: #fff;
}
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar[data-tone="0"] { background: #2f6fd1; }
.avatar[data-tone="1"] { background: #0f7c67; }
.avatar[data-tone="2"] { background: #b85c1b; }
.avatar[data-tone="3"] { background: #7a4fcf; }
.avatar[data-tone="4"] { background: #b8386a; }
.avatar[data-tone="5"] { background: #52606d; }

.empty { padding: 40px 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.empty-title { font-weight: 650; margin-bottom: 4px; }

/* ============ Lead page ============ */
body[data-view="lead"] { padding-bottom: 0; }
.lead-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.lead-header-inner { max-width: 1180px; margin: 0 auto; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.lead-title .title { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-title .sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.lead-title .sub-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-title .value { color: var(--text); }
.header-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .hide-sm { display: none; } .header-actions .btn:not(.icon-btn) { padding: 0 10px; } .lead-header .avatar { display: none; } }
@media (max-width: 380px) { .hide-xs { display: none; } }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 260px;
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-panel .btn { justify-content: flex-start; }

.lead-page { padding-top: 12px; padding-bottom: calc(var(--composer-h, 120px) + 24px); gap: 10px; }
.lead-strip:empty { display: none; }
.strip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.strip > span:not(.icon) { flex: 1; }
.strip.warn { background: var(--warn-soft); color: var(--warn); }
.strip.danger { background: var(--danger-soft); color: var(--danger); }

.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtab { padding: 10px 12px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-bottom-color: var(--brand); }

.detail-layout { display: grid; gap: 18px; }
@media (min-width: 960px) {
  .detail-layout { grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); align-items: start; }
  .detail-layout .side { position: sticky; top: calc(var(--appbar-h) + 20px); max-height: calc(100vh - var(--appbar-h) - var(--composer-h, 120px) - 44px); overflow-y: auto; padding-right: 2px; }
  .subtabs .only-mobile { display: none; }
}
@media (max-width: 959px) {
  .detail-layout[data-tab="chat"] .side { display: none; }
  .detail-layout:not([data-tab="chat"]) .main { display: none; }
}
.side-stack { gap: 12px; }

/* conversation */
.thread { display: flex; flex-direction: column; gap: 6px; }
.request-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 6px; }
.request-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.request-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-text); }
.request-title { font-weight: 650; font-size: 16px; }
.request-desc { color: var(--muted); margin-top: 2px; }
dl.qa { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
dl.qa dt { color: var(--muted); }
dl.qa dd { margin: 0; font-weight: 600; }
@media (max-width: 480px) { dl.qa { grid-template-columns: 1fr; gap: 0; } dl.qa dd { margin-bottom: 6px; } }

.day { display: flex; justify-content: center; margin: 10px 0 4px; }
.day span { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 999px; }
.msg-row { display: flex; }
.msg-row.out { justify-content: flex-end; }
.msg { max-width: min(560px, 84%); padding: 9px 13px 7px; border-radius: 16px; border: 1px solid var(--line); background: var(--bubble-in); box-shadow: var(--shadow-sm); word-wrap: break-word; }
.msg.in { border-bottom-left-radius: 6px; }
.msg.out { background: var(--bubble-out); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.out.ai { background: var(--ai-soft); }
.msg.pending { border: 1px dashed var(--line-strong); background: var(--surface); opacity: .92; }
.msg.failed { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.msg .who { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 650; margin-bottom: 2px; }
.msg.ai .who { color: var(--ai); }
.msg .text { white-space: pre-wrap; }
.msg .when { font-size: 11px; color: var(--faint); margin-top: 3px; text-align: right; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.thumb { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: zoom-in; }
.link-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--brand-text); font-size: 12px; font-weight: 650; cursor: pointer; }
.link-thumb:hover { text-decoration: none; border-color: var(--brand); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-bottom: 8px; }
.photo-grid .thumb { width: 100%; height: auto; aspect-ratio: 1; }

/* composer + AI draft dock */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.composer-inner { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 960px) {
  .composer { padding-left: 16px; padding-right: 16px; }
  .composer-inner { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); column-gap: 18px; row-gap: 6px; }
  .composer-inner > * { grid-column: 1; }
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; border-radius: 12px; }
.composer .btn.primary.icon-btn { width: 44px; min-height: 42px; border-radius: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.dock:empty { display: none; }
.dock { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; }
.draft { background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai) 35%, transparent); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.draft-head { display: flex; align-items: center; gap: 6px; color: var(--ai); font-size: 14px; }
.draft-head .muted { color: var(--muted); }
.draft textarea { background: var(--surface); min-height: 72px; }
@media (max-width: 640px) { .draft textarea { min-height: 60px; } .draft { padding: 8px 10px; gap: 6px; } .draft-head .muted { display: none; } }

/* side cards */
.summary-card .price-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.summary-card .price { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.ai-summary { display: flex; gap: 6px; font-size: 14px; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.ai-summary .icon { color: var(--ai); margin-top: 3px; }
.summary-card .callout { margin-bottom: 8px; }
.breakdown { margin: 6px 0; font-size: 14px; }
.breakdown summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.breakdown dl { margin-top: 8px; }
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-weight: 600; }

.facts-grid { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.fact { display: grid; grid-template-columns: minmax(0, 1fr) 150px; grid-template-areas: "label input" "label src"; gap: 2px 12px; align-items: center; }
.fact-label { grid-area: label; font-size: 14px; }
.fact > input, .fact > select, .fact-value { grid-area: input; }
.fact-value { font-weight: 600; text-align: right; }
.fact-src { grid-area: src; font-size: 11px; color: var(--faint); text-align: right; }
.fact-src.missing { color: var(--warn); }
@media (max-width: 480px) { .fact { grid-template-columns: 1fr; grid-template-areas: "label" "input" "src"; } .fact-src, .fact-value { text-align: left; } }

.contact { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.contact .muted { display: flex; align-items: center; gap: 4px; }
.note { border-top: 1px solid var(--line); padding-top: 10px; }

/* activity */
.timeline { display: flex; flex-direction: column; }
.log-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-item:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-size: 13px; }
.log-time .small { font-size: 11px; color: var(--faint); }
.log-summary { color: var(--muted); font-size: 13px; margin-top: 2px; }
.log-raw summary { cursor: pointer; font-size: 12px; color: var(--faint); margin-top: 4px; }
.log-raw code { display: block; font-size: 11px; color: var(--muted); white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 8px; border-radius: 8px; margin-top: 4px; }
.log-item.actor-ai strong { color: var(--ai); }

/* services page */
.svc-card { display: block; width: 100%; text-align: left; cursor: pointer; }
.svc-card:hover { border-color: var(--line-strong); }
.svc-card.selected { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.svc-card .top { display: flex; justify-content: space-between; gap: 8px; }
.svc-card .name { font-weight: 650; }
.svc-card .meta { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* login */
.login { max-width: 380px; margin: 14vh auto 0; padding: 28px; }
.login h1 { font-size: 22px; }

/* simulator */
.qa-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.sim-thread { max-height: 360px; overflow-y: auto; padding: 10px; background: var(--bg); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.sim-thread .msg { max-width: 90%; }
.sim-thread .msg.out { align-self: flex-end; }

/* overlays */
#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(8px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 560; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 60; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; z-index: 70; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
