/* Argent agent dashboard — operator UI, scanned rather than read. */
:root {
  --bg: #F6F8F6;
  --surface: #FFFFFF;
  --surface-2: #EEF2EE;
  --ink: #1B2420;
  --muted: #5C6B63;
  --faint: #8A9891;
  --line: #DCE4DE;
  --teal: #0E6B5C;
  --teal-ink: #0A5347;
  --teal-soft: #E1EFEB;
  --clay: #B4552D;
  --clay-ink: #94431F;
  --clay-soft: #F7E9E0;
  --good: #0F7A4A;
  --good-soft: #E2F2E9;
  --warn: #8A6410;
  --warn-soft: #FBF1D9;
  --bad: #A8302B;
  --bad-soft: #F9E4E2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 36, 32, 0.06), 0 4px 12px rgba(27, 36, 32, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #101613;
    --surface: #19201C;
    --surface-2: #212A24;
    --ink: #E7ECE8;
    --muted: #9AA9A1;
    --faint: #78877F;
    --line: #2A342E;
    --teal: #4FB3A0;
    --teal-ink: #6FC7B6;
    --teal-soft: #15302A;
    --clay: #D98757;
    --clay-ink: #E39A6F;
    --clay-soft: #34231A;
    --good: #4FBF8B;
    --good-soft: #142B20;
    --warn: #D6B45C;
    --warn-soft: #2E2714;
    --bad: #E58079;
    --bad-soft: #2F1917;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme='dark'] {
  --bg: #101613; --surface: #19201C; --surface-2: #212A24; --ink: #E7ECE8;
  --muted: #9AA9A1; --faint: #78877F; --line: #2A342E;
  --teal: #4FB3A0; --teal-ink: #6FC7B6; --teal-soft: #15302A;
  --clay: #D98757; --clay-ink: #E39A6F; --clay-soft: #34231A;
  --good: #4FBF8B; --good-soft: #142B20; --warn: #D6B45C; --warn-soft: #2E2714;
  --bad: #E58079; --bad-soft: #2F1917;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal-ink); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.mono, code { font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace; font-size: 0.86em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- shell -- */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
/* Phone: the nav becomes a compact scrolling bar so the work starts at the top
   of the screen — a field agent should not scroll past ten links to reach the
   capture form. */
@media (max-width: 900px) {
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 10px; overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { padding: 0 10px 0 2px; }
  .brand span { display: none; }
  #nav { display: flex; gap: 6px; }
  .nav-item { width: auto; white-space: nowrap; padding: 6px 10px; }
  .nav-sep { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0 4px; display: flex; align-items: center; gap: 8px; }
  .sidebar-foot > div:first-child, .sidebar-foot .pill { display: none; }
  .main { padding: 16px 14px 80px; }
  .page-head h1 { font-size: 1.2rem; }
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 4px 10px 16px; }
.brand b { font-size: 1.05rem; letter-spacing: -0.01em; }
.brand span { font-size: 0.7rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--muted);
  text-decoration: none; border: none; background: none; width: 100%; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current='page'] { background: var(--teal-soft); color: var(--teal-ink); font-weight: 600; }
.nav-count {
  font-size: 0.72rem; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.nav-item[aria-current='page'] .nav-count { background: var(--surface); }
.nav-count.alert { background: var(--bad-soft); color: var(--bad); }
.nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 0.8rem; color: var(--faint); }

.main { padding: 24px 28px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.4rem; margin: 0 0 2px; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 68ch; }

/* --------------------------------------------------------------- pieces -- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; } }

.stat { padding: 14px 16px; }
.stat .label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.stat .value { font-size: 1.9rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: 0.8rem; color: var(--muted); }
.stat.attention { border-color: var(--warn); }
.stat.attention .value { color: var(--warn); }
.stat.critical { border-color: var(--bad); }
.stat.critical .value { color: var(--bad); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.teal { background: var(--teal-soft); color: var(--teal-ink); }
.pill.clay { background: var(--clay-soft); color: var(--clay-ink); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 0.88rem; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 4px 9px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

input[type='text'], input[type='email'], input[type='password'], input[type='number'], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-click { cursor: pointer; }

.empty { padding: 40px 20px; text-align: center; color: var(--faint); }
.empty strong { display: block; color: var(--muted); margin-bottom: 4px; }

/* --------------------------------------------------------------- inbox --- */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.conv-list { max-height: calc(100vh - 190px); overflow-y: auto; }
.conv-item { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 3px; }
.conv-item:hover { background: var(--surface-2); }
.conv-item[aria-selected='true'] { background: var(--teal-soft); }
.conv-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-item .who { font-weight: 600; font-size: 0.9rem; }
.conv-item .when { font-size: 0.72rem; color: var(--faint); white-space: nowrap; }
.conv-item .preview { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread { display: flex; flex-direction: column; gap: 10px; padding: 16px; max-height: 52vh; overflow-y: auto; }
.msg { max-width: 74%; padding: 9px 12px; border-radius: 12px; font-size: 0.9rem; }
.msg.inbound { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.outbound { align-self: flex-end; background: var(--teal-soft); color: var(--teal-ink); border-bottom-right-radius: 4px; }
.msg .meta { font-size: 0.7rem; color: var(--faint); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg.outbound .meta { color: var(--teal-ink); opacity: 0.75; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 8px; }
.window-note { font-size: 0.8rem; padding: 8px 12px; border-radius: 8px; }
.window-note.open { background: var(--good-soft); color: var(--good); }
.window-note.closed { background: var(--warn-soft); color: var(--warn); }

.card-preview { border: 1px dashed var(--clay); border-radius: 8px; padding: 10px 12px; background: var(--clay-soft); font-size: 0.84rem; }
.card-preview .ref { font-weight: 700; color: var(--clay-ink); }

/* ------------------------------------------------------------- details --- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.reasons { margin: 8px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); }
.reasons li { margin-bottom: 3px; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--teal); }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 50; max-width: 380px;
  padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow);
  background: var(--surface); border: 1px solid var(--line); font-size: 0.88rem;
}
.toast.error { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.toast.success { border-color: var(--good); background: var(--good-soft); color: var(--good); }

/* ---------------------------------------------------------------- login -- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 0.88rem; }
.error-text { color: var(--bad); font-size: 0.85rem; margin: 0 0 12px; }

.skeleton { color: var(--faint); padding: 24px; }

/* ------------------------------------------------------- field capture --- */
/* Mobile-first: a field agent uses this one-handed, outdoors, on a phone. */
.field-wrap { max-width: 720px; margin: 0 auto; }
.visit-card {
  display: grid; gap: 6px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.visit-card:hover { background: var(--surface-2); }
.visit-card .ref { font-weight: 600; }
.visit-card .where { color: var(--muted); font-size: 0.88rem; }
.visit-card .when { font-size: 0.8rem; color: var(--faint); }

.capture-head {
  position: sticky; top: 52px; z-index: 4; background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid var(--line); padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.photo-tile {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .badge {
  position: absolute; left: 5px; top: 5px; font-size: 0.66rem; padding: 1px 6px; border-radius: 999px;
  background: var(--teal); color: #fff; font-weight: 600;
}
.photo-tile .remove {
  position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.6); color: #fff; cursor: pointer; line-height: 1;
  font-size: 15px; display: grid; place-items: center;
}
.photo-tile.uploading::after {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.45);
}
.photo-tile .progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--teal);
  transform-origin: left; z-index: 1;
}
.add-photo {
  display: grid; place-items: center; gap: 4px; aspect-ratio: 1; border-radius: 8px;
  border: 1.5px dashed var(--line); background: var(--surface); cursor: pointer; color: var(--muted);
  font-size: 0.8rem; text-align: center; padding: 6px;
}
.add-photo:hover { border-color: var(--teal); color: var(--teal-ink); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.chip-toggle {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 0.84rem; cursor: pointer;
}
.chip-toggle[aria-pressed='true'] { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-ink); font-weight: 600; }
.sticky-actions {
  position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 16px; display: flex; gap: 8px; flex-wrap: wrap;
}
.gps-note { font-size: 0.8rem; color: var(--muted); }

/* Price-estimate caveats — the reasons a figure is weaker than its confidence pill
   suggests. Styled as a warning block rather than body text because an agent
   skim-reading a range needs these to interrupt, not to blend in. */
.caveats {
  margin: 12px 0 0;
  padding: 10px 12px 10px 28px;
  list-style: disc;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  font-size: .85rem;
  color: var(--warn);
}
.caveats li + li { margin-top: 6px; }

/* A quiet aside inside a card: true, worth knowing, not a warning. */
.inline-note { margin: 0; font-size: .8rem; color: var(--muted); }

/* ------------------------------------------- onboarding + application status */
.ob-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ob-pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--good, #2f7d32); }
.ob-bar {
  height: 6px; border-radius: 999px; background: var(--surface-2, #eef1e9);
  margin: 12px 0 16px; overflow: hidden;
}
.ob-bar span { display: block; height: 100%; background: var(--good, #2f7d32); border-radius: 999px; transition: width .4s ease; }

.ob-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ob-list li { display: flex; gap: 11px; align-items: flex-start; }
.ob-tick {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  border: 2px solid var(--line, #d9ded1); position: relative;
}
.ob-list li.done .ob-tick { background: var(--good, #2f7d32); border-color: var(--good, #2f7d32); }
.ob-list li.done .ob-tick::after {
  content: ""; position: absolute; left: 4px; top: 4px; width: 7px; height: 4px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg);
}
.ob-list li.done strong { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.ob-detail { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.ob-link {
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-weight: 650;
  color: var(--green-deep, #2f5d1e); text-decoration: underline; text-underline-offset: 3px;
}

.apply-steps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.apply-steps li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--line, #d9ded1); border-radius: 10px;
}
.apply-steps li.now { border-color: #c9e88f; background: var(--wash-2, #f2f9e3); }
.apply-steps li span { color: var(--muted); font-size: .85rem; }

/* --------------------------------------------- demo logins (test envs only) */
.demo-logins:empty { display: none; }
.demo-logins {
  margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line, #d9ded1);
  display: grid; gap: 8px;
}
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.demo-head strong { font-size: .92rem; }
.demo-env {
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  background: #fdf3d6; color: #8a6b12; border: 1px solid #ecd9a0;
}
.demo-note { margin: 0 0 4px; color: var(--muted); font-size: .8rem; }
.demo-account {
  display: grid; gap: 1px; text-align: left; cursor: pointer; width: 100%;
  padding: 10px 13px; border: 1px solid var(--line, #d9ded1); border-radius: 9px;
  background: var(--surface, #fff); font: inherit;
}
.demo-account:hover { border-color: #c9e88f; background: var(--wash-2, #f2f9e3); }
.demo-account strong { font-size: .88rem; }
.demo-email { font-size: .78rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.demo-detail { font-size: .78rem; color: var(--faint, #8a9a78); }

/* --- the matching desk ---------------------------------------------------- */
.score-line { display: flex; align-items: center; gap: 9px; min-width: 110px; }
.score-bar {
  flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2, #eef1ec);
  overflow: hidden; min-width: 54px;
}
.score-bar i { display: block; height: 100%; border-radius: inherit; background: var(--good, #0F7A4A); }

/* --- the assistant --------------------------------------------------------- */
.chat-card { display: flex; flex-direction: column; height: min(62vh, 620px); }
.chat-thread {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 18px;
}
.chat-bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 13px; font-size: .9rem; line-height: 1.5;
}
.chat-bubble.me { align-self: flex-end; background: var(--good-soft, #E2F2E9); border-bottom-right-radius: 4px; }
.chat-bubble.them {
  align-self: flex-start; background: var(--surface-2, #eef1ec);
  border-bottom-left-radius: 4px;
}
.chat-matches { display: grid; gap: 6px; margin-top: 9px; }
.chat-match {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  padding: 7px 10px; border-radius: 9px; font-size: .82rem;
  background: var(--surface, #fff); border: 1px solid var(--line, #d9ded1);
}
.chat-input {
  display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line, #d9ded1);
}
.chat-input input { flex: 1; }
