/* ==========================================================================
   Gateway — application styles (no build step required)
   ========================================================================== */

:root {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --border-strong: #cfd6e0;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --brand: #0f766e;
  --brand-hover: #115e59;
  --brand-soft: #e6f4f2;
  --brand-ring: rgba(15, 118, 110, .25);

  --sidebar-bg: #0b1220;
  --sidebar-text: #aab4c5;
  --sidebar-active: rgba(255,255,255,.08);

  --ok: #15803d;      --ok-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --danger: #b91c1c;  --danger-soft: #fee2e2;
  --info: #1d4ed8;    --info-soft: #dbeafe;

  --bubble-in: #eef2f7;
  --bubble-out: #0f766e;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --sidebar-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .05em .35em; }
pre { font-family: var(--mono); font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .85rem 1rem; overflow-x: auto; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; color: var(--text); }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 1.1rem .9rem;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 700; font-size: 1rem;
  padding: .35rem .6rem 1.2rem; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: .7rem;
  color: var(--sidebar-text); padding: .55rem .7rem; border-radius: 8px; font-weight: 500; font-size: .92rem;
  transition: background .12s, color .12s;
}
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.sidebar nav a:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar nav a.active svg { opacity: 1; color: #2dd4bf; }
.sidebar nav a .count { margin-left: auto; background: #14b8a6; color: #032723; font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.sidebar .section-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .7rem .35rem; font-weight: 600; }
.sidebar .spacer { flex: 1; }

.sidebar .user { display: flex; align-items: center; gap: .65rem; border-top: 1px solid rgba(255,255,255,.08); padding: .9rem .4rem 0; }
.sidebar .user .avatar { width: 32px; height: 32px; font-size: .75rem; background: #1e293b; color: #cbd5e1; }
.sidebar .user .who { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar .user .who strong { display: block; color: #e2e8f0; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user .who span { font-size: .72rem; color: #64748b; }
.sidebar .user button { background: none; border: 0; color: #64748b; cursor: pointer; padding: .3rem; border-radius: 6px; display: grid; place-items: center; }
.sidebar .user button:hover { color: #fff; background: var(--sidebar-active); }
.sidebar .user button svg { width: 17px; height: 17px; }

.main { flex: 1; min-width: 0; padding: 1.75rem 2.25rem 3rem; max-width: 1400px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-header h1 { margin: 0; font-size: 1.45rem; line-height: 1.25; }
.page-header h1 .muted { font-weight: 400; font-size: .95rem; margin-left: .35rem; }
.page-header .sub { color: var(--text-2); margin-top: .2rem; font-size: .9rem; }
.page-header .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Components
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm); }
.card > h2 { margin: 0 0 1rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; }
.card > h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .88rem; font-weight: 500; line-height: 1.25;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: #b9c2cf; text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f5b5b5; }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: .32rem .65rem; font-size: .8rem; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.4; background: var(--brand-soft); color: var(--brand-hover); margin-right: .25rem; white-space: nowrap; }
.badge-gray { background: #f1f5f9; color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-err { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
a.badge:hover { text-decoration: none; filter: brightness(.96); }

.muted { color: var(--text-2); font-size: .85rem; }
.hint { color: var(--text-3); font-size: .8rem; margin-top: .35rem; }

.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.alert-err { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty .icon { width: 44px; height: 44px; margin: 0 auto .75rem; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.empty .icon svg { width: 22px; height: 22px; }
.empty strong { display: block; color: var(--text); margin-bottom: .2rem; }

/* Stats row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat .label { font-size: .75rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin-top: .15rem; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-row { margin-bottom: 1.05rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: .92rem; background: var(--surface); color: var(--text);
  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-ring); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type=file] { padding: .4rem .5rem; font-size: .85rem; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.checkbox { display: flex; align-items: center; gap: .55rem; font-weight: 400; color: var(--text); font-size: .9rem; cursor: pointer; margin-bottom: .3rem; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.check-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .75rem; background: var(--surface-2); }
.error { color: var(--danger); font-size: .8rem; margin-top: .3rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 180px; }
.search-wrap { position: relative; flex: 0 1 320px; }
.search-wrap svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search-wrap input { padding-left: 2.1rem; max-width: none; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .9rem; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); background: var(--surface-2); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td .muted { display: block; margin-top: .1rem; }
td.right, th.right { text-align: right; }
td .row-actions { display: inline-flex; gap: .35rem; }
.card > .table-wrap, .card > table { margin: 0 -1.5rem; border-left: 0; border-right: 0; border-radius: 0; width: calc(100% + 3rem); box-shadow: none; }
.card > table th:first-child, .card > table td:first-child { padding-left: 1.5rem; }
.card > table th:last-child, .card > table td:last-child { padding-right: 1.5rem; }
.pagination { margin-top: 1rem; display: flex; justify-content: flex-end; }
.pagination nav { display: flex; gap: .5rem; align-items: center; font-size: .85rem; }

/* --------------------------------------------------------------------------
   Inbox list
   -------------------------------------------------------------------------- */
.threads { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.thread { display: flex; gap: .9rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); color: inherit; align-items: center; transition: background .1s; }
.thread:last-child { border-bottom: 0; }
.thread:hover { background: #fafbfd; text-decoration: none; }
.thread .body { flex: 1; min-width: 0; }
.thread .name { font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.thread .name .muted { font-weight: 400; }
.thread .preview { color: var(--text-2); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.thread .time { color: var(--text-3); font-size: .78rem; white-space: nowrap; }
.thread.unread .name::before { content: ""; width: 7px; height: 7px; background: var(--brand); border-radius: 50%; flex-shrink: 0; }
.thread.unread .preview { color: var(--text); font-weight: 500; }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-hover); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; letter-spacing: .02em; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }

/* --------------------------------------------------------------------------
   Thread / chat view
   -------------------------------------------------------------------------- */
.thread-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

.chat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; height: calc(100vh - 9.5rem); min-height: 420px; }
.chat-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.chat-head .title { font-weight: 600; }
.chat-head .title span { display: block; font-weight: 400; color: var(--text-2); font-size: .8rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.1rem 1.1rem .6rem; display: flex; flex-direction: column; gap: .35rem; background: #fbfcfd; }
.day-sep { align-self: center; font-size: .72rem; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .6rem; margin: .6rem 0; }
.bubble { max-width: 68%; padding: .55rem .85rem; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; font-size: .92rem; box-shadow: var(--shadow-sm); }
.bubble.in { background: var(--bubble-in); color: var(--text); align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.out { background: var(--bubble-out); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.bubble .meta { display: block; font-size: .68rem; opacity: .7; margin-top: .25rem; }
.bubble.out .meta { text-align: right; }
.bubble.failed { background: var(--danger-soft); color: var(--danger); }
.chat-compose { border-top: 1px solid var(--border); padding: .75rem .9rem; display: flex; gap: .6rem; align-items: flex-end; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); }
.chat-compose textarea { min-height: 44px; height: 44px; max-height: 160px; }
.chat-compose .btn { height: 42px; padding-inline: 1.1rem; }

.profile dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: .05rem; }
.profile dt { font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-top: .7rem; }
.profile dd { margin: .1rem 0 0; font-size: .9rem; word-break: break-word; }
.profile-head { display: flex; align-items: center; gap: .9rem; margin-bottom: .6rem; }
.profile-head .title { font-weight: 600; font-size: 1rem; }
.profile-head .title span { display: block; font-weight: 400; color: var(--text-2); font-size: .82rem; }

/* File list */
.file-list { list-style: none; margin: 0 0 1.1rem; padding: 0; }
.file-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: 0; }
.file-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.file-icon svg { width: 18px; height: 18px; }
.file-list .info { flex: 1; min-width: 0; }
.file-list .info a { font-weight: 500; }
.file-list .info .muted { display: block; }

/* Progress */
.progress { background: #e5e9f0; border-radius: 999px; height: 8px; overflow: hidden; }
.progress > div { background: var(--brand); height: 100%; transition: width .3s; }

/* --------------------------------------------------------------------------
   Auth / setup
   -------------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--sidebar-bg); color: #cbd5e1; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; background-image: radial-gradient(ellipse at 20% 0%, rgba(20,184,166,.25), transparent 55%); }
.auth-side .brand { padding: 0; font-size: 1.15rem; }
.auth-side h2 { color: #fff; font-size: 1.8rem; line-height: 1.2; margin: 0 0 .75rem; letter-spacing: -.02em; }
.auth-side p { color: #94a3b8; max-width: 38ch; font-size: .95rem; }
.auth-side ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .55rem; color: #cbd5e1; font-size: .9rem; }
.auth-side li { display: flex; gap: .6rem; align-items: center; }
.auth-side li svg { width: 16px; height: 16px; color: #2dd4bf; flex-shrink: 0; }
.auth-side .foot { font-size: .78rem; color: #64748b; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
.auth-card .lead { color: var(--text-2); margin-bottom: 1.5rem; font-size: .92rem; }
.auth-card .btn { width: 100%; padding: .65rem; font-size: .95rem; }
.checks { list-style: none; padding: 0; margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.checks li { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .8rem; border-bottom: 1px solid var(--border); font-size: .88rem; background: var(--surface-2); }
.checks li:last-child { border-bottom: 0; }
.checks .dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; margin-top: .1rem; }
.checks .dot svg { width: 11px; height: 11px; }
.checks .ok .dot { background: var(--ok-soft); color: var(--ok); }
.checks .bad .dot { background: var(--danger-soft); color: var(--danger); }
.checks .error { margin-top: .2rem; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .thread-layout, .two-col, .form-grid { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .6rem .75rem; }
  .brand { padding: 0 .75rem 0 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: .15rem; order: 3; width: 100%; margin-top: .4rem; }
  .sidebar nav a { padding: .4rem .55rem; font-size: .85rem; }
  .sidebar nav a svg { display: none; }
  .sidebar .section-label, .sidebar .spacer, .sidebar .user .who { display: none; }
  .sidebar .user { border: 0; padding: 0; margin-left: auto; order: 2; }
  .sidebar .user .avatar { display: none; }
  .main { padding: 1.1rem 1rem 2rem; }
  .bubble { max-width: 85%; }
  .card > .table-wrap, .card > table { margin: 0 -1rem; width: calc(100% + 2rem); }
  .card { padding: 1rem; }
}

/* AI screening note under an inbound bubble */
.ai-note { align-self: flex-start; max-width: 68%; font-size: .78rem; color: var(--text-2); display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin: -.1rem 0 .3rem .25rem; }
.ai-note .badge { font-size: .68rem; }
@media (max-width: 760px) { .ai-note { max-width: 85%; } }

/* --------------------------------------------------------------------------
   Thread page: lock to the viewport so only the message pane scrolls
   -------------------------------------------------------------------------- */
.main.main-fixed { height: 100vh; display: flex; flex-direction: column; padding-bottom: 1.25rem; overflow: hidden; }
.main.main-fixed .thread-layout { flex: 1; min-height: 0; }
.main.main-fixed .chat { height: 100%; min-height: 0; position: relative; }
.main.main-fixed .profile { max-height: 100%; overflow-y: auto; }

/* Always-visible, slim scrollbar in the message pane */
.chat-messages { scrollbar-width: thin; scrollbar-color: #b9c2cf transparent; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 10px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #b9c2cf; border-radius: 999px; border: 2px solid #fbfcfd; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.jump-latest {
  position: absolute; right: 1.25rem; bottom: 5rem; z-index: 2;
  background: var(--text); color: #fff; border: 0; border-radius: 999px; padding: .4rem .8rem;
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .15s, transform .15s;
}
.jump-latest.show { opacity: 1; transform: none; pointer-events: auto; }

@media (max-width: 760px) {
  .main.main-fixed { height: auto; overflow: visible; display: block; }
  .main.main-fixed .chat { height: 70vh; }
}

/* --------------------------------------------------------------------------
   Resumes: editor, viewer, print
   -------------------------------------------------------------------------- */
.editor-shell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; padding: .5rem .6rem; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.editor-toolbar button { font: inherit; font-size: .82rem; padding: .3rem .55rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; min-width: 30px; }
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border-strong); }
.editor-toolbar select { width: auto; font-size: .82rem; padding: .3rem 1.8rem .3rem .5rem; }
.editor-toolbar .sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 .25rem; }
.editor-toolbar .spacer { flex: 1; }
.editor-body { min-height: 60vh; padding: 2.2rem 2.6rem; outline: none; }
.editor-body:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor-foot { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .9rem; border-top: 1px solid var(--border); font-size: .78rem; }

.resume-paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.6rem 3rem; }

/* Document typography — deliberately fixed so every resume looks consistent */
.resume-doc { font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.55; color: #1a1a1a; max-width: 52rem; }
.resume-doc h1 { font-family: var(--font); font-size: 1.6rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.resume-doc h2 { font-family: var(--font); font-size: .95rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-hover); border-bottom: 1px solid var(--border); padding-bottom: .25rem; margin: 1.4rem 0 .6rem; }
.resume-doc h3 { font-family: var(--font); font-size: 1rem; margin: .9rem 0 .2rem; }
.resume-doc p { margin: 0 0 .6rem; }
.resume-doc ul, .resume-doc ol { margin: 0 0 .7rem; padding-left: 1.35rem; }
.resume-doc li { margin-bottom: .2rem; }
.resume-doc hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.resume-doc table { width: 100%; border-collapse: collapse; margin: .5rem 0 .9rem; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.resume-doc td, .resume-doc th { padding: .3rem .5rem; border: 1px solid var(--border); font-size: .92em; vertical-align: top; }
.resume-doc blockquote { margin: .5rem 0 .8rem; padding-left: .9rem; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.resume-doc a { color: var(--brand); }

@media (max-width: 960px) {
  .editor-body, .resume-paper { padding: 1.2rem 1.1rem; }
}

/* Bulk selection bar (contacts list) */
.bulk-bar { display: none; align-items: center; gap: .6rem; flex-wrap: wrap; background: var(--brand-soft); border: 1px solid #b9dfd9; border-radius: var(--radius-sm); padding: .55rem .9rem; margin-bottom: .9rem; }
.bulk-bar.show { display: flex; }
.bulk-bar select, .bulk-bar input[type=text] { padding: .4rem .6rem; font-size: .88rem; }
.row-check, #check-all { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Tab bar (Contacts / Groups) */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: -.4rem 0 1.1rem; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; margin-bottom: -1px; color: var(--text-2); font-weight: 500; font-size: .92rem; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-hover); border-bottom-color: var(--brand); }
.tabs a svg { opacity: .8; }

/* Modal (resume quick view) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 18, 32, .55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(2px); }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.35); width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.modal-titles { display: flex; flex-direction: column; min-width: 0; }
.modal-titles strong { font-size: 1.05rem; }
.modal-body { overflow-y: auto; padding: 1.6rem 2.2rem 2.2rem; }
.modal-skills { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; }
.modal-skills:empty { display: none; }
@media (max-width: 760px) { .modal-backdrop { padding: 0; } .modal { border-radius: 0; height: 100%; } .modal-body { padding: 1rem; } }

/* --------------------------------------------------------------------------
   Split inbox: list on the left, open thread on the right
   -------------------------------------------------------------------------- */
.main.main-inbox { padding: 1.1rem 1.25rem 1.1rem; max-width: none; }
.inbox-split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 1rem; height: 100%; min-height: 0; }
.inbox-list { display: flex; flex-direction: column; min-height: 0; }
.inbox-list-head { padding-bottom: .75rem; }
.inbox-threads { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.inbox-threads .thread { padding: .7rem .85rem; gap: .7rem; }
.inbox-threads .thread .name { font-size: .92rem; }
.inbox-threads .thread .preview { font-size: .8rem; }
.inbox-threads .thread.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.inbox-threads .thread.active:hover { background: var(--brand-soft); }
.thread-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.thread-side .badge { margin: 0; }

.inbox-pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.pane { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.pane-head { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.pane-head .avatar { width: 34px; height: 34px; font-size: .75rem; }
.pane-title { flex: 1; min-width: 0; line-height: 1.25; }
.pane-title strong { display: block; }
.pane-title .muted { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.pane-back { display: none; }
.pane-notes { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .45rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: .8rem; }
.pane-messages { flex: 1; }
.pane-empty { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.pane .jump-latest { bottom: 5rem; }

@media (max-width: 960px) {
  .inbox-split { grid-template-columns: 1fr; }
  .inbox-pane { display: none; }
  .inbox-split.has-open .inbox-list { display: none; }
  .inbox-split.has-open .inbox-pane { display: flex; }
  .pane-back { display: inline-flex; }
  .main.main-fixed.main-inbox { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  .main.main-fixed.main-inbox .inbox-split { flex: 1; }
}

/* ---- small dialogs (new message) ---- */
.modal.modal-sm { width: min(480px, 100%); }
.modal.modal-sm .modal-body { padding: 1.25rem 1.5rem 1.5rem; }
@media (max-width: 760px) { .modal.modal-sm { height: auto; border-radius: var(--radius); margin: 1rem; } }

/* ---- contact avatar colours (assigned from the phone number, so a contact keeps its colour everywhere) ---- */
.avatar.av-0 { background: #e0f2f1; color: #00695c; }
.avatar.av-1 { background: #e3f2fd; color: #1565c0; }
.avatar.av-2 { background: #ede7f6; color: #5e35b1; }
.avatar.av-3 { background: #fce4ec; color: #c2185b; }
.avatar.av-4 { background: #fff3e0; color: #e65100; }
.avatar.av-5 { background: #f1f8e9; color: #558b2f; }
.avatar.av-6 { background: #fffde7; color: #9e7c00; }
.avatar.av-7 { background: #e0f7fa; color: #00838f; }
.avatar.av-8 { background: #efebe9; color: #6d4c41; }
.avatar.av-9 { background: #eceff1; color: #455a64; }
