/* Legacy Real design system -------------------------------------------------------------------------- */
:root {
  --brand: #16254f; --brand-2: #22367a; --accent: #3461f4; --accent-ink: #fff; --accent-soft: #e9eeff; --gold: #f5b83d;
  --bg: #f5f7fb; --surface: #fff; --surface-2: #f0f3f9; --ink: #141b2d; --ink-2: #414b63; --mute: #6b7590;
  --line: #e2e7f0; --line-2: #d3dae7;
  --good: #137a47; --good-bg: #e2f5ea; --warn: #9a6300; --warn-bg: #fff3d6; --bad: #b3261e; --bad-bg: #fde7e5;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(20,27,45,.06), 0 4px 16px rgba(20,27,45,.06);
  --side: 248px; --bottom: 64px;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #0b1330; --brand-2: #1a2a5e; --accent: #7a9bff; --accent-ink: #0b1020; --accent-soft: #1b2650;
    --bg: #0d1017; --surface: #161a23; --surface-2: #1d222d; --ink: #e9ecf3; --ink-2: #c3c9d6; --mute: #929bb0;
    --line: #262c39; --line-2: #313849; --good: #6fd39b; --good-bg: #11301f; --warn: #f2c65d; --warn-bg: #34290f;
    --bad: #ff8e86; --bad-bg: #3a1614; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* App shell */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: var(--brand); color: #dfe5f7; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 18px 12px; z-index: 20; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-weight: 700; font-size: 17px; }
.logo img { width: 32px; height: 32px; }
.navlist { display: flex; flex-direction: column; gap: 2px; }
.navlist a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #c9d2ee; font-weight: 500; }
.navlist a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.navlist a[aria-current="page"] { background: rgba(255,255,255,.13); color: #fff; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #aeb8d8; }
.side-foot .who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--brand); display: grid; place-items: center; font-weight: 800; }
.content { flex: 1; margin-left: var(--side); min-width: 0; }
.topbar { display: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--mute); margin-top: 4px; }
.bottom { display: none; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.grid > .card, .grid > * + * { margin-top: 0; }   /* grid gap handles spacing -- no stagger */
a.card, a.card:hover { text-decoration: none; color: inherit; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.muted { color: var(--mute); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); } .g5 { grid-template-columns: repeat(5, 1fr); }
.row { display: flex; align-items: center; gap: 10px; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* Stats */
.stat { padding: 16px; }
.stat .label { color: var(--mute); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }
.stat .hint { font-size: 12px; color: var(--mute); margin-top: 2px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.btn:hover { filter: brightness(1.05); } .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.sm { padding: 7px 11px; font-size: 13px; } .btn.block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--mute); }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { min-height: 96px; resize: vertical; }
.checkbox { display: flex; gap: 10px; align-items: center; font-weight: 500; } .checkbox input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--mute); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search { position: relative; } .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); }
.search input { padding-left: 38px; }

/* Pills & badges */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.EXCELLENT, .pill.done, .pill.PASS, .pill.on { background: var(--good-bg); color: var(--good); }
.pill.OKAY, .pill.running, .pill.PARTIAL, .pill.CHECK { background: var(--warn-bg); color: var(--warn); }
.pill.POOR, .pill.failed, .pill.interrupted, .pill.stopped, .pill.FAIL, .pill.off { background: var(--bad-bg); color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pulse .dot { animation: pulse 1.2s infinite; } @keyframes pulse { 50% { opacity: .3; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; } .item:hover { background: var(--surface-2); border-radius: 10px; }
.item .grow { flex: 1; min-width: 0; } .item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-box { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }

/* Lead cards */
.leads { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.lead { cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 10px; }
.lead:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(20,27,45,.1); }
.lead .name { font-weight: 700; font-size: 16px; } .lead .why { font-size: 13px; color: var(--ink-2); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--mute); }
.facts span { display: inline-flex; align-items: center; gap: 5px; } .facts svg.i { width: 15px; height: 15px; }

/* Sheet (modal on desktop, bottom sheet on phone) */
.overlay { position: fixed; inset: 0; background: rgba(8,12,24,.45); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
.sheet { width: min(640px, 100%); height: 100%; background: var(--surface); overflow-y: auto; box-shadow: -8px 0 30px rgba(0,0,0,.18); animation: slide .2s; display: flex; flex-direction: column; }
.sheet-head { position: sticky; top: 0; background: var(--surface); padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; z-index: 1; }
.sheet-body { padding: 18px 20px 40px; }
.section + .section { margin-top: 22px; } .section h3 { margin-bottom: 10px; color: var(--ink-2); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; } .kv dt { color: var(--mute); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.grade { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.grade:last-child { border-bottom: 0; } .grade .t { font-weight: 600; min-width: 96px; }
.quote { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; font-size: 14px; }
pre.log { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; margin: 0; }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(30px); opacity: .5; } }

/* Chat */
.chat { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.conv { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 82%; padding: 11px 14px; border-radius: 16px; white-space: pre-wrap; font-size: 14.5px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.bubble .meta { font-size: 11px; opacity: .75; margin-bottom: 3px; }
.coach { border: 1px solid var(--line); border-left: 4px solid var(--gold); background: var(--surface); border-radius: var(--radius-sm); padding: 14px; }
.coach .k { font-size: 11.5px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; margin-top: 10px; }
.coach .k:first-child { margin-top: 0; } .coach .reply { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding-top: 10px; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 500px at 0% 0%, #2c49a8 0%, transparent 60%), var(--brand); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-size: 34px; max-width: 460px; margin-top: 40px; } .auth-hero p { color: #c9d2ee; margin-top: 12px; max-width: 440px; }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; color: #e2e8fa; } .auth-hero li svg { color: var(--gold); }
.auth-form { display: grid; place-items: center; padding: 32px; } .auth-form .card { width: min(400px, 100%); padding: 28px; }

/* Empty / loading / toast */
.empty { text-align: center; padding: 40px 16px; color: var(--mute); } .empty .icon-box { margin: 0 auto 12px; width: 52px; height: 52px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; height: 88px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-weight: 600; margin-bottom: 16px; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-weight: 600; max-width: 340px; animation: fade .2s; }
.toast.bad { background: var(--bad); color: #fff; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Phone ----------------------------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .g4, .g5 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; } .chat.open .people { display: none; } .chat:not(.open) .thread { display: none; }
  .auth { grid-template-columns: 1fr; } .auth-hero { padding: 32px 24px; } .auth-hero h1 { font-size: 26px; margin-top: 20px; } .auth-hero ul { display: none; }
}
@media (max-width: 760px) {
  .side { display: none; } .content { margin-left: 0; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 15; background: var(--brand); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); align-items: center; gap: 10px; font-weight: 700; }
  .topbar img { width: 28px; height: 28px; } .topbar .job { margin-left: auto; }
  .page { padding: 18px 16px calc(var(--bottom) + 28px); } h1 { font-size: 21px; }
  .g2 { grid-template-columns: 1fr; } .leads { grid-template-columns: 1fr; }
  .bottom { display: flex; position: fixed; inset: auto 0 0 0; height: calc(var(--bottom) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); z-index: 20; }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--mute); }
  .bottom a[aria-current="page"] { color: var(--accent); } .bottom a:hover { text-decoration: none; }
  .sheet { width: 100%; height: 92vh; margin-top: auto; border-radius: 18px 18px 0 0; }
  .overlay { align-items: flex-end; } .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  #toasts { left: 16px; bottom: calc(var(--bottom) + 16px); }
}

/* contacts spreadsheet */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.sheet-table th { text-align: left; font-weight: 600; color: var(--mute); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.sheet-table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; word-break: break-word; }
.sheet-table tbody tr { cursor: pointer; }
.sheet-table td:nth-child(3), .sheet-table td:nth-child(1) { white-space: nowrap; }
.sheet-table td:nth-child(4) { overflow-wrap: anywhere; word-break: normal; min-width: 200px; }
.sheet-table tbody tr:hover { background: var(--surface-2); }

/* new chat from screenshots */
.drop { display: flex; gap: 12px; align-items: center; padding: 18px; border: 2px dashed var(--line-2); border-radius: 12px; cursor: pointer; background: var(--surface-2); }
.drop:hover { border-color: var(--accent); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; border: 0; border-radius: 99px; width: 24px; height: 24px; display: grid; place-items: center; background: rgb(0 0 0 / .6); color: #fff; cursor: pointer; padding: 0; }
.thumb button svg { width: 14px; height: 14px; }

.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 60; border: 0; border-radius: 99px; padding: 12px 20px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
.bubble .thumb { width: 120px; height: 120px; display: block; }

/* phone: nothing may push the page wider than the screen (grid/flex children default to min-width:auto) */
html, body { overflow-x: hidden; max-width: 100%; }
.grid > *, .chat > *, .thread, .card, .content, main { min-width: 0; }
.bubble, .coach, .title, .sub, .quote, .log, .why { overflow-wrap: anywhere; }
