/* Lead Command Center */
:root {
  --bg: #f4f3ee; --card: #ffffff; --ink: #15211c; --muted: #68756f; --faint: #98a39d; --line: #e3e1d8; --soft: #f0efe8;
  --brand: #0b6e4f; --brand-dark: #07513a; --brand-tint: #e3f2ea; --side: #0f221b; --side-ink: #b9cdc3; --side-line: #1d3a2f;
  --hot: #dc3d43; --hot-bg: #fdecec; --warm: #c77700; --warm-bg: #fdf1dc; --cold: #2f6fdb; --cold-bg: #e8f0fd;
  --ok: #0b6e4f; --err: #c0332f; --radius: 12px; --shadow: 0 1px 2px rgba(20, 33, 28, .05), 0 4px 16px rgba(20, 33, 28, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; } .nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.mt { margin-top: 14px; } .mt2 { margin-top: 22px; } .mb { margin-bottom: 14px; }
.hide { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 12px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand i { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #1fb57f, #0b6e4f); display: grid; place-items: center; font-style: normal; font-size: 15px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--side-ink); letter-spacing: 0; }
.nav-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6f8a7e; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--side-ink); font-size: 13.5px; }
.nav a:hover { background: var(--side-line); color: #fff; text-decoration: none; }
.nav a.on { background: #1b4a39; color: #fff; font-weight: 550; }
.nav a .ic { width: 18px; text-align: center; opacity: .9; }
.nav a b { margin-left: auto; background: var(--hot); color: #fff; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 0 7px; line-height: 18px; }
.nav a b.calm { background: #2c5a48; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(244, 243, 238, .92); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
.top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .search { flex: 1; max-width: 360px; margin-left: auto; }
.top .search input { width: 100%; }
.burger { display: none; border: 0; background: none; font-size: 20px; padding: 4px 6px; cursor: pointer; }
.page { padding: 20px 24px 60px; max-width: 1400px; }
.pilot { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 30px; font-size: 12.5px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.pilot.on { background: var(--brand-tint); color: var(--brand-dark); border-color: #b9dfcd; }
.pilot.off { background: var(--hot-bg); color: var(--hot); border-color: #f5c6c7; }
.pilot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pilot.on::before { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.bell { position: relative; border: 1px solid var(--line); background: var(--card); border-radius: 9px; width: 36px; height: 36px; cursor: pointer; font-size: 15px; }
.bell b { position: absolute; top: -5px; right: -5px; background: var(--hot); color: #fff; border-radius: 20px; font-size: 10.5px; padding: 0 5px; line-height: 16px; }
.drop { position: absolute; right: 24px; top: 58px; width: 360px; max-width: calc(100vw - 24px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(20, 33, 28, .16); max-height: 70vh; overflow: auto; z-index: 30; }
.drop a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--soft); color: var(--ink); }
.drop a:hover { background: var(--soft); text-decoration: none; }
.drop a.unread { background: #f3faf6; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--soft); flex-wrap: wrap; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: var(--ink); }
.kpi:hover { text-decoration: none; border-color: #c9c6ba; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 680; letter-spacing: -.03em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 11.5px; margin-top: 2px; color: var(--muted); }
.kpi .d.up { color: var(--ok); } .kpi .d.down { color: var(--err); }
.kpi.hot .v { color: var(--hot); }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 9px; padding: 7px 13px; font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c2bfb2; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--err); } .btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; } .btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .55; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=url], input[type=file], select, textarea {
  width: 100%; border: 1px solid #d5d2c6; background: #fff; border-radius: 9px; padding: 8px 10px; font: inherit; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd4bd; outline-offset: 0; border-color: var(--brand); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input[type=color] { width: 40px; height: 34px; padding: 2px; border: 1px solid #d5d2c6; border-radius: 8px; background: #fff; }
.field { display: block; margin-bottom: 14px; }
.field > span, label.lbl { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.field em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.fgrid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
form.inline { display: inline; }

/* Tables */
.tw { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfaf7; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fbfaf6; }
.tbl td.act { white-space: nowrap; text-align: right; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 20px; padding: 1px 9px; line-height: 19px; white-space: nowrap; background: var(--soft); color: var(--muted); }
.temp-hot { background: var(--hot-bg); color: var(--hot); } .temp-warm { background: var(--warm-bg); color: var(--warm); } .temp-cold { background: var(--cold-bg); color: var(--cold); }
.badge.stage { background: color-mix(in srgb, var(--c) 13%, #fff); color: color-mix(in srgb, var(--c) 75%, #111); }
.badge.ok { background: var(--brand-tint); color: var(--brand-dark); } .badge.err { background: var(--hot-bg); color: var(--hot); } .badge.warn { background: var(--warm-bg); color: var(--warm); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); margin-right: 6px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--brand-tint); border-color: #b9dfcd; color: var(--brand-dark); }
.flash.err { background: var(--hot-bg); border-color: #f5c6c7; color: #9c2327; }
.flash.warn { background: var(--warm-bg); border-color: #f3d7a2; color: #7a4b00; }

/* Tabs & filters */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 13px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--brand-dark); border-color: var(--brand); } .tabs a:hover { text-decoration: none; color: var(--ink); }
.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg a { padding: 4px 11px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: 12.5px; white-space: nowrap; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); } .seg a:hover { text-decoration: none; }
.filters { display: grid; grid-template-columns: 1.6fr repeat(5, 1fr) auto; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--soft); }

/* Dashboard bits */
.alert-strip { display: grid; gap: 8px; margin-bottom: 16px; }
.alert-item { display: flex; gap: 12px; align-items: center; background: #fff8e8; border: 1px solid #f1dba6; border-radius: 10px; padding: 9px 14px; }
.alert-item b { font-weight: 600; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar { height: 10px; border-radius: 6px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--c, var(--brand)); min-width: 2px; }
.list > a, .list > div { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--soft); color: var(--ink); }
.list > :last-child { border-bottom: 0; }
.list > a:hover { background: #fbfaf6; text-decoration: none; }
.time { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 74px; font-size: 13px; }
.time.late { color: var(--err); }
.split { display: flex; height: 12px; border-radius: 7px; overflow: hidden; background: var(--soft); }
.split i { display: block; height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; }
.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--soft) 0); display: grid; place-items: center; flex: none; }
.ring span { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 680; font-size: 17px; }

/* Lead page */
.lead-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.brief { background: linear-gradient(180deg, #f1f8f4, #fff 70%); }
.brief h3 { color: var(--brand-dark); margin: 14px 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.brief h3:first-child { margin-top: 0; }
.score { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.chat { display: flex; flex-direction: column; height: min(72vh, 720px); }
.chat .msgs { flex: 1; overflow-y: auto; padding: 16px; background: #efeae0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; padding: 8px 11px; border-radius: 12px; font-size: 13.5px; position: relative; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; background: #fff; border-top-left-radius: 3px; }
.msg.out { align-self: flex-end; background: #d9f6dd; border-top-right-radius: 3px; }
.msg.out.human { background: #dbe9ff; }
.msg.failed { background: #fde3e3; }
.msg .meta { display: block; font-size: 10.5px; color: #6c7a73; margin-top: 3px; text-align: right; white-space: normal; }
.msg .who { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-dark); display: block; margin-bottom: 2px; }
.msg.human .who { color: #2456b5; }
.composer { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: #fff; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.composer textarea { min-height: 42px; max-height: 140px; flex: 1; min-width: 180px; }
.timeline > div { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.timeline > div::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.timeline > div.ai::before { background: var(--brand); }
details.pop { position: relative; }
details.pop > summary { list-style: none; cursor: pointer; }
details.pop > summary::-webkit-details-marker { display: none; }
details.box { border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; background: #fff; }
details.box > summary { padding: 11px 0; cursor: pointer; font-weight: 600; }
details.box[open] { padding-bottom: 14px; }

/* Chart (printable playbook) */
.chart-card { break-inside: avoid; }
.chart-card .bd { font-size: 13.5px; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--brand-dark); }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--soft); padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere; }
.codeblock { display: block; padding: 10px 12px; background: #17251f; color: #d6eadf; border-radius: 9px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; overflow-x: auto; white-space: pre; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 14px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 15% 0%, #dcefe5, transparent), var(--bg); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lead-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .lead-grid > .c3 { grid-column: 1 / -1; }
  .filters { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .burger { display: block; }
  .top { padding: 10px 14px; } .top .search { display: none; } .page { padding: 14px 14px 60px; }
  .g2, .g3, .g-main, .lead-grid, .fgrid, .fgrid.three { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  .msg { max-width: 90%; }
  .drop { right: 12px; }
  .hide-m { display: none !important; }
}
@media print {
  .side, .top, .no-print, .flash { display: none !important; }
  .shell { display: block; } .page { padding: 0; max-width: none; } body { background: #fff; }
  .card { box-shadow: none; }
}
