:root {
  --bg: #F4F6FB; --panel: #FFFFFF; --ink: #0B1733; --muted: #5E6B86; --line: #E2E7F1; --line-2: #EEF1F7;
  --blue: #3A6FD8; --blue-2: #E9F1FF; --teal: #16B89C; --red: #E5484D; --amber: #D98E04; --violet: #7C5CFF; --green: #1A9F63;
  --side: #07122A; --side-text: #AEBBD6; --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 2px; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 10px; }
h4 { font-size: 13px; margin: 14px 0 6px; }
code { font-family: var(--mono); font-size: 12px; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox] { width: auto; accent-color: var(--blue); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,123,255,.15); }
textarea { resize: vertical; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .block { display: block; } .red { color: var(--red); }
.pre { white-space: pre-wrap; word-break: break-word; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #C8D2E6; background: #FAFBFE; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1F6AF0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; } .btn.xs { padding: 3px 9px; font-size: 12px; } .btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; font-size: 16px; cursor: pointer; color: inherit; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--line-2); }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: #fff; letter-spacing: -.02em; padding: 0 8px 18px; }
.brand img { height: 28px; width: auto; display: block; }
.brand-sub { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #8FB0EE; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.18); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.side nav a.active { background: rgba(47,123,255,.18); color: #fff; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.svc { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #45526E; } .dot.on { background: var(--teal); }
.me b { display: block; color: #fff; font-size: 13px; } .me small { color: var(--side-text); }
.side-foot .btn { color: var(--side-text); } .side-foot .btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.main { min-width: 0; }
.topbar { display: none; }
.scrim { display: none; }

.page { padding: 28px 32px 60px; max-width: 1240px; }
.page.wide { max-width: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; }
.links { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { max-width: 360px; }
.filters select { width: auto; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input[type=date] { width: 160px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
td.row-actions { display: table-cell; white-space: nowrap; text-align: right; }
td.row-actions > * { margin-left: 4px; }
.detail-side .inline-form { flex-wrap: wrap; } .detail-side .inline-form input:first-child { flex: 1 1 100%; } .detail-side .inline-form input[type=date] { flex: 1; width: auto; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { font-size: 12px; color: var(--muted); display: block; }
.kpi b { font-size: 26px; letter-spacing: -.03em; display: block; margin: 2px 0; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.warn b { color: var(--red); }

.funnel { display: grid; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr 36px; gap: 10px; align-items: center; color: var(--ink); font-size: 13px; }
.funnel-row:hover { text-decoration: none; }
.funnel-row .bar { background: var(--line-2); height: 10px; border-radius: 5px; overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 5px; min-width: 2px; }
.funnel-row.lost .bar i { background: #B7C0D3; }
.funnel-row b { text-align: right; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list li > div { flex: 1; min-width: 0; }
.list li small { display: block; color: var(--muted); font-size: 12px; }
.list li input[type=checkbox] { margin-top: 3px; }
.list.tight li { padding: 7px 0; }
.list li.done span, .list li.done > div { text-decoration: line-through; color: var(--muted); }
.list.panel { padding: 4px 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.panel .table-wrap { border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: #F8FAFF; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.tag { font-size: 11px; background: var(--line-2); padding: 1px 7px; border-radius: 999px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: #E3F6EC; color: var(--green); } .badge.red { background: #FDE8E8; color: var(--red); }
.badge.blue { background: var(--blue-2); color: var(--blue); } .badge.amber { background: #FDF3DC; color: var(--amber); }
.badge.violet { background: #EFEAFF; color: var(--violet); }
.badge[class*="stage-"] { background: var(--blue-2); color: var(--blue); }
.badge.stage-prospect { background: var(--line-2); color: var(--muted); }
.badge.stage-live { background: #E3F6EC; color: var(--green); } .badge.stage-lost { background: #F1F2F5; color: #8A93A6; }
.badge.stage-agreement, .badge.stage-technical { background: #E6F7F4; color: #0E8C77; }
a.badge:hover { text-decoration: none; }
.chip { display: inline-block; font-size: 12px; border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; color: var(--ink); background: #fff; white-space: nowrap; }
.chip:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.finder { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; background: #FBFCFE; }
.notice { background: var(--blue-2); color: #1D4FA8; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 0 0 12px; }
.notice.amber { background: #FDF3DC; color: #8A5A00; }
.error { color: var(--red); margin: 0 0 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--blue); }
.tabs.big { margin-bottom: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { background: none; border: 0; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--blue-2); color: var(--blue); font-weight: 600; }

/* Detail */
.detail { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.detail-main { min-width: 0; }
.deal { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.deal-head { display: grid; gap: 8px; margin-bottom: 8px; }
.stage-select { font-weight: 600; color: var(--blue); background: var(--blue-2); border-color: transparent; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; margin: 0 0 8px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; word-break: break-word; }
.notebox { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 14px; display: grid; gap: 8px; }
.notebox textarea { border: 0; padding: 4px; box-shadow: none; }
.notebox .row-actions select { width: auto; flex: 1; max-width: 240px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line-2); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #C5CEDF; border: 2px solid #fff; }
.timeline .t-email_out::before { background: var(--blue); } .timeline .t-email_in::before { background: var(--violet); }
.timeline .t-linkedin::before { background: #0A66C2; } .timeline .t-stage_change::before { background: var(--teal); }
.timeline .t-inbound_lead::before { background: var(--amber); }
.t-head { font-size: 13px; } .t-body { margin-top: 4px; font-size: 13px; color: #334; background: #FAFBFD; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; }
.md { font-size: 13.5px; } .md p { margin: 0 0 8px; } .md ul { margin: 0 0 8px; padding-left: 18px; }
.email-body { background: #FAFBFD; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 12px; font-size: 13.5px; max-height: 55vh; overflow: auto; }

/* Pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: #EBEFF7; border-radius: 12px; padding: 8px; min-height: 200px; transition: background .15s; }
.col.over { background: #DCE7FF; }
.col.lost { background: #F0F1F4; }
.col-head { display: flex; justify-content: space-between; padding: 4px 6px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: grab; display: grid; gap: 3px; box-shadow: 0 1px 2px rgba(11,23,51,.04); }
.card:hover { border-color: #BFD0F5; }
.card small { font-size: 12px; color: var(--muted); }
.card .next { color: var(--ink); }
.card.stale { border-left: 3px solid var(--amber); }
.mobile-stage { display: none; margin-top: 6px; font-size: 12px; padding: 4px 6px; }

/* Research */
.research-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.country-list { position: sticky; top: 16px; padding: 12px; }
.country-list ul { list-style: none; margin: 10px 0 0; padding: 0; max-height: 70vh; overflow: auto; }
.country-list button { width: 100%; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 6px; font: inherit; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.country-list button:hover { background: var(--line-2); }
.country-list button.on { background: var(--blue-2); color: var(--blue); font-weight: 600; }
.country-list small { color: var(--muted); }

.steps-mini { margin: 0 0 10px; padding-left: 18px; font-size: 13px; }
.steps-mini li { margin-bottom: 3px; }
.seq.paused { opacity: .7; }
.steps-table td { padding: 6px; } .steps-table select { min-width: 160px; }
.checklist { display: grid; gap: 4px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 10px 0; }
.checklist label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.checklist label.disabled { color: var(--muted); }
.checklist small { color: var(--muted); }

/* Modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(7,18,42,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(7,18,42,.5); }
.modal.wide { width: min(780px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal footer > .muted { margin-right: auto; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: 380px; }
.toast.err { background: var(--red); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(900px 500px at 70% 0%, #16336f, transparent 60%), var(--side); padding: 16px; }
.login-box { background: #fff; border-radius: 16px; padding: 30px; width: min(380px, 100%); }
.login-box .brand { color: var(--ink); padding: 0 0 8px; }
.login-box .brand img { height: 40px; }
.login-box .brand-sub { color: var(--blue); border-left-color: var(--line); }
.loading-screen { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Responsive */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, 1fr); } .detail { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .menu-open .side { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(7,18,42,.4); z-index: 50; }
  .topbar { display: flex; align-items: center; gap: 8px; background: var(--side); padding: 10px 12px; position: sticky; top: 0; z-index: 40; }
  .topbar .brand { padding: 0; } .topbar .brand img { height: 24px; } .topbar .icon-btn { color: #fff; font-size: 20px; }
  .page { padding: 18px 16px 48px; }
  .cols, .grid2, .grid3, .research-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .country-list { position: static; } .country-list ul { max-height: 220px; }
  .funnel-row { grid-template-columns: 120px 1fr 30px; }
  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; }
  .col { min-height: 0; }
  .mobile-stage { display: block; }
  .inline-form { flex-wrap: wrap; } .inline-form input[type=date] { width: auto; flex: 1; }
}

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.lang-switch button { background: none; border: 0; padding: 4px 9px; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang-switch button.on { background: var(--blue); color: #fff; }
.lang-switch.dark { background: transparent; border-color: rgba(255,255,255,.15); }
.lang-switch.dark button { color: var(--side-text); }
.lang-switch.dark button.on { background: rgba(47,123,255,.35); color: #fff; }
.side-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.login-lang { display: flex; justify-content: center; margin-top: 14px; }
.side .brand { gap: 8px; }
.side .brand img { height: 24px; }
.side .brand-sub { font-size: 10px; letter-spacing: .1em; padding-left: 8px; }
.li-fill { background: #F6F9FF; border: 1px solid #DCE7FF; border-radius: 10px; padding: 12px 12px 4px; margin-bottom: 14px; }
.li-fill .field { margin-bottom: 8px; }
.li-fill .row-actions { justify-content: flex-start; margin-bottom: 8px; }
.notice.sm { font-size: 12px; }
.paste-box { margin: 4px 0 8px; }
.paste-box textarea { margin: 6px 0 8px; font-size: 12px; }
