/* ===== exStrat Hub — theme + layout ===== */
:root {
  --blue: #047DD5; --blue-hover: #0a72c0; --blue-press: #1665C0;
  --black: #25292E; --orange: #F6851B; --green: #10B981;
  --red: #EF4444; --purple: #A78BFA; --sky: #38BDF8; --slate: #94A3B8;

  --bg: #F1F4F8; --surface: #FFFFFF; --surface-2: #F7F9FB; --surface-3: #EEF2F6;
  --border: #E1E6EC; --border-strong: #CFD0D2;
  --text: #23272C; --text-muted: #616B77; --text-faint: #93a0ad;
  --primary: var(--blue); --primary-contrast: #fff;
  --sidebar-bg: #21262C; --sidebar-text: #C7D0DA; --sidebar-active: #ffffff; --sidebar-active-bg: rgba(4,125,213,.18);
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 14px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 30px rgba(16,24,40,.14);
  --radius: 10px; --radius-sm: 7px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: #14171B; --surface: #1D2126; --surface-2: #23282E; --surface-3: #2A3037;
  --border: #313841; --border-strong: #3C4650;
  --text: #E7ECF2; --text-muted: #9BA6B2; --text-faint: #6b7682;
  --primary: #2f97e6; --primary-contrast: #fff;
  --sidebar-bg: #101317; --sidebar-text: #AEB8C4; --sidebar-active: #fff; --sidebar-active-bg: rgba(47,151,230,.22);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* ===== App shell ===== */
.app-shell { display: grid; grid-template-columns: 244px 1fr; height: 100vh; overflow: hidden; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; }
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.side-logo { width: 26px; height: 26px; }
.side-title { font-size: 15px; color: #fff; font-weight: 600; letter-spacing: .01em; }
.side-title b { color: var(--orange); font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; font-size: 13.5px; transition: background .12s, color .12s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-ico { width: 18px; height: 18px; display: inline-flex; opacity: .9; }
.nav-ico svg { width: 100%; height: 100%; }
.sidebar-foot { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.icon-btn { background: transparent; border: 1px solid transparent; color: var(--sidebar-text); border-radius: 8px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 58px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.page-title { font-size: 17px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; color: var(--text-muted); border-color: var(--border); }
.content { flex: 1; overflow: auto; padding: 22px; }
.loading { color: var(--text-muted); padding: 40px; text-align: center; }

/* ===== Buttons / chips / badges ===== */
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 7px; font-size: 12px; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }
.pill { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }

/* ===== Cards / grid ===== */
.grid { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 700; margin-bottom: 12px; }

/* ===== Overview ===== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.kpi .sub { color: var(--text-faint); font-size: 11.5px; margin-top: 6px; }
.funnel { display: flex; flex-direction: column; gap: 7px; }
.funnel-row { display: grid; grid-template-columns: 190px 1fr 52px; align-items: center; gap: 12px; }
.funnel-row .lbl { color: var(--text-muted); font-size: 13px; }
.funnel-bar { height: 22px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--sky)); border-radius: 6px; }
.funnel-row .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.mini-bars { display: flex; flex-direction: column; gap: 9px; }
.mini-bar { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.mini-bar .track { height: 9px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.mini-bar .track > span { display: block; height: 100%; border-radius: 5px; }

/* ===== CRM Kanban ===== */
.crm-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--text-muted); padding: 6px 13px; cursor: pointer; font-size: 13px; font-weight: 550; }
.seg button.on { background: var(--primary); color: #fff; }
.board { display: flex; gap: 13px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; height: calc(100vh - 190px); }
.col { flex: 0 0 288px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; display: flex; flex-direction: column; max-height: 100%; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.col-head .cdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.col-head .cname { font-weight: 650; font-size: 13px; flex: 1; }
.col-head .ccount { background: var(--surface-3); color: var(--text-muted); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 650; }
.col-head.exit .cname { color: var(--text-muted); }
.col-body { padding: 9px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 40px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: grab; box-shadow: var(--shadow); }
.kcard:active { cursor: grabbing; }
.kcard.sortable-ghost { opacity: .35; }
.kcard.sortable-chosen { box-shadow: var(--shadow-lg); }
.kcard .kname { font-weight: 620; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.kcard .kocc { color: var(--text-muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .kmeta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; }
.kcard .kfoot { display: flex; align-items: center; gap: 9px; margin-top: 8px; color: var(--text-faint); font-size: 11.5px; }
.kcard .kfoot .k-ind { display: inline-flex; align-items: center; gap: 3px; }
.kcard.treated { border-left: 3px solid var(--green); }
.call-flag { color: var(--orange); }
.src-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; letter-spacing: .02em; }
.src-Hasheur { background: rgba(246,133,27,.16); color: #c76a12; }
.src-Cryptoast { background: rgba(4,125,213,.15); color: var(--blue); }
.src-BBS { background: rgba(167,139,250,.18); color: #7c5cd6; }
:root[data-theme="dark"] .src-Hasheur { color: #f2a04f; }
:root[data-theme="dark"] .src-Cryptoast { color: #4aa8ec; }
:root[data-theme="dark"] .src-BBS { color: #b49bf5; }
.bucket-badge { font-weight: 700; font-size: 10.5px; width: 18px; height: 18px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; }
.bk-A{background:rgba(16,185,129,.18);color:#0c9b6d}.bk-B{background:rgba(52,211,153,.18);color:#12a074}
.bk-C{background:rgba(167,139,250,.2);color:#7c5cd6}.bk-D{background:rgba(148,163,184,.2);color:#697585}.bk-E{background:rgba(107,114,128,.2);color:#6b7280}

/* ===== Table (contacts + crm list) ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; padding: 10px 12px; color: var(--text-faint); font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.t-name { font-weight: 600; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }

/* ===== Filters ===== */
.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input, .search-input { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.search-input { min-width: 240px; }
.filters select:focus, .filters input:focus, textarea:focus, input:focus { outline: 2px solid rgba(4,125,213,.3); outline-offset: -1px; border-color: var(--primary); }
.count-note { color: var(--text-muted); font-size: 13px; margin-left: auto; }

/* ===== Drawer (fiche) ===== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(16,20,26,.42); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(680px, 94vw); background: var(--bg); z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head .dh-main { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 19px; }
.drawer-head .dh-sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.drawer-body { overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.fiche-sec { }
.fiche-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 9px; font-weight: 700; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 12px; font-size: 13px; }
.kv .k { color: var(--text-muted); }
.conv { display: flex; flex-direction: column; gap: 9px; }
.msg { padding: 9px 12px; border-radius: 10px; font-size: 13px; max-width: 88%; white-space: pre-wrap; }
.msg.prospect { background: var(--surface-3); align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.daan { background: rgba(4,125,213,.13); align-self: flex-end; border-bottom-right-radius: 3px; }
.msg .who { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: 3px; }
.msg .gist { font-style: italic; color: var(--text-muted); }
.message-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.message-box .mb-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.message-box textarea { width: 100%; border: none; background: transparent; color: var(--text); padding: 12px; resize: vertical; min-height: 128px; line-height: 1.55; }
.message-box .subj { width: 100%; border: none; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); padding: 9px 12px; font-weight: 600; }
.notes-list { display: flex; flex-direction: column; gap: 7px; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 13px; }
.note .nmeta { color: var(--text-faint); font-size: 11px; display: flex; justify-content: space-between; margin-bottom: 3px; }
.note-add { display: flex; gap: 8px; margin-top: 8px; }
.note-add input { flex: 1; }
.signal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; }
.signal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.signal b { display: block; font-size: 15px; }
.signal.on { border-color: var(--green); }
.signal.on b { color: var(--green); }

/* ===== Journal ===== */
.jentry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.jentry .jhead { display: flex; align-items: baseline; gap: 12px; }
.jentry .jdate { color: var(--text-faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.jentry h3 { font-size: 15.5px; }
.jentry .jsummary { margin: 9px 0; color: var(--text); }
.jentry ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-muted); font-size: 13px; }
.jtags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ===== Studies ===== */
.studies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.study-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); cursor: pointer; transition: transform .1s, box-shadow .12s; text-align: left; }
.study-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.study-card .stag { font-size: 11px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.study-card h3 { font-size: 17px; margin: 8px 0 6px; }
.study-card p { color: var(--text-muted); font-size: 13px; margin: 0; }
.study-embed { position: absolute; inset: 0; width: 100%; height: 100%; border: none; background: var(--bg); }
.embed-wrap { position: fixed; inset: 58px 0 0 244px; background: var(--bg); }
.embed-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }

/* ===== Login ===== */
.login-body { display: grid; place-items: center; min-height: 100vh; background:
  radial-gradient(1200px 500px at 50% -10%, rgba(4,125,213,.14), transparent 60%), var(--bg); }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 34px 32px; width: 340px; box-shadow: var(--shadow-lg); }
.login-logo { height: 34px; display: block; margin: 0 auto 6px; }
.logo-dark { display: none; } :root[data-theme="dark"] .logo-dark { display: block; } :root[data-theme="dark"] .logo-light { display: none; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin: 4px 0 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-2); color: var(--text); }
.login-error { color: var(--red); font-size: 13px; text-align: center; margin: 10px 0 0; }
.login-foot { color: var(--text-faint); font-size: 12px; }

/* ===== Toast + empty ===== */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--black); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 80; box-shadow: var(--shadow-lg); font-size: 13px; }
:root[data-theme="dark"] .toast { background: #000; border: 1px solid var(--border); }
.empty { text-align: center; color: var(--text-muted); padding: 46px 20px; }
.spinner { color: var(--text-muted); padding: 26px; text-align: center; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: 244px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .embed-wrap { inset: 58px 0 0 0; }
  .drawer-backdrop.for-nav { z-index: 55; }
}
