/* ==========================================================================
   Cappuccinos — shared design system
   Light, warm, premium, minimal. One system across funnel + both dashboards.
   Paper / bone-white ground, deep espresso ink, one caramel accent.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter+Tight:wght@400;500;600;700&display=swap');

:root {
  /* ground — warm paper, never stark white */
  --bg:        #f4efe4;
  --bg-raised: #fbf8f1;
  --bg-sunk:   #ece4d4;
  --line:      #ddd1bd;
  --line-soft: #e7ddca;

  /* ink — deep espresso */
  --espresso:  #2a2019;   /* primary text / headings */
  --fg:        #3a2e24;
  --fg-dim:    #6d5f50;
  --fg-faint:  #9b8a76;

  /* the one accent — caramel / coffee brown */
  --accent:      #9c6b2f;
  --accent-deep: #83571f;
  --accent-tint: #efe4d1;
  --accent-ink:  #fffaf1;   /* text on a filled accent surface */

  /* states — kept earthy so they sit in the palette */
  --danger:    #b0402e;
  --danger-bg: #f3ddd5;
  --ok:        #3f7a4e;
  --warn:      #a9782c;

  --radius:    14px;
  --radius-sm: 10px;
  --gap:       clamp(16px, 4vw, 28px);
  --maxw:      1180px;

  --shadow:    0 1px 2px rgba(42,32,25,0.04), 0 22px 48px -24px rgba(42,32,25,0.22);
  --font:      'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --serif:     'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  font-size: 16px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--espresso); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 400; font-optical-sizing: auto; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h3 { font-size: 1.05rem; }
p  { margin: 0; }
a  { color: var(--accent-deep); }

.muted  { color: var(--fg-dim); }
.faint  { color: var(--fg-faint); }
.tiny   { font-size: 0.8rem; }
.mono   { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right  { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---- layout ------------------------------------------------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gap); }
.stack > * + * { margin-top: var(--stack, 16px); }
.row  { display: flex; gap: 12px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---- top bar ---------------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.appbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.08em; color: var(--espresso); }
.brand .dot { width: 20px; height: 20px; }
.brand small { color: var(--fg-faint); font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.62rem; }

/* ---- cards ----------------------------------------------------------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.sunk { background: var(--bg-sunk); box-shadow: none; }
.card.pad-lg { padding: clamp(20px, 5vw, 36px); }

/* ---- stat tiles --------------------------------------------------- */
.stat { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-faint); }
.stat .v { font-size: 1.6rem; font-weight: 600; color: var(--espresso); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 0.78rem; color: var(--fg-dim); margin-top: 2px; }

/* ---- buttons ---------------------------------------------------------- */
button, .btn {
  font-family: inherit; font-size: 0.92rem; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-raised); color: var(--fg);
  padding: 10px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  transition: background .14s ease, border-color .14s ease, transform .04s ease, opacity .14s ease;
  text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); background: #fff; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #dcb6ab; background: var(--danger-bg); }
.btn-danger:hover { border-color: var(--danger); background: #eed0c6; }
.btn-sm { padding: 7px 11px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; }

/* ---- forms ---------------------------------------------------------- */
label { display: block; font-size: 0.8rem; color: var(--fg-dim); margin-bottom: 6px; letter-spacing: 0.01em; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; width: 100%;
  background: #fff; color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
textarea { resize: vertical; min-height: 84px; }
.field + .field { margin-top: 14px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 0.84rem; cursor: pointer; user-select: none;
  color: var(--fg-dim); background: var(--bg-raised);
}
.chip input { display: none; }
.chip.on { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-tint); }

/* ---- badges ------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--fg-dim); background: var(--bg-raised);
  white-space: nowrap;
}
.badge.stale { color: var(--danger); border-color: #dcb6ab; background: var(--danger-bg); font-weight: 600; }
.badge.ok { color: var(--ok); border-color: #b8d2be; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.status-closed { color: var(--ok); border-color: #b8d2be; }
.badge.status-notclosed { color: var(--fg-faint); }
.badge.status-discussion { color: var(--warn); border-color: #e0cba0; }

/* ---- lead list ---------------------------------------------------- */
.lead {
  display: block; background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
}
.lead + .lead { margin-top: 10px; }
.lead:hover { border-color: var(--accent); }
.lead.is-stale { border-color: #dcb6ab; }
.lead .name { font-weight: 600; font-size: 1.02rem; color: var(--espresso); }
.lead .meta { color: var(--fg-dim); font-size: 0.84rem; margin-top: 3px; }
.lead .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---- table (owner) --------------------------------------------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { color: var(--fg-faint); font-weight: 500; font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; }
tbody tr:hover { background: var(--accent-tint); cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

/* ---- toast ----------------------------------------------------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  pointer-events: auto;
  background: var(--espresso); color: var(--bg);
  border-radius: 999px; padding: 11px 20px; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 12px 34px -12px rgba(42,32,25,0.45);
  animation: toastin .22s ease;
}
.toast.info { background: var(--bg-raised); color: var(--fg); border: 1px solid var(--line); }
.toast.err  { background: var(--danger); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* ---- modal / drawer ----------------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(42,32,25,0.32); backdrop-filter: blur(3px); z-index: 60; }
.drawer {
  position: fixed; z-index: 70; background: var(--bg); border-left: 1px solid var(--line);
  top: 0; right: 0; height: 100%; width: min(560px, 100%);
  border-radius: 0; overflow-y: auto; box-shadow: var(--shadow);
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(20px); opacity: .6; } }
.drawer .drawer-head { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line-soft); padding: 16px var(--gap); display: flex; justify-content: space-between; align-items: center; }
.drawer .drawer-body { padding: var(--gap); }
@media (max-width: 620px) { .drawer { width: 100%; } }

/* ---- misc ---------------------------------------------------- */
hr { border: none; border-top: 1px solid var(--line-soft); margin: 18px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-title { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-faint); margin-bottom: 10px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
