/* ==========================================================================
   Rmoved · plateforme HeraHub
   Design system : minimal, dense, sans-serif. Inspiré de Linear / Pipedrive
   sur une palette inspirée de rmoved.ch (blanc, encres, sans accent coloré).
   ========================================================================== */

:root {
  --bg: #ffffff;
  --canvas: #fafaf9;
  --panel: #ffffff;
  --panel-2: #f6f6f4;
  --hover: #f1f1ee;
  --line: #e7e7e2;
  --line-strong: #d8d8d2;
  --ink: #1a1a1a;
  --ink-2: #404040;
  --ink-3: #737373;
  --ink-4: #a3a3a3;
  --ink-disabled: #d4d4d4;

  /* Marque Rmoved : violet/aubergine + gris */
  --brand: #7b2a85;
  --brand-strong: #5d1f64;
  --brand-soft: #f3e6f5;
  --brand-tint: #faf3fb;
  --brand-grey: #6e6e6e;

  --accent: var(--brand);
  --accent-2: var(--brand-strong);
  --ring: rgba(123, 42, 133, 0.18);

  --ok: #137a3a;
  --ok-bg: #e6f3eb;
  --warn: #b1640c;
  --warn-bg: #fbf1de;
  --danger: #b6201c;
  --danger-bg: #fbe7e6;
  --info: #1d4ed8;
  --info-bg: #e3eafd;
  --violet: var(--brand);
  --violet-bg: var(--brand-soft);

  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(13,13,12,.04);
  --shadow: 0 2px 6px rgba(13,13,12,.06), 0 0 0 1px var(--line);
  --shadow-pop: 0 8px 32px rgba(13,13,12,.12), 0 0 0 1px var(--line);

  --topbar-h: 52px;
  --side-w: 232px;
  --side-w-collapsed: 56px;

  --t-fast: 120ms cubic-bezier(.2,.8,.2,1);
  --t: 180ms cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; background: var(--canvas); color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: .9rem; }

::selection { background: var(--ink); color: #fff; }

/* === Icons (Lucide) ===================================================== */
.icon { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 32px; height: 32px; stroke-width: 1.5; }

/* === App shell ========================================================== */
.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "side top"
    "side main";
  height: 100vh;
}
.app[data-collapsed="true"] { grid-template-columns: var(--side-w-collapsed) 1fr; }

/* --- Topbar --- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1rem 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-search {
  flex: 1; max-width: 480px; position: relative;
}
.topbar-search input {
  width: 100%; height: 32px; padding: 0 .75rem 0 2rem;
  background: var(--panel-2); border: 1px solid transparent;
  border-radius: var(--r); font-size: .85rem; color: var(--ink);
  transition: var(--t-fast);
}
.topbar-search input::placeholder { color: var(--ink-4); }
.topbar-search input:focus {
  outline: none; background: var(--bg); border-color: var(--line-strong);
  box-shadow: 0 0 0 3px var(--ring);
}
.topbar-search .icon-search {
  position: absolute; left: .55rem; top: 50%; transform: translateY(-50%);
  color: var(--ink-3);
}
.topbar-search kbd {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  font-size: .7rem; padding: 1px 5px; background: var(--bg); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-family: inherit;
}

.topbar-actions { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent;
  border: 1px solid transparent; color: var(--ink-2);
  border-radius: var(--r); transition: var(--t-fast); position: relative;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--danger);
  border: 1.5px solid var(--bg);
}

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: #fff;
  font-size: .72rem; font-weight: 600; letter-spacing: 0;
}
.avatar-lg { width: 36px; height: 36px; font-size: .82rem; }

.user-menu-btn {
  display: flex; align-items: center; gap: .5rem; padding: .25rem .35rem .25rem .25rem;
  background: transparent; border: 1px solid transparent; border-radius: var(--r);
  color: var(--ink-2); font-size: .82rem;
}
.user-menu-btn:hover { background: var(--panel-2); color: var(--ink); }
.user-menu-btn .name { font-weight: 500; }

/* --- Sidebar --- */
.sidebar {
  grid-area: side;
  background: var(--canvas);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; gap: .65rem;
  padding: 0 .85rem; height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 600; font-size: .95rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: auto; display: block; }
.brand-text { line-height: 1.05; }
.brand-text small {
  display: block; font-size: .62rem; color: var(--ink-3);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  margin-top: 1px;
}
.collapse-btn {
  margin-left: auto; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent;
  border-radius: var(--r-sm); color: var(--ink-3);
}
.collapse-btn:hover { background: var(--panel-2); color: var(--ink); }

.app[data-collapsed="true"] .brand span,
.app[data-collapsed="true"] .nav a span,
.app[data-collapsed="true"] .nav-section,
.app[data-collapsed="true"] .nav a .badge,
.app[data-collapsed="true"] .sidebar-foot { display: none; }
.app[data-collapsed="true"] .sidebar-head { justify-content: center; padding: 0; }
.app[data-collapsed="true"] .nav a { justify-content: center; padding: 0; height: 36px; }

.nav {
  flex: 1; overflow-y: auto; padding: .75rem .5rem;
}
.nav-section {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4); padding: .85rem .85rem .35rem;
  font-weight: 500;
}
.nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .42rem .75rem; margin-bottom: 1px;
  border-radius: var(--r); color: var(--ink-2);
  font-size: .85rem; line-height: 1.2; font-weight: 500;
  transition: var(--t-fast); position: relative;
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .icon { color: inherit; opacity: .85; }
.nav a.active .icon { opacity: 1; }
.nav a .badge {
  margin-left: auto; font-size: .68rem; padding: 1px 5px;
  background: var(--panel-2); color: var(--ink-2); border-radius: 99px;
  font-weight: 500;
}
.nav a.active .badge { background: rgba(255,255,255,.16); color: #fff; }
.nav a .badge.danger { background: var(--danger); color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: .65rem .75rem;
  display: flex; align-items: center; gap: .55rem;
  background: var(--canvas);
}
.sidebar-foot .info { font-size: .75rem; line-height: 1.2; }
.sidebar-foot .info strong { display: block; font-weight: 600; color: var(--ink); }
.sidebar-foot .info span { color: var(--ink-3); }

/* --- Main content --- */
.main { grid-area: main; overflow-y: auto; background: var(--canvas); }

.page-header {
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 1.1rem 1.5rem .9rem;
}
.page-header .breadcrumb {
  display: flex; align-items: center; gap: .35rem;
  color: var(--ink-3); font-size: .78rem; margin-bottom: .35rem;
}
.page-header .breadcrumb a:hover { color: var(--ink); }
.page-header .breadcrumb .icon { width: 12px; height: 12px; opacity: .6; }
.page-header .title-row { display: flex; align-items: center; gap: .85rem; }
.page-header h1 { font-size: 1.25rem; font-weight: 600; }
.page-header .actions { margin-left: auto; display: flex; gap: .4rem; }

.toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .65rem 1.5rem; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex; align-items: center; gap: .25rem;
  background: var(--panel-2); padding: 2px; border-radius: var(--r);
}
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .28rem .65rem; font-size: .82rem; color: var(--ink-2);
  background: transparent; border: 0; border-radius: var(--r-sm); font-weight: 500;
  transition: var(--t-fast);
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.active, .tabs button.active {
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm);
}

.content { padding: 1.5rem; }
.content.flush { padding: 0; }

/* === Buttons & form ==================================================== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  height: 30px; padding: 0 .8rem;
  background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: var(--r);
  font-size: .82rem; font-weight: 500;
  transition: var(--t-fast);
}
.btn:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn.secondary {
  background: var(--bg); color: var(--ink);
  border-color: var(--line-strong);
}
.btn.secondary:hover { background: var(--panel-2); border-color: var(--ink-3); color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.sm { height: 26px; font-size: .78rem; padding: 0 .65rem; }

input[type="text"], input[type="search"], input[type="email"],
textarea, select {
  width: 100%; height: 32px; padding: 0 .65rem;
  background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--r); font-family: inherit; font-size: .85rem;
  color: var(--ink); transition: var(--t-fast);
}
textarea { padding: .5rem .65rem; height: auto; min-height: 80px; }
select { padding-right: 1.75rem; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e6a' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right .55rem center; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--ring);
}

.field-inline { display: flex; align-items: center; gap: .35rem; }
.field-inline label { font-size: .78rem; color: var(--ink-3); }

/* === Card / panel ====================================================== */
.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: .92rem; font-weight: 600; }
.card-head .actions { margin-left: auto; }
.card-body { padding: 1rem; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; }
.cols-2-3 { display: grid; grid-template-columns: 2fr 3fr; gap: 1rem; }

@media (max-width: 1100px) { .cols-2, .cols-3-2, .cols-2-3 { grid-template-columns: 1fr; } }

/* === KPI card ========================================================== */
.kpi {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.kpi .label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 500;
}
.kpi .value {
  font-size: 1.65rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1;
}
.kpi .sub {
  font-size: .76rem; color: var(--ink-3);
  display: flex; align-items: center; gap: .35rem;
}
.kpi .delta { font-weight: 500; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }
.kpi .spark { margin-top: .25rem; height: 24px; }

/* === Table ============================================================= */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.tbl th, .tbl td {
  padding: .55rem .85rem; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.tbl th {
  background: var(--panel-2); color: var(--ink-3);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 500; padding: .5rem .85rem;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.mono, .tbl th.mono {
  font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: .8rem;
}
.tbl tr.row-link { cursor: pointer; }
.tbl tr.row-link a { color: inherit; }

.row-actions { display: flex; gap: .15rem; opacity: 0; transition: var(--t-fast); }
.tbl tbody tr:hover .row-actions { opacity: 1; }

/* === Badge ============================================================= */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: 1px 8px; font-size: .72rem; font-weight: 500;
  border-radius: 99px; line-height: 1.5;
  background: var(--panel-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.violet { background: var(--violet-bg); color: var(--violet); border-color: transparent; }
.badge.solid { background: var(--ink); color: #fff; border-color: transparent; }
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* === Progress ========================================================== */
.bar { display: block; width: 100%; height: 4px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width var(--t); }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.bar.danger > span { background: var(--danger); }
.bar-mini { width: 60px; }

/* === Avatars ========================================================== */
.avatar-set { display: inline-flex; }
.avatar-set .avatar {
  border: 2px solid var(--bg); margin-left: -8px; width: 24px; height: 24px;
  font-size: .65rem;
}
.avatar-set .avatar:first-child { margin-left: 0; }

/* === Kanban ============================================================ */
.kanban {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  overflow-x: auto; padding-bottom: .5rem;
}
.kanban-col {
  background: var(--canvas); border: 1px solid var(--line);
  border-radius: var(--r-md); display: flex; flex-direction: column;
  min-height: 60vh;
}
.kanban-col-head {
  padding: .65rem .85rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .5rem;
}
.kanban-col-head h4 { font-size: .82rem; font-weight: 600; }
.kanban-col-head .count {
  background: var(--panel-2); color: var(--ink-2);
  padding: 0 6px; border-radius: 99px; font-size: .7rem; font-weight: 500;
  margin-left: .25rem;
}
.kanban-col-body { padding: .65rem; flex: 1; overflow-y: auto; }
.kanban-card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r); padding: .75rem; margin-bottom: .5rem;
  transition: var(--t-fast); cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(13,13,12,.06), 0 0 0 1px var(--line); }
.kanban-card .top {
  display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .35rem;
}
.kanban-card .top strong {
  font-size: .82rem; line-height: 1.3; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kanban-card .meta {
  display: flex; flex-wrap: wrap; gap: .35rem; font-size: .72rem; color: var(--ink-3);
  margin: .35rem 0;
}
.kanban-card .meta-row {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--ink-3);
}

/* === Activity feed ====================================================== */
.activity { display: flex; flex-direction: column; }
.activity-item {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--line);
  font-size: .82rem;
}
.activity-item:last-child { border-bottom: 0; }
.activity-item .ico {
  width: 28px; height: 28px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--ink-2); border-radius: var(--r);
}
.activity-item .body { flex: 1; min-width: 0; }
.activity-item .body .text { color: var(--ink); }
.activity-item .body .meta { color: var(--ink-3); font-size: .74rem; margin-top: 1px; }
.activity-item time { color: var(--ink-3); font-size: .72rem; flex-shrink: 0; }

/* === 3-pane mail ======================================================= */
.mail {
  display: grid;
  grid-template-columns: 220px 360px 1fr;
  height: calc(100vh - var(--topbar-h));
}
.mail-folders {
  background: var(--canvas); border-right: 1px solid var(--line);
  padding: .75rem .5rem; overflow-y: auto;
}
.mail-folders h4 {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4); padding: .5rem .85rem; font-weight: 500;
}
.mail-folder {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem; border-radius: var(--r); color: var(--ink-2);
  font-size: .85rem; cursor: pointer;
}
.mail-folder:hover { background: var(--panel-2); color: var(--ink); }
.mail-folder.active { background: var(--brand); color: #fff; }
.mail-folder .count { margin-left: auto; font-size: .72rem; color: var(--ink-3); }
.mail-folder.active .count { color: rgba(255,255,255,.7); }

.mail-list { background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; }
.mail-row {
  display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: var(--t-fast);
}
.mail-row:hover { background: var(--panel-2); }
.mail-row.active { background: var(--brand-tint); border-left: 3px solid var(--brand); padding-left: calc(1rem - 3px); }
.mail-row .from { display: flex; align-items: center; gap: .35rem; font-size: .82rem; }
.mail-row .from strong { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .from time { color: var(--ink-3); font-size: .72rem; }
.mail-row .subject { font-size: .85rem; margin-top: .15rem; color: var(--ink); font-weight: 500; }
.mail-row .preview { font-size: .78rem; color: var(--ink-3); margin-top: .15rem;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.mail-row .tags { margin-top: .35rem; display: flex; gap: .25rem; }

.mail-view { background: var(--bg); overflow-y: auto; }
.mail-view-head {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line);
}
.mail-view-head h2 { font-size: 1rem; margin-bottom: .35rem; }
.mail-view-meta {
  display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--ink-3);
}
.mail-view-body {
  padding: 1.5rem; font-size: .9rem; line-height: 1.7;
}
.mail-attachments {
  display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 1.5rem 1.5rem;
}
.mail-att {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel-2); font-size: .82rem;
}

/* === Chat ============================================================== */
.chat {
  display: grid; grid-template-columns: 240px 1fr;
  height: calc(100vh - var(--topbar-h));
}
.chat-side {
  background: var(--canvas); border-right: 1px solid var(--line);
  padding: .75rem; overflow-y: auto;
}
.chat-side h4 {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4); padding: .5rem .35rem; font-weight: 500;
}
.chat-suggestion {
  display: block; width: 100%; text-align: left;
  padding: .55rem .65rem; margin-bottom: .25rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  font-size: .8rem; color: var(--ink-2); transition: var(--t-fast); cursor: pointer;
}
.chat-suggestion:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line-strong); }

.chat-main { display: flex; flex-direction: column; background: var(--bg); }
.chat-main-head {
  display: flex; align-items: center; gap: .65rem;
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--line);
}
.chat-main-head .avatar { background: var(--violet-bg); color: var(--violet); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 1.5rem; max-width: 800px; margin: 0 auto; width: 100%; }
.chat-msg { display: flex; gap: .75rem; margin-bottom: 1.25rem; }
.chat-msg .av {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 600;
}
.chat-msg.user .av { background: var(--ink); color: #fff; }
.chat-msg.bot .av { background: var(--violet-bg); color: var(--violet); }
.chat-msg .content { flex: 1; min-width: 0; }
.chat-msg .content .who { font-weight: 600; font-size: .82rem; margin-bottom: .25rem; }
.chat-msg .content .text { font-size: .9rem; line-height: 1.65; color: var(--ink); }
.chat-msg .source {
  margin-top: .65rem; padding: .4rem .6rem; background: var(--panel-2);
  border-left: 2px solid var(--violet); font-size: .76rem; color: var(--ink-3);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.chat-input-wrap {
  padding: 1rem 1.5rem 1.5rem; max-width: 800px; margin: 0 auto; width: 100%;
}
.chat-input {
  display: flex; align-items: flex-end; gap: .5rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--bg); padding: .55rem .65rem; box-shadow: var(--shadow-sm);
  transition: var(--t-fast);
}
.chat-input:focus-within { border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--ring); }
.chat-input textarea {
  flex: 1; border: 0; padding: .25rem; resize: none; min-height: 24px; max-height: 200px;
  background: transparent; outline: none; font-size: .9rem;
}
.chat-input button {
  height: 30px; width: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; border: 0; border-radius: var(--r);
}
.chat-input button:disabled { opacity: .35; cursor: not-allowed; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2rem; color: var(--ink-3);
}
.chat-empty .ico {
  width: 56px; height: 56px; border-radius: 50%; background: var(--violet-bg); color: var(--violet);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 1rem;
}
.chat-empty h2 { color: var(--ink); margin-bottom: .35rem; }
.chat-empty p { font-size: .9rem; max-width: 42ch; }
.chat-empty .chips { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.chat-empty .chips button {
  border: 1px solid var(--line-strong); background: var(--bg); padding: .45rem .8rem;
  border-radius: var(--r); font-size: .82rem; color: var(--ink-2); cursor: pointer;
}
.chat-empty .chips button:hover { background: var(--panel-2); color: var(--ink); }

/* === Map fake ========================================================== */
.map-shell { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--topbar-h) - 60px); }
.map-list { background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; }
.map-list a {
  display: block; padding: .65rem 1rem; border-bottom: 1px solid var(--line);
  font-size: .82rem;
}
.map-list a:hover { background: var(--panel-2); }
.map-canvas {
  position: relative; background:
    linear-gradient(0deg, var(--panel-2) 1px, transparent 1px) 0 0/40px 40px,
    linear-gradient(90deg, var(--panel-2) 1px, transparent 1px) 0 0/40px 40px,
    var(--canvas);
}
.map-pin {
  position: absolute; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  font-size: .65rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,.15);
}
.map-pin:hover { background: var(--accent-2); transform: translate(-50%, -100%) rotate(-45deg) scale(1.1); }

/* === Detail page tabs ==================================================*/
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }

.tablist { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.tablist a, .tablist button {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .65rem .85rem; font-size: .85rem; color: var(--ink-3);
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  font-weight: 500; cursor: pointer;
}
.tablist a:hover, .tablist button:hover { color: var(--ink); }
.tablist a.active, .tablist button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tablist .badge { margin-left: .25rem; }

/* === Aside info card =================================================== */
.aside-card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.aside-card h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); margin-bottom: .55rem; font-weight: 500;
}
.fact-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: .25rem 0; font-size: .85rem;
}
.fact-line .k { color: var(--ink-3); }
.fact-line .v { font-weight: 500; }

/* === Chips ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; background: var(--panel-2);
  border-radius: var(--r); font-size: .76rem; color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip-close {
  margin-left: .15rem; padding: 1px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

/* === Empty / utility ================================================== */
.empty {
  padding: 3rem 2rem; text-align: center; color: var(--ink-3); font-size: .9rem;
}
.empty .icon-xl { color: var(--ink-4); margin-bottom: .65rem; }

.hr { height: 1px; background: var(--line); margin: 1rem 0; border: 0; }
.muted { color: var(--ink-3); }
.tiny { font-size: .76rem; }
.mono { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: .82rem; }
.no-wrap { white-space: nowrap; }
.right { text-align: right; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }

/* === Charts (inline SVG) =============================================== */
.chart-y-grid line { stroke: var(--line); stroke-dasharray: 2 4; }
.chart-bar { fill: var(--ink); transition: fill var(--t-fast); }
.chart-bar:hover { fill: var(--accent-2); }
.chart-line { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart-area { fill: rgba(13,13,12,.06); }
.chart-axis text { font-size: 10px; fill: var(--ink-3); }

/* === Donut ============================================================ */
.donut { width: 120px; height: 120px; }
.donut-bg { stroke: var(--panel-2); }
.donut-fg { stroke: var(--ink); stroke-linecap: round; transition: stroke-dashoffset var(--t); }

/* === Tooltips & popovers (Alpine) ====================================== */
[x-cloak] { display: none !important; }

/* === Dropdown menu ==================================================== */
.menu {
  position: absolute; right: 0; top: 100%; margin-top: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); min-width: 220px; padding: .35rem; z-index: 50;
}
.menu a, .menu button {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .45rem .55rem; border-radius: var(--r-sm);
  font-size: .85rem; color: var(--ink-2); background: transparent; border: 0;
  text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--panel-2); color: var(--ink); }
.menu hr { margin: .35rem 0; border: 0; border-top: 1px solid var(--line); }
.menu .meta { padding: .35rem .55rem; font-size: .76rem; color: var(--ink-3); }

/* === Source badges (integrations) ====================================== */
:root {
  --src-outlook: #0078D4;
  --src-tipee: #16A34A;
  --src-archicad: #EA580C;
  --src-bcn: #1F2937;
  --src-artlogiciel: #6B7280;
  --src-ai: #7B2A85;
  --src-audio: #DC2626;
}

.source-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500; line-height: 1.55;
  border: 1px solid transparent;
  white-space: nowrap;
}
.source-badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.source-badge__label { font-weight: 500; }
.source-badge__extra { color: var(--ink-3); font-weight: 400; margin-left: 1px; }
.source-badge--sm { padding: 1px 6px; font-size: 10px; }
.source-badge--sm .icon { width: 10px; height: 10px; }

.source-badge--outlook    { background: rgba(0,120,212,.10);   color: var(--src-outlook); }
.source-badge--tipee      { background: rgba(22,163,74,.10);   color: var(--src-tipee); }
.source-badge--archicad   { background: rgba(234,88,12,.10);   color: var(--src-archicad); }
.source-badge--bcn        { background: rgba(31,41,55,.08);    color: var(--src-bcn); }
.source-badge--artlogiciel{ background: rgba(107,114,128,.10); color: var(--src-artlogiciel); }
.source-badge--ai         { background: rgba(123,42,133,.10);  color: var(--src-ai); }
.source-badge--audio      { background: rgba(220,38,38,.10);   color: var(--src-audio); }

.source-badge--outlook .source-badge__extra,
.source-badge--tipee .source-badge__extra,
.source-badge--archicad .source-badge__extra,
.source-badge--bcn .source-badge__extra,
.source-badge--artlogiciel .source-badge__extra,
.source-badge--ai .source-badge__extra,
.source-badge--audio .source-badge__extra { color: var(--ink-3); }

/* === Status pills (topbar live integrations) ============================ */
.status-pills {
  display: flex; align-items: center; gap: .5rem;
  padding-right: .5rem; margin-right: .25rem;
  border-right: 1px solid var(--line);
}
.status-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  color: var(--ink-3); background: var(--panel-2);
  white-space: nowrap;
}
.status-pill .pulse-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #16A34A;
  animation: pulse-dot 2s cubic-bezier(.4,0,.6,1) infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(22,163,74,.4); }
  50%     { opacity: .4; box-shadow: 0 0 0 4px rgba(22,163,74,0); }
}
.status-pill-collapsed { display: none; }
.topbar-sync {
  font-size: 11px; color: var(--ink-3); margin: 0 .5rem 0 0;
  white-space: nowrap;
}
@media (max-width: 1024px) {
  .status-pill { display: none; }
  .status-pill-collapsed { display: inline-flex; }
  .topbar-sync { display: none; }
}

/* === Notifications dropdown (rich) ====================================== */
.notif-menu { width: 360px; padding: .25rem; }
.notif-head {
  padding: .65rem .65rem .5rem;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .82rem; font-weight: 600;
}
.notif-head .muted { font-size: .72rem; font-weight: 500; }
.notif-item {
  display: flex; gap: .65rem; padding: .65rem;
  border-radius: var(--r-sm); align-items: flex-start;
  text-decoration: none; color: inherit;
}
.notif-item + .notif-item { border-top: 1px solid var(--line); border-radius: 0; }
.notif-item:hover { background: var(--panel-2); }
.notif-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.notif-icon--red    { background: var(--danger-bg); color: var(--danger); }
.notif-icon--orange { background: var(--warn-bg);   color: var(--warn); }
.notif-icon--green  { background: var(--ok-bg);     color: var(--ok); }
.notif-icon--blue   { background: var(--info-bg);   color: var(--info); }
.notif-icon--violet { background: var(--brand-soft); color: var(--brand); }
.notif-body { flex: 1; min-width: 0; }
.notif-title {
  font-size: .82rem; font-weight: 600; line-height: 1.3;
  color: var(--ink);
}
.notif-sub {
  font-size: .76rem; color: var(--ink-3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-time {
  font-size: .7rem; color: var(--ink-4); margin-top: 2px;
}
.notif-foot {
  padding: .5rem; text-align: center;
  border-top: 1px solid var(--line); margin-top: .25rem;
}
.notif-foot a { font-size: .78rem; color: var(--ink-3); font-weight: 500; }
.notif-foot a:hover { color: var(--ink); }

/* === Sources connectées card =========================================== */
.sources-list { display: flex; flex-direction: column; gap: .55rem; }
.source-line {
  display: flex; align-items: center; gap: .65rem;
  font-size: .82rem; color: var(--ink-2);
}
.source-line .src-ico {
  width: 26px; height: 26px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); background: var(--panel-2);
}
.source-line .src-ico--outlook    { background: rgba(0,120,212,.10);   color: var(--src-outlook); }
.source-line .src-ico--tipee      { background: rgba(22,163,74,.10);   color: var(--src-tipee); }
.source-line .src-ico--archicad   { background: rgba(234,88,12,.10);   color: var(--src-archicad); }
.source-line .src-ico--bcn        { background: rgba(31,41,55,.08);    color: var(--src-bcn); }
.source-line .src-ico--ai         { background: rgba(123,42,133,.10);  color: var(--src-ai); }
.source-line .src-name { flex: 1; }
.source-line .src-info { color: var(--ink-3); font-size: .78rem; }

/* === Holding selector (Phase 7 teaser) ================================= */
.holding-selector {
  position: relative; padding: .5rem;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}
.holding-btn {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .5rem .65rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r);
  font-family: inherit; text-align: left; cursor: pointer;
  transition: var(--t-fast); color: var(--ink);
}
.holding-btn:hover { border-color: var(--ink-3); }
.holding-btn .body { flex: 1; min-width: 0; }
.holding-btn .name {
  font-size: .82rem; font-weight: 600; line-height: 1.2;
  color: var(--brand);
}
.holding-btn .sub {
  font-size: .72rem; color: var(--ink-3); line-height: 1.2; margin-top: 1px;
}
.holding-btn .icon-toggle { color: var(--ink-3); flex-shrink: 0; }

.holding-menu {
  position: absolute; top: 100%; left: .5rem; right: .5rem;
  margin-top: 4px; padding: 0; z-index: 60;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.holding-menu-head {
  padding: .65rem .8rem; background: var(--brand);
  color: #fff; font-size: .78rem; font-weight: 600;
}
.holding-menu-head .sub {
  font-size: .68rem; opacity: .8; margin-top: 1px; font-weight: 400;
}
.holding-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem .8rem; font-size: .82rem;
  border-bottom: 1px solid var(--line);
}
.holding-item:last-of-type { border-bottom: 0; }
.holding-item .ind {
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.holding-item.is-active .ind { color: var(--ok); }
.holding-item.is-disabled { color: var(--ink-4); cursor: default; }
.holding-item.is-disabled .ind { color: var(--ink-disabled); }
.holding-item .body { flex: 1; }
.holding-item .name { font-weight: 500; }
.holding-item .where { font-size: .72rem; color: var(--ink-3); }
.holding-item.is-active .where { color: var(--ok); font-weight: 500; }
.holding-item.is-disabled .where { color: var(--ink-4); font-style: italic; }

.holding-foot {
  padding: .55rem .8rem; background: var(--brand-soft);
  color: var(--brand); font-size: .8rem; font-weight: 600;
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  border-top: 1px solid var(--line);
}
.holding-foot:hover { background: var(--brand-tint); }

@media (max-width: 900px) {
  .holding-selector { display: none; }
}

/* === Mini integration icons inside table rows =========================== */
.row-src {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  margin-left: .35rem; vertical-align: middle;
}
.row-src .icon { width: 11px; height: 11px; stroke-width: 2; }
.row-src--bcn { background: rgba(31,41,55,.08); color: var(--src-bcn); }
.row-src--outlook { background: rgba(0,120,212,.10); color: var(--src-outlook); }

/* === Mobile ============================================================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar { display: none; }
  .topbar-search { max-width: none; }
  .mail { grid-template-columns: 1fr; }
  .mail-folders, .mail-list { display: none; }
  .chat { grid-template-columns: 1fr; }
  .chat-side { display: none; }
}
