/* Lead2Sold. Mobile first. Deep kelp green, jacaranda accent, porcelain paper. */

:root {
  --ink: #12211c;
  --ink-2: #2c3d36;
  --muted: #6b7a73;
  --paper: #edefea;
  --surface: #ffffff;
  --line: #dbded7;
  --line-soft: #e8eae4;
  --kelp: #1b5e4a;
  --kelp-dark: #124636;
  --kelp-tint: #e4efea;
  --jac: #6b4fc4;
  --jac-tint: #ece7fa;
  --amber: #a86c0d;
  --amber-tint: #fbf0dc;
  --rust: #a33827;
  --rust-tint: #fae6e2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(18, 33, 28, .06), 0 8px 24px -12px rgba(18, 33, 28, .18);
  --shadow-lift: 0 2px 6px rgba(18, 33, 28, .08), 0 20px 40px -20px rgba(18, 33, 28, .35);
  --tab-h: 62px;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 25px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
a { color: var(--kelp); }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: inherit; }
:focus-visible { outline: 2px solid var(--jac); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hide { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: grid; gap: 10px; }

/* Flex/grid children default to min-width:auto, which stops long content
   (addresses, names, emails) from shrinking — it then collides with the
   value column beside it or spills into the neighbouring card. Let content
   shrink and wrap instead of overlapping. */
.spread > * { min-width: 0; }
.spread > .right, .spread .chip { flex-shrink: 0; }
.list > .item, .two-col > *, .stats > .stat { min-width: 0; }
.item .title, .item .sub, .card h1, .card h2, .card h3 { overflow-wrap: break-word; }

/* ---------- shell ---------- */

/* Bottom clearance = tab bar + the floating quick-add button, so the last
   list item is never trapped underneath either. */
#app { min-height: 100vh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 92px); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--ink); color: #f2f5f2;
}
.brand { font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.brand span { color: #9ad9bf; }
.topbar .icon-btn { color: #dfe8e3; }
.icon-btn {
  background: none; border: 0; padding: 8px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:active { background: rgba(255, 255, 255, .12); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--jac); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600; border: 0; cursor: pointer;
}

main { padding: 14px; max-width: 1240px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; place-items: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: 11px; padding-top: 8px;
}
.tabbar a.on { color: var(--kelp); font-weight: 600; }
.tabbar svg { width: 21px; height: 21px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 41; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--kelp); color: #fff; box-shadow: var(--shadow-lift);
  display: grid; place-items: center;
}
.fab:active { transform: scale(.95); }
.sidebar { display: none; }

/* ---------- cards & lists ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-head h2, .card-head h3 { line-height: 1.2; }

.rail { position: relative; padding-left: 16px; }
.rail::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 4px;
  background: var(--line);
}
.rail.r-green::before { background: var(--kelp); }
.rail.r-violet::before { background: var(--jac); }
.rail.r-amber::before { background: var(--amber); }
.rail.r-rust::before { background: var(--rust); }
.rail.r-grey::before { background: #b6bdb7; }

.list { display: grid; gap: 10px; }
.item {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; cursor: pointer; display: block; width: 100%;
  text-align: left; font: inherit; color: inherit;
}
/* The .item padding shorthand used to zero the left padding and (being the
   later rule) beat .rail's padding-left — every row's first letter sat under
   the colour bar. Items always carry .rail; state the gutter explicitly. */
.item.rail { padding-left: 16px; }
.item:active { transform: scale(.995); }
.item .title { font-weight: 600; font-size: 15px; }
.item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em; background: var(--paper); color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip.green { background: var(--kelp-tint); color: var(--kelp-dark); border-color: #c5e0d5; }
.chip.violet { background: var(--jac-tint); color: #4b34a0; border-color: #d8cef5; }
.chip.amber { background: var(--amber-tint); color: #7d5008; border-color: #ecd9b0; }
.chip.rust { background: var(--rust-tint); color: #832819; border-color: #f0cdc6; }
.chip.plain { background: transparent; }

.masked {
  font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap;
  cursor: pointer; border-bottom: 1px dotted var(--muted); user-select: none;
}

.price { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: -.02em; white-space: nowrap; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty h3 { font-family: var(--display); color: var(--ink); margin-bottom: 6px; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px 12px 11px; box-shadow: var(--shadow); cursor: pointer; text-align: left;
}
.stat .n { font-family: var(--display); font-size: 27px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.alert .n { color: var(--rust); }
.stat.warn .n { color: var(--amber); }
.stat.good .n { color: var(--kelp); }

.money-band {
  background: var(--ink); color: #eef3f0; border-radius: var(--radius); padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px;
}
.money-band .n { font-family: var(--mono); font-size: 20px; font-weight: 600; letter-spacing: -.03em; }
.money-band .l { font-size: 11.5px; color: #9bb0a7; text-transform: uppercase; letter-spacing: .07em; }

/* ---------- forms ---------- */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); appearance: none; font-size: 16px; /* 16px stops iOS zooming on focus */
}
textarea { min-height: 78px; resize: vertical; }
select { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7a73' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input:disabled, select:disabled { background: var(--paper); color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; cursor: pointer;
}
.tag.on { background: var(--kelp); border-color: var(--kelp); color: #fff; font-weight: 600; }

.switch { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.switch input { width: 44px; height: 26px; appearance: none; background: #ccd2cd; border-radius: 999px; position: relative; transition: background .15s; flex: 0 0 auto; }
.switch input:checked { background: var(--kelp); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked::after { transform: translateX(18px); }
.switch label { font-size: 14px; font-weight: 500; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--kelp); color: #fff; font-weight: 600; font-size: 14.5px; cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.quiet { background: transparent; color: var(--kelp); padding: 8px 10px; }
.btn.violet { background: var(--jac); }
.btn.danger { background: var(--rust); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: flex; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: none; padding: 7px 13px; border-radius: 999px; font-size: 13px;
  white-space: nowrap; cursor: pointer; color: var(--muted); font-weight: 500;
}
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.search-bar { position: relative; margin-bottom: 12px; }
.search-bar input { padding-left: 38px; font-size: 15px; }
.search-bar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ---------- sheets, modals, toasts ---------- */

.scrim { position: fixed; inset: 0; background: rgba(18, 33, 28, .45); z-index: 60; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--surface);
  border-radius: 20px 20px 0 0; max-height: 92vh; display: flex; flex-direction: column;
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--surface);
  border-radius: 20px 20px 0 0;
}
.sheet-body { padding: 14px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px;
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; }
.grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; }

.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick-grid button {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 8px; display: grid; gap: 7px; place-items: center; cursor: pointer; font-size: 12.5px; font-weight: 600;
}
.quick-grid button:active { background: var(--kelp-tint); }
.quick-grid svg { color: var(--kelp); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 84px); z-index: 90;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow-lift); max-width: 90vw; animation: rise .2s;
}
.toast.bad { background: var(--rust); }

/* ---------- timeline ---------- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line-soft); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--kelp);
}
.tl-item.violet::before { border-color: var(--jac); }
.tl-item.amber::before { border-color: var(--amber); }
.tl-when { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

/* ---------- match meter ---------- */

.meter { display: flex; align-items: center; gap: 9px; }
.meter .bar { flex: 1; height: 7px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--kelp); border-radius: 4px; }
.meter .fill.mid { background: var(--amber); }
.meter .fill.low { background: #b6bdb7; }
.meter .pct { font-family: var(--mono); font-weight: 600; font-size: 13px; min-width: 38px; text-align: right; }

/* ---------- charts ---------- */

.chart-bars { display: grid; gap: 9px; }
.cb-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 9px; align-items: center; font-size: 13px; }
.cb-row > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-track { height: 20px; background: var(--paper); border-radius: 5px; overflow: hidden; }
.cb-fill { height: 100%; background: var(--kelp); border-radius: 5px; }
.cb-fill.v { background: var(--jac); }
.cb-val { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }

.funnel { display: grid; gap: 8px; }
.funnel-step { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--paper); }
.funnel-step .k { font-size: 13px; }
.funnel-step .v { font-family: var(--mono); font-weight: 600; }
.funnel-arrow { font-size: 11.5px; color: var(--muted); text-align: center; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.data td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); }
table.data tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.banner { padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 12px; }
.banner.rust { background: var(--rust-tint); color: #7a2417; border: 1px solid #f0cdc6; }
.banner.amber { background: var(--amber-tint); color: #6f4708; border: 1px solid #ecd9b0; }
.banner.green { background: var(--kelp-tint); color: var(--kelp-dark); border: 1px solid #c5e0d5; }
.banner.violet { background: var(--jac-tint); color: #47309b; border: 1px solid #d8cef5; }

.section-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
  font-weight: 600; margin: 18px 0 8px;
}
.section-label:first-child { margin-top: 0; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.photo-strip img { height: 92px; border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 500px at 15% -10%, #1b5e4a22, transparent), var(--paper); }
.login-card { width: 100%; max-width: 380px; }
.login-mark { font-family: var(--display); font-size: 34px; font-weight: 600; letter-spacing: -.03em; margin-bottom: 4px; }
.login-mark span { color: var(--kelp); }
.demo-note { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* ---------- desktop ---------- */

@media (min-width: 900px) {
  #app { padding-bottom: 0; padding-left: 224px; }
  .tabbar, .fab { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 3px; position: fixed; left: 0; top: 0; bottom: 0; width: 224px;
    background: var(--ink); color: #dfe8e3; padding: 16px 12px; z-index: 50; overflow-y: auto;
  }
  .sidebar .brand { font-size: 21px; padding: 6px 10px 16px; }
  .sidebar a {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
    text-decoration: none; color: #c3d3cc; font-size: 14px;
  }
  .sidebar a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
  .sidebar a.on { background: var(--kelp); color: #fff; font-weight: 600; }
  .sidebar svg { width: 18px; height: 18px; }
  .sidebar .spacer { flex: 1; }
  .sidebar .side-btn { margin-top: 8px; }
  /* The sidebar already carries the brand — showing it in the topbar too
     reads as a glitch. Icons keep to the right. */
  .topbar { padding-left: 18px; justify-content: flex-end; }
  .topbar .brand { display: none; }
  main { padding: 22px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .money-band { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .two-col { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .two-col > * + * { margin-top: 0; }
  .card + .card { margin-top: 14px; }
  .sheet { left: 50%; transform: translateX(-50%); bottom: 0; width: min(720px, 96vw); border-radius: 18px 18px 0 0; max-height: 94vh; }
  .list.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { bottom: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .tabbar, .sidebar, .fab { display: none !important; }
  #app { padding: 0; }
}
