/* ==========================================================================
   La Roca — shared design system
   Dark, premium, minimal. One neutral system across funnel + both dashboards.
   Monochrome: near-black ground, bone foreground. No colour accent.
   ========================================================================== */

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

:root {
  /* ground */
  --bg:        #0a0a0b;
  --bg-raised: #121214;
  --bg-sunk:   #0d0d0f;
  --line:      #232326;
  --line-soft: #1a1a1d;

  /* foreground */
  --bone:      #f4f1ea;   /* primary text / the "accent" */
  --fg:        #e7e4dd;
  --fg-dim:    #a6a29a;
  --fg-faint:  #6c6a64;

  /* states (kept desaturated to stay premium, not "colourful") */
  --danger:    #e8654e;
  --danger-bg: #2a1512;
  --ok:        #7fbf8f;
  --warn:      #d8b46b;

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

  --shadow:    0 1px 0 rgba(255,255,255,0.02) inset, 0 20px 50px -20px rgba(0,0,0,0.7);
  --font:      'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-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 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
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: inherit; }

.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.02em; }
.brand .dot { width: 18px; height: 18px; }
.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;
}
.card.sunk { background: var(--bg-sunk); }
.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; }
.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; 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: #34343a; background: #16161a; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--bone); color: #0a0a0b; border-color: var(--bone); font-weight: 600; }
.btn-primary:hover { background: #fff; border-color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #3a2420; background: var(--danger-bg); }
.btn-danger:hover { border-color: var(--danger); background: #331a16; }
.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: var(--bg-sunk); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none;
  transition: border-color .14s ease, background .14s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--bone); background: #101012; }
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-sunk);
}
.chip input { display: none; }
.chip.on { border-color: var(--bone); color: var(--bone); background: #17171a; }

/* ---- 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-sunk);
  white-space: nowrap;
}
.badge.stale { color: var(--danger); border-color: #3a2420; background: var(--danger-bg); font-weight: 600; }
.badge.ok { color: var(--ok); border-color: #21341f; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.status-closed { color: var(--ok); border-color: #21341f; }
.badge.status-notclosed { color: var(--fg-faint); }
.badge.status-discussion { color: var(--warn); border-color: #3a3320; }

/* ---- 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;
}
.lead + .lead { margin-top: 10px; }
.lead:hover { border-color: #34343a; }
.lead.is-stale { border-color: #3a2420; }
.lead .name { font-weight: 600; font-size: 1.02rem; }
.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); }
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: #141417; 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(--bone); color: #0a0a0b;
  border-radius: 999px; padding: 11px 20px; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 12px 40px -12px rgba(0,0,0,0.8);
  animation: toastin .22s ease;
}
.toast.info { background: var(--bg-raised); color: var(--fg); border: 1px solid var(--line); }
.toast.err  { background: var(--danger); color: #1a0d0a; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* ---- modal / drawer ----------------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); z-index: 60; }
.drawer {
  position: fixed; z-index: 70; background: var(--bg); border: 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(--fg-faint); border-top-color: var(--bone); 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; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.appbar .btn-ghost { color: var(--fg); }
.appbar .btn-ghost:hover { color: var(--bone, var(--espresso)); }

/* ===========================================================================
   v2 dashboard components
   =========================================================================== */
:root { --accent: var(--bone); --hover: #141417; --hover-2: #16161a; }

/* skeleton shimmer */
.skel {
  height: 12px; border-radius: 6px; margin: 7px 0;
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--line) 37%, var(--line-soft) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
.skel:first-child { margin-top: 0; } .skel:last-child { margin-bottom: 0; }
td .skel { margin: 0; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* sticky sub-bar (sales) */
.subbar {
  position: sticky; top: 60px; z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 0;
}
.subbar .wrap { display: flex; align-items: center; gap: 10px; }

/* segmented tabs */
.tabs { display: inline-flex; gap: 4px; background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tab {
  border: none; background: transparent; color: var(--fg-dim);
  font: inherit; font-size: .82rem; font-weight: 500;
  padding: 6px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab .pill { font-size: .72rem; background: var(--line); color: var(--fg-dim); border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center; }
.tab.on { background: var(--accent); color: #0a0a0b; }
.tab.on .pill { background: rgba(10,10,11,.18); color: #0a0a0b; }

/* urgency edge on lead cards */
.lead { position: relative; }
.lead.u-hot  { border-color: #3a2420; }
.lead.u-hot::before, .lead.u-warm::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px;
}
.lead.u-hot::before  { background: var(--danger); }
.lead.u-warm::before { background: var(--warn); }
.lead .subline { color: var(--fg-faint); font-size: .78rem; margin-top: 6px; }

/* one-tap outcome row */
.quick { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.quick button { font-size: .78rem; padding: 6px 10px; }

/* attention strip (owner) */
.attn { display: flex; gap: 10px; flex-wrap: wrap; }
.attn-item {
  flex: 1; min-width: 150px; text-align: left; cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; color: inherit; font: inherit;
  transition: border-color .14s, background .14s;
}
.attn-item:hover { border-color: #34343a; background: var(--hover); }
.attn-item .n { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.attn-item .l { font-size: .78rem; color: var(--fg-dim); margin-top: 4px; }
.attn-item.warn .n { color: var(--danger); }
.attn-item.ok .n { color: var(--ok); }

/* sparkline + trend */
.spark { width: 100%; height: 30px; display: block; margin-top: 8px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: .9; }
.spark-fill { fill: var(--accent); opacity: .08; stroke: none; }
.trend { font-size: .74rem; font-weight: 600; }
.trend.good { color: var(--ok); } .trend.bad { color: var(--danger); } .trend.flat { color: var(--fg-faint); }
.stat .toprow { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

/* sortable table headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--fg-dim); }
th.sortable .arr { opacity: .4; margin-left: 4px; }
th.sortable.asc .arr, th.sortable.desc .arr { opacity: 1; }

/* inline-editable cells */
td.editable { position: relative; }
td.editable:hover { background: var(--hover); }
td select.inline, td .inline-input {
  background: var(--bg-sunk); border: 1px solid var(--line); color: var(--fg);
  border-radius: 8px; padding: 5px 8px; font: inherit; font-size: .84rem; max-width: 150px;
}

/* bulk selection bar */
.bulkbar {
  position: sticky; bottom: 0; z-index: 20; margin-top: 10px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}

/* saved-view chips */
.views { display: flex; gap: 7px; flex-wrap: wrap; }
.view-chip {
  font-size: .8rem; padding: 6px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-sunk); color: var(--fg-dim);
}
.view-chip.on { border-color: var(--accent); color: var(--accent); background: var(--hover-2); }

/* queued / unsent badge */
.badge.queued { color: var(--warn); border-color: #3a3320; }

/* team + settings rows */
.trow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.trow:last-child { border-bottom: none; }
.trow .grow { min-width: 0; }
.trow input, .trow select { max-width: 160px; }

/* next-lead CTA */
.cta-next { background: var(--accent); color: #0a0a0b; border-color: var(--accent); font-weight: 600; }
.cta-next:hover { background: #fff; border-color: #fff; }

@media (max-width: 640px) {
  .subbar .wrap { flex-wrap: wrap; }
  .tabs { width: 100%; justify-content: space-between; }
}

/* ---------------------------------------------------------------- planning / tasks */
.tab.hidden, .hidden { display: none !important; }
.row.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
select.inline {
  font-size: .82rem; padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-sunk); color: var(--fg);
}

.task-group { display: flex; flex-direction: column; gap: 10px; }
.task-group + .task-group { margin-top: 20px; }
.task-group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-weight: 600; font-size: .9rem; color: var(--fg-dim);
  padding-bottom: 4px; border-bottom: 1px solid var(--line-soft);
}

.task {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: .95rem; }
.task-desc { font-size: .84rem; color: var(--fg-dim); margin-top: 3px; white-space: pre-wrap; }
.task-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--fg-faint); margin-top: 7px;
}
.task-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.task.overdue { border-left-color: var(--danger); }
.task.is-done { opacity: .62; }
.task.is-done .task-title { text-decoration: line-through; }

@media (max-width: 640px) {
  .task { flex-direction: column; }
  .task-actions { width: 100%; }
  .task-actions .btn { flex: 1; }
}
