/* Lark Opportunity Engine — dashboard
   Aesthetic: precise operations console. Cool sage paper, forest ink,
   editorial serif for figures, signal orange reserved for things that
   actually need a human. */

:root {
  --paper:    #F1F3EE;
  --surface:  #FFFFFF;
  --sunken:   #E9ECE4;
  --ink:      #131711;
  --muted:    #626A5D;
  --faint:    #8D9486;
  --rule:     #DCE0D5;
  --rule-firm:#C6CCBB;

  --forest:   #1E3B2A;
  --moss:     #4C7C5B;
  --lime:     #7FA34F;
  --signal:   #BE5127;
  --gold:     #9A7B18;
  --slate:    #3F5E78;

  --r:   3px;
  --r-lg: 6px;
  --shadow: 0 1px 2px rgba(19,23,17,.05), 0 8px 24px -12px rgba(19,23,17,.18);
  --shadow-lg: 0 2px 6px rgba(19,23,17,.06), 0 32px 64px -28px rgba(19,23,17,.35);

  --serif: "Newsreader", Georgia, serif;
  --sans:  "Archivo", "Helvetica Neue", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Faint paper grain so large empty areas don't read as flat white. */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--rule-firm);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  letter-spacing: .005em;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--sunken); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn--solid { background: var(--forest); border-color: var(--forest); color: #F4F7F1; }
.btn--solid:hover { background: #17301F; border-color: #17301F; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 7px 10px; }
.btn--ghost:hover { background: var(--sunken); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--full { width: 100%; justify-content: center; padding: 10px; }
.btn--danger { color: var(--signal); border-color: #E4C4B5; }
.btn--danger:hover { background: #FBEFE9; }
.btn:disabled { opacity: .45; pointer-events: none; }

.input {
  font: inherit;
  padding: 8px 11px;
  border: 1px solid var(--rule-firm);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(76,124,91,.14); }
.input--sm { padding: 5px 9px; width: 90px; font-size: 13px; }
.input--search { width: 240px; }

/* ── Login ────────────────────────────────────────────────────── */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--paper);
}
.login__card {
  position: relative; z-index: 1;
  width: min(370px, 90vw);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 34px 30px;
  text-align: center;
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.login__mark { font-size: 22px; color: var(--moss); }
.login__title { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 10px 0 2px; letter-spacing: -.01em; }
.login__sub { color: var(--faint); font-size: 12px; margin: 0 0 24px; letter-spacing: .02em; }
.login__card .input { width: 100%; margin-bottom: 10px; }
.login__err { color: var(--signal); font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 13px 28px;
  background: rgba(241,243,238,.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.topbar__brand { display: flex; align-items: center; gap: 11px; }
.topbar__mark { font-size: 17px; color: var(--moss); }
.topbar__name { font-family: var(--serif); font-size: 17px; letter-spacing: -.01em; line-height: 1.2; }
.topbar__meta { font-size: 11px; color: var(--faint); letter-spacing: .04em; text-transform: uppercase; }
.topbar__ramp { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar__actions { display: flex; gap: 8px; }

.ramp { display: flex; align-items: center; gap: 10px; }
.ramp__label { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.ramp__bar { width: 92px; height: 5px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.ramp__fill { height: 100%; width: 0; background: var(--moss); border-radius: 3px; transition: width .5s cubic-bezier(.2,.7,.3,1); }
.ramp__count { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ramp__count b { color: var(--ink); font-weight: 500; }

.pill {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px;
  background: #F5E7DF; color: var(--signal); border: 1px solid #E9CDBE;
}
.pill.is-live { background: #E4EFE3; color: var(--forest); border-color: #C6DCC4; }

/* ── Layout ───────────────────────────────────────────────────── */
.wrap { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 26px 28px 80px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--rule);
}
.panel__head--tools { padding: 12px 14px; }
.panel__title { font-family: var(--serif); font-weight: 400; font-size: 17px; margin: 0; letter-spacing: -.01em; }
.panel__note { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

/* ── Stat cards ───────────────────────────────────────────────── */
.stats {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 15px 16px 14px;
  box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.stat:nth-child(1){animation-delay:.02s} .stat:nth-child(2){animation-delay:.06s}
.stat:nth-child(3){animation-delay:.1s}  .stat:nth-child(4){animation-delay:.14s}
.stat:nth-child(5){animation-delay:.18s} .stat:nth-child(6){animation-delay:.22s}
.stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.stat__value {
  font-family: var(--serif); font-weight: 400; font-size: 34px;
  line-height: 1.1; margin-top: 7px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat__sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat--alert { border-color: #E4C4B5; background: #FDF6F2; }
.stat--alert .stat__value { color: var(--signal); }

/* ── Funnel ───────────────────────────────────────────────────── */
.funnel__rows { padding: 14px 18px 18px; display: grid; gap: 9px; }
.frow { display: grid; grid-template-columns: 128px 1fr 52px; align-items: center; gap: 12px; }
.frow__label { font-size: 12.5px; color: var(--muted); }
.frow__track { height: 22px; background: var(--sunken); border-radius: var(--r); overflow: hidden; }
.frow__bar {
  height: 100%; border-radius: var(--r);
  background: var(--moss);
  transform-origin: left; animation: grow .6s cubic-bezier(.2,.7,.3,1) both;
}
.frow__val { font-family: var(--mono); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 3px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); }
.tab {
  border: none; background: none; padding: 9px 14px;
  font-size: 13.5px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--forest); border-bottom-color: var(--forest); }
.tab__badge {
  display: inline-block; margin-left: 5px; padding: 1px 6px;
  background: var(--signal); color: #fff; border-radius: 10px;
  font-size: 11px; font-family: var(--mono);
}

.filters { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--rule-firm); background: var(--surface);
  padding: 4px 10px; border-radius: 20px; font-size: 12px; color: var(--muted);
  transition: all .15s;
}
.chip:hover { border-color: var(--faint); color: var(--ink); }
.chip.is-active { background: var(--forest); border-color: var(--forest); color: #F4F7F1; }

/* ── Table ────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--faint);
  padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--sunken); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }

.biz__name { font-weight: 500; }
.biz__sub { font-size: 12px; color: var(--faint); margin-top: 1px; }
.truncate { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.score { display: inline-block; min-width: 30px; padding: 2px 7px; border-radius: var(--r); background: var(--sunken); font-size: 12.5px; }
.score--hot { background: #E4EFE3; color: var(--forest); font-weight: 500; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge--grey   { background: var(--sunken); color: var(--muted); }
.badge--green  { background: #E4EFE3; color: var(--forest); border-color: #C9DDC7; }
.badge--slate  { background: #E3EAF0; color: var(--slate); border-color: #C9D7E3; }
.badge--amber  { background: #F6EFD8; color: var(--gold); border-color: #E6D9B0; }
.badge--signal { background: #F7E5DC; color: var(--signal); border-color: #E9CDBE; }
.badge--faint  { background: transparent; color: var(--faint); border-color: var(--rule-firm); }

.tablefoot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; font-size: 12px; color: var(--faint);
  border-top: 1px solid var(--rule); background: #FBFCFA;
}
.empty { padding: 44px 20px; text-align: center; color: var(--faint); font-size: 13.5px; }

/* ── Replies ──────────────────────────────────────────────────── */
.replylist { display: grid; }
.reply { padding: 15px 18px; border-bottom: 1px solid var(--rule); }
.reply:last-child { border-bottom: none; }
.reply__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 7px; }
.reply__who { font-weight: 500; }
.reply__from { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.reply__time { margin-left: auto; font-size: 12px; color: var(--faint); }
.reply__subject { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.reply__body {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--sunken); border-radius: var(--r); padding: 11px 13px;
  white-space: pre-wrap; max-height: 190px; overflow: auto; color: #2A3126;
}
.reply__foot { display: flex; gap: 8px; margin-top: 10px; align-items: center; }

/* ── Settings ─────────────────────────────────────────────────── */
.settings { padding: 4px 18px 8px; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 16px 0; border-bottom: 1px solid var(--rule);
}
.setting:last-child { border-bottom: none; }
.setting__label { font-weight: 500; }
.setting__help { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; max-width: 52ch; }
.setting__control { display: flex; gap: 7px; align-items: center; }
.setting__value { font-size: 13px; color: var(--muted); }

/* ── Drawer ───────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(19,23,17,.32);
  animation: fade .25s ease both;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(560px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: slide .34s cubic-bezier(.2,.7,.3,1) both;
}
.drawer__inner { padding: 26px 28px 60px; }
.drawer__top { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 4px; }
.drawer__title { font-family: var(--serif); font-weight: 400; font-size: 25px; line-height: 1.2; letter-spacing: -.015em; margin: 0; }
.drawer__close { margin-left: auto; }
.drawer__meta { font-size: 12.5px; color: var(--faint); margin: 2px 0 20px; }

.dsec { margin-top: 24px; }
.dsec__title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); margin: 0 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-word; }
.kv a { color: var(--slate); }

.draft { border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.draft__subject {
  padding: 9px 12px; border-bottom: 1px solid var(--rule);
  background: #FBFCFA; font-weight: 500; font-size: 13.5px;
}
.draft__body {
  padding: 13px; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.65; white-space: pre-wrap; color: #2A3126;
}
.draft__foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--rule); background: #FBFCFA; align-items: center; }
.draft textarea, .draft input.edit {
  width: 100%; border: none; outline: none; background: transparent;
  font: inherit; color: inherit; resize: vertical;
}
.draft__body textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.65; min-height: 200px; }

.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 13px 1fr auto; gap: 11px; align-items: start; padding: 7px 0; font-size: 12.5px; }
.tl__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rule-firm); margin-top: 6px; }
.tl__dot--on { background: var(--moss); }
.tl__time { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.tl__detail { color: var(--faint); }

.actions { display: flex; flex-wrap: wrap; gap: 7px; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 60; background: var(--forest); color: #F4F7F1;
  padding: 10px 18px; border-radius: var(--r); font-size: 13px;
  box-shadow: var(--shadow-lg); animation: rise .3s cubic-bezier(.2,.7,.3,1) both;
}
.toast.is-err { background: var(--signal); }

/* ── Motion ───────────────────────────────────────────────────── */
@keyframes rise  { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes grow  { from { transform: scaleX(0); } to { transform: scaleX(1); } }

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

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .topbar__ramp { order: 3; margin-left: 0; width: 100%; }
  .wrap { padding: 18px 14px 60px; }
  .input--search { width: 100%; }
  .panel__head--tools { flex-direction: column; align-items: stretch; }
  .frow { grid-template-columns: 96px 1fr 44px; }
  .setting { flex-direction: column; align-items: flex-start; gap: 10px; }
}
