/* ------------------------------------------------------------------
   Cart & Co. Leads — brand colors from the Cart & Company brand brief.
   ------------------------------------------------------------------ */
:root {
  --accent: #A4492C;            /* terracotta */
  --accent-soft: rgba(164, 73, 44, 0.10);
  --ink: #111111;

  --bg: #FFFFFF;
  --card: #FFFFFF;
  --fill: rgba(17, 17, 17, 0.05);
  --text: #111111;
  --text2: #4A4A47;
  --text3: #BDBDB8;
  --sep: #DADAD6;

  /* status colors */
  --red: #D93A2B;
  --orange: #E08A00;
  --green: #2E9E5B;
  --indigo: #4B4FC4;
  --gray: #8E8E89;

  --radius: 6px;
  --shadow: 4px 4px 0 var(--ink);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Zilla Slab", Georgia, serif;
}

@font-face { font-family: "Zilla Slab"; src: url("/fonts/ZillaSlab-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Zilla Slab"; src: url("/fonts/ZillaSlab-600.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Zilla Slab"; src: url("/fonts/ZillaSlab-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Brand font for the wordmark. Put the file in public/fonts/ with one of these names. */
@font-face {
  font-family: "Carentro";
  src: url("/fonts/Carentro.woff2") format("woff2"),
       url("/fonts/Carentro.otf") format("opentype"),
       url("/fonts/Carentro.ttf") format("truetype");
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(24px + var(--safe-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bars ---------- */
.topbar, .navbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.topbar.scrolled, .navbar { border-bottom-color: var(--sep); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.wordmark { font-family: "Carentro", Georgia, serif; font-weight: normal; font-size: 21px; letter-spacing: 0.02em; color: var(--accent); white-space: nowrap; line-height: 1; }
.icon-btn {
  border: 0; background: none; color: var(--accent); padding: 6px; font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.icon-btn:disabled { color: var(--text3); }
.back { font-size: 17px; display: inline-flex; align-items: center; gap: 2px; padding: 6px 0; min-width: 72px; }
.back svg { width: 12px; height: 20px; }
.nav-title { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: center; }
.nav-spacer { min-width: 72px; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; margin: 4px 0 12px; }

/* ---------- bucket tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.tile {
  background: var(--card); border: 0; border-radius: var(--radius); padding: 10px 12px 12px;
  text-align: left; cursor: pointer; display: flex; flex-direction: column; justify-content: flex-start; box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .15s;
}
.tile .count { font-size: 28px; font-weight: 700; line-height: 1.1; display: flex; align-items: center; gap: 6px; }
.tile .label { font-size: 13px; color: var(--text2); font-weight: 500; margin-top: 2px; }
.tile .dot { width: 10px; height: 10px; }
.tile.active { box-shadow: inset 0 0 0 2px var(--tile-color); }
.tile.new { --tile-color: var(--red); }
.tile.followup { --tile-color: var(--orange); }
.tile.responded { --tile-color: var(--green); }

/* ---------- grouped lists ---------- */
.section-head {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text2);
  margin: 22px 16px 7px; display: flex; justify-content: space-between; align-items: baseline;
}
.section-head button { text-transform: none; letter-spacing: 0; font-size: 15px; border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; }
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.group + .group { margin-top: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--text2); font-size: 15px; }

.row {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; color: var(--text);
  position: relative; min-height: 44px;
}
.row::after { content: ""; position: absolute; left: 38px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.row:last-child::after { display: none; }
.row:active { background: var(--fill); }
.row .dot { margin-top: 7px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-age { font-size: 15px; color: var(--text2); white-space: nowrap; }
.row-sub { font-size: 15px; color: var(--text2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-snip { font-size: 15px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; }
.chev { color: var(--text3); align-self: center; font-size: 20px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.s-new { background: var(--red); }
.s-followup { background: var(--orange); }
.s-responded { background: var(--green); }
.s-closed { background: var(--gray); }
.s-booked { background: var(--green); }

.badge {
  font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; white-space: nowrap;
  color: var(--badge, var(--gray)); background: color-mix(in srgb, var(--badge, var(--gray)) 15%, transparent);
}
.badge.contract { --badge: var(--indigo); }
.badge.new { --badge: var(--red); }
.badge.followup { --badge: var(--orange); }
.badge.responded { --badge: var(--green); }
.badge.closed { --badge: var(--gray); }

/* ---------- footer / banners ---------- */
.footer { text-align: center; font-size: 13px; color: var(--text2); margin: 22px 0 8px; line-height: 1.8; }
.link { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; font-size: inherit; }
.banner {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
  display: flex; gap: 12px; align-items: center; font-size: 15px;
}
.banner p { margin: 0; flex: 1; color: var(--text2); }
.banner strong { color: var(--text); display: block; }

/* ---------- lead detail ---------- */
.lead-head { padding: 16px 0 4px; }
.lead-head h1 { font-size: 28px; font-weight: 700; margin: 0 0 6px; line-height: 1.15; }
.lead-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--text2); font-size: 15px; }
.kv { display: flex; gap: 12px; padding: 11px 16px; position: relative; font-size: 16px; }
.kv::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.kv:last-child::after { display: none; }
.kv .k { color: var(--text2); width: 92px; flex: none; }
.kv .v { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.convo { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: 18px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.lead { background: var(--card); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.us { background: var(--fill); align-self: flex-end; border-bottom-right-radius: 6px; }
.msg-time { font-size: 12px; color: var(--text2); margin: 0 6px; }
.msg-time.us { align-self: flex-end; }
.msg.clamped { max-height: 9.5em; overflow: hidden; position: relative; cursor: pointer; }
.msg.clamped::after {
  content: "Show more"; position: absolute; right: 0; bottom: 0; left: 0; padding: 18px 13px 7px; font-size: 13px;
  color: var(--accent); background: linear-gradient(transparent, var(--msg-bg) 55%); text-align: right;
}
.msg.lead { --msg-bg: var(--card); }
.msg.us { --msg-bg: var(--bg); }

.drafts { display: flex; flex-direction: column; gap: 12px; }
.draft { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.draft-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.draft-label { font-weight: 600; font-size: 15px; }
.draft-body { font-size: 15px; white-space: pre-wrap; color: var(--text); }
.draft-warn { color: var(--red); font-size: 13px; font-weight: 600; margin-top: 6px; }
.chip-btn {
  border: 0; border-radius: 14px; padding: 5px 12px; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}

.compose { padding: 0; }
.to-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 0.5px solid var(--sep); font-size: 16px; }
.to-row label { color: var(--text2); }
.to-row input { flex: 1; border: 0; background: none; outline: none; min-width: 0; font-size: 16px; }
.to-alts { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px 0; }
.to-alts button { border: 0; background: var(--fill); border-radius: 12px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
textarea#body {
  width: 100%; min-height: 180px; border: 0; background: none; outline: none; resize: none;
  padding: 12px 16px 14px; font-size: 16px; line-height: 1.4;
}

.btn {
  display: block; width: 100%; border: 0; border-radius: var(--radius); padding: 14px; font-size: 17px; font-weight: 600;
  cursor: pointer; text-align: center; margin-top: 12px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: 0.45; }
.btn.plain { background: var(--card); color: var(--accent); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { font-weight: 500; }
.btn.danger { color: var(--red); }
.btn.good { color: var(--green); }

.err-box { background: var(--card); border-radius: var(--radius); padding: 12px 14px; color: var(--red); font-size: 15px; }
.muted { color: var(--text2); font-size: 15px; }

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.signin img { width: 88px; height: 88px; border-radius: 20px; margin-bottom: 16px; }
.signin h1 { margin: 0; font-family: "Carentro", Georgia, serif; font-weight: normal; font-size: 34px; color: var(--accent); }
.signin p { color: var(--text2); margin: 4px 0 28px; }
.signin .btn { max-width: 320px; }
.signin .err { color: var(--red); font-size: 15px; margin-top: 16px; max-width: 320px; }

/* ---------- tab bar ---------- */
body:has(.tabbar) { padding-bottom: calc(76px + var(--safe-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 0;
  padding: 6px 16px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabbar a { flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--gray); font-size: 11px; font-weight: 500; position: relative; padding: 2px 0; }
.tabbar a.on { color: var(--accent); }
.tabbar svg { width: 26px; height: 26px; }
.tab-badge { position: absolute; top: -2px; left: calc(50% + 6px); background: var(--red); color: #fff; font-size: 11px; font-weight: 600; border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }
body:has(.tabbar) #toast { bottom: calc(84px + var(--safe-bottom)); }

/* ---------- calendar ---------- */
.cal { padding: 4px 8px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 6px; }
.cal-head .icon-btn svg { width: 12px; height: 20px; }
.cal-head .flip svg { transform: scaleX(-1); }
.cal-title { font-weight: 600; font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow span { text-align: center; font-size: 12px; font-weight: 600; color: var(--text2); padding: 4px 0; }
.cal-cell { border: 0; background: none; padding: 4px 0 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 46px; }
.cal-cell .num { width: 34px; height: 34px; line-height: 34px; border-radius: 50%; font-size: 17px; text-align: center; }
.cal-cell.past .num { color: var(--text2); }
.cal-cell.today .num { color: var(--accent); font-weight: 700; }
.cal-cell.sel .num { background: var(--accent); color: #fff; font-weight: 600; }
.cal-cell .dots { display: flex; gap: 3px; height: 6px; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.cal-today { display: block; margin: 4px auto 0; font-size: 15px; }

/* ---------- forms ---------- */
.form .field { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 46px; position: relative; font-size: 16px; }
.form .field::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--sep); }
.form .field:last-child::after { display: none; }
.form .field > span { width: 92px; flex: none; color: var(--text); }
.form .field.top { align-items: flex-start; padding-top: 12px; padding-bottom: 8px; }
.form input, .form textarea { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; padding: 12px 0; text-align: left; }
.form textarea { padding: 0; resize: vertical; line-height: 1.4; }
.form input[type="date"], .form input[type="time"] { -webkit-appearance: none; appearance: none; color: var(--accent); min-height: 22px; }
.nav-action { font-weight: 600; min-width: 72px; justify-content: flex-end; }

/* ---------- misc ---------- */
.loading-screen { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--fill); border-top-color: var(--text2);
  animation: spin .8s linear infinite; display: inline-block; vertical-align: middle;
}
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--card); border-radius: var(--radius); padding: 16px; color: var(--text2); font-size: 15px; display: flex; gap: 10px; align-items: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: rgba(30, 30, 30, 0.92); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==================================================================
   Brand layer: Cart & Company look (ink borders, hard offset shadows,
   Zilla Slab type, terracotta accent). Overrides the base styles above.
   ================================================================== */
body { font-family: var(--font); font-size: 17px; }
button, input, textarea, select { font-family: var(--font); }

.topbar, .navbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1.5px solid var(--ink);
}
.topbar.scrolled { border-bottom-color: var(--ink); }
.brand img { border-radius: 4px; border: 1.5px solid var(--ink); }
.wordmark { color: var(--ink); font-size: 22px; }
.nav-title { font-weight: 700; }
.back, .icon-btn, .link, .section-head button { color: var(--accent); }

.large-title {
  font-weight: 700; font-size: 34px; letter-spacing: 0; margin: 14px 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.large-title::after { content: "✦"; color: var(--accent); font-size: 18px; }

/* cards: ink border + hard offset shadow */
.group, .tile, .draft, .banner, .skeleton, .err-box {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.group + .group { margin-top: 16px; }
.tiles { gap: 12px; margin-bottom: 24px; }
.tile { padding: 10px 12px 12px; transition: transform .08s, box-shadow .08s; }
.tile .count { font-weight: 700; }
.tile .label { color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; line-height: 1.3; margin-top: 4px; }
.tile.active { box-shadow: 4px 4px 0 var(--tile-color); border-color: var(--tile-color); }

.section-head {
  font-size: 12px; font-weight: 600; letter-spacing: .1em; color: var(--text2);
  margin: 26px 2px 9px;
}
.section-head button { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; }

.row-name { font-weight: 700; }
.row-sub, .row-snip, .row-age { color: var(--text2); }
.row::after { border-bottom: 1px solid var(--sep); }
.row:active, .tile:active, .btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.row:active { box-shadow: none; transform: none; }

.badge { border-radius: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 10.5px; padding: 2px 6px; }

/* buttons */
.btn {
  border: 1.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 15px;
  transition: transform .08s, box-shadow .08s; margin-top: 16px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.plain { background: var(--card); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.good { color: var(--green); }
.chip-btn {
  border: 1.5px solid var(--ink); border-radius: 4px; background: var(--card); color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 700;
}

/* lead detail */
.lead-head h1 { font-weight: 700; font-size: 30px; }
.kv .k { color: var(--text2); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding-top: 2px; }
.kv::after { border-bottom: 1px solid var(--sep); }
.msg { border-radius: 10px; font-size: 16px; }
.msg.lead { background: var(--card); border: 1.5px solid var(--ink); border-bottom-left-radius: 3px; }
.msg.us { background: #F4F3EF; border: 1.5px solid var(--sep); border-bottom-right-radius: 3px; }
.msg.us { --msg-bg: #F4F3EF; }
.msg-time { color: var(--text2); font-size: 12px; }
.draft-label { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 13px; color: var(--accent); }
.draft-body { font-size: 16px; }
.to-row { border-bottom: 1px solid var(--sep); }
textarea#body { font-size: 16px; }

/* tab bar */
.tabbar { background: rgba(255, 255, 255, 0.96); border-top: 1.5px solid var(--ink); }
.tabbar a { color: var(--text2); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.tabbar a.on { color: var(--accent); }
.tab-badge { border: 1.5px solid var(--card); }

/* calendar */
.cal-title { font-weight: 700; }
.cal-dow span { font-weight: 700; letter-spacing: .06em; }
.cal-cell.today .num { color: var(--accent); }
.cal-cell.sel .num { background: var(--ink); color: #fff; }
.cal-cell .dots i { background: var(--accent); }
.s-booked { background: var(--accent); }
.form .field > span { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--text2); }
.form .field::after { border-bottom: 1px solid var(--sep); }

/* footer + sign-in */
.footer { color: var(--text2); }
.signin h1 { color: var(--ink); font-size: 38px; }
.signin p { text-transform: uppercase; letter-spacing: .14em; font-size: 13px; font-weight: 600; color: var(--text2); }
.signin p::before, .signin p::after { content: " ✦ "; color: var(--accent); }
.signin img { border: 1.5px solid var(--ink); box-shadow: var(--shadow); border-radius: 12px; }
#toast { background: var(--ink); border-radius: 4px; font-weight: 600; }
