/* ==========================================================================
   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; }
