/* OkiDocIt prototype — design tokens
   60% neutral greys · 30% muted tones · 10% Myrtille CTA */
:root {
  /* 60 — neutrals */
  --bg: #F2F3F5;
  --surface: #FFFFFF;
  --surface-2: #F8F9FA;
  --line: #E6E8EB;
  --line-strong: #D5D8DD;
  --ink: #15171C;
  --ink-2: #4B5160;
  --ink-3: #868C98;

  /* 30 — muted / attenuation */
  --muted: #EEF0F3;
  --myrtille-50: #F1F0FD;
  --myrtille-100: #E3E0FB;
  --myrtille-200: #C9C3F6;

  /* 10 — CTA Myrtille */
  --myrtille: #5B4FE0;
  --myrtille-600: #4C40CC;
  --myrtille-700: #3E33AD;

  /* semantic statuses */
  --amber-bg: #FFF7E6; --amber-ink: #A15C00; --amber-line: #F5D9A6;
  --red-bg: #FFF0F0;   --red-ink: #B42318;   --red-line: #F6C6C2;
  --green-bg: #ECFAF1; --green-ink: #137A3F; --green-line: #B7E6C8;
  --grey-bg: #F2F3F5;  --grey-ink: #5B6270;  --grey-line: #DDE0E5;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --sidebar: 264px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; padding: 16px; gap: 16px; }
.sidebar {
  width: var(--sidebar); flex: none; display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 16px; height: calc(100vh - 32px);
}
.main {
  flex: 1; min-width: 0; background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--line); display: flex; flex-direction: column; min-height: calc(100vh - 32px);
}

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--myrtille);
  display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2.6; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand-name span { color: var(--myrtille); }
.side-search {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; color: var(--ink-3);
  margin-bottom: 18px;
}
.side-search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink-3); background: var(--surface-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav a, .nav button.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--ink-2); border: 0; background: transparent; width: 100%; text-align: left;
}
.nav a:hover, .nav button.nav-item:hover { background: rgba(21, 23, 28, .04); color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.nav a .count {
  margin-left: auto; font-size: 11px; font-weight: 600; background: var(--myrtille-100); color: var(--myrtille-700);
  border-radius: 999px; padding: 1px 7px;
}
.nav .sub { padding-left: 38px; font-size: 13px; }
.client-dot { width: 18px; height: 18px; border-radius: 5px; background: #2F6F62; color: #fff; font-size: 9px; font-weight: 700; display: grid; place-items: center; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.workspace {
  margin-top: 10px; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.avatar {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: var(--myrtille-100); color: var(--myrtille-700); flex: none;
}
.workspace small { display: block; color: var(--ink-3); font-size: 12px; }

/* ---------- header ---------- */
.header {
  display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line);
}
.header h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink-2); position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--myrtille); border: 2px solid #fff; }
.menu-btn { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--myrtille); border-color: var(--myrtille); color: #fff; }
.btn-primary:hover { background: var(--myrtille-600); border-color: var(--myrtille-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--muted); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--myrtille-200); outline-offset: 2px;
}

.role-switch {
  display: inline-flex; background: var(--muted); border-radius: var(--radius); padding: 3px; gap: 2px;
}
.role-switch button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-3);
}
.role-switch button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.proto-tag { font-size: 11px; font-weight: 600; color: var(--ink-3); border: 1px dashed var(--line-strong); padding: 2px 8px; border-radius: 999px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 24px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--muted); border-radius: var(--radius); padding: 3px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.tab.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.toolbar .spacer { flex: 1; }
.field {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink-3);
}
.field input { border: 0; outline: 0; background: transparent; width: 180px; color: var(--ink); }
.select {
  height: 38px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 32px 0 12px; background: var(--surface);
  appearance: none; color: var(--ink-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868C98' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 0 24px 18px; }
.kpi {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: var(--surface); text-align: left;
  display: flex; flex-direction: column; gap: 14px; transition: border-color .15s, box-shadow .15s;
}
.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.kpi.on { border-color: var(--myrtille-200); box-shadow: 0 0 0 3px var(--myrtille-50); }
.kpi-icon { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-2); box-shadow: var(--shadow); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 8px; }
.kpi-value small { font-size: 12px; font-weight: 600; }
.kpi-label { color: var(--ink-2); }
.up { color: var(--green-ink); } .down { color: var(--red-ink); } .warn { color: var(--amber-ink); }

/* ---------- table ---------- */
.table-wrap { margin: 0 24px 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-weight: 500; color: var(--ink-2); background: var(--surface-2); padding: 12px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: var(--myrtille-50); }
tbody tr:last-child td { border-bottom: 0; }
.cell-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-title strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.cell-title small { color: var(--ink-3); font-size: 12px; }
.thumb {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; flex: none; color: var(--ink-2);
  background: var(--muted); border: 1px solid var(--line);
}
.cb { width: 16px; height: 16px; accent-color: var(--myrtille); }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.comments-count { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-3); }
.comments-count.has { color: var(--ink); font-weight: 600; }
.row-more { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { background: var(--grey-bg); color: var(--grey-ink); border-color: var(--grey-line); }
.st-review { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber-line); }
.st-changes { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-line); }
.st-approved { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-line); }
.st-scheduled { background: var(--myrtille-50); color: var(--myrtille-700); border-color: var(--myrtille-100); }
.st-published { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); background: var(--muted); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.late { color: var(--red-ink); font-weight: 600; font-size: 12px; }

.table-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 6px; margin: 0 auto; }
.pager button { min-width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.pager button.on { border-color: var(--ink); font-weight: 700; }
.pager button:disabled { opacity: .4; cursor: default; }

.bulkbar {
  position: sticky; bottom: 16px; margin: 0 24px 16px; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  background: var(--ink); color: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.bulkbar .btn { height: 34px; }
.bulkbar .btn-ghost { color: #C9CDD6; }
.bulkbar .btn-ghost:hover { background: rgba(255,255,255,.08); }

.empty { padding: 48px 24px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* mobile list (agency) */
.m-list { display: none; }

/* ---------- calendar ---------- */
.cal { margin: 0 24px 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.cal-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cal-head h3 { margin: 0 8px; font-size: 15px; text-transform: capitalize; min-width: 150px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { font-size: 12px; color: var(--ink-3); padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-n { color: var(--line-strong); }
.cal-n { font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 2px 4px; }
.cal-day.today .cal-n { color: #fff; background: var(--myrtille); border-radius: 6px; align-self: flex-start; }
.cal-ev {
  font-size: 12px; text-align: left; border: 1px solid; border-radius: 6px; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(21, 23, 28, .32); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(560px, calc(100vw - 24px)); background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 50; display: flex; flex-direction: column;
  transform: translateX(calc(100% + 24px)); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head .crumbs { margin: 0; }
.drawer-body { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-foot .btn { flex: 1; }
.meta { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; font-size: 13px; }
.meta dt { color: var(--ink-3); }
.meta dd { margin: 0; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 8px; }
.caption { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.6; }
.brief { background: var(--myrtille-50); border: 1px solid var(--myrtille-100); border-radius: var(--radius); padding: 12px 14px; color: var(--myrtille-700); font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; }
.msg .avatar { width: 28px; height: 28px; font-size: 11px; border-radius: 50%; }
.msg.client .avatar { background: #DDEFEA; color: #1F5A4E; }
.msg-body { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 8px 12px; flex: 1; }
.msg-body small { color: var(--ink-3); font-size: 12px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
textarea {
  width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; outline: 0; background: var(--surface);
}
textarea:focus { border-color: var(--myrtille); box-shadow: 0 0 0 3px var(--myrtille-50); }
.history { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); }
.history div { display: flex; gap: 8px; align-items: center; }
.history i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }

/* ---------- visual preview ---------- */
.visual {
  position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4 / 5;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; color: #fff; isolation: isolate;
}
.visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.45)); z-index: -1; }
.visual .v-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%); opacity: .55; }
.visual .v-icon svg { width: 56px; height: 56px; stroke-width: 1.2; }
.visual .v-format { position: absolute; top: 12px; left: 12px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.92); color: var(--ink); padding: 3px 9px; border-radius: 999px; display: inline-flex; gap: 5px; align-items: center; }
.visual .v-format svg { width: 14px; height: 14px; }
.visual .v-title { font-weight: 700; font-size: 18px; line-height: 1.25; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.visual .v-link {
  margin-top: 10px; align-self: flex-start; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.92); color: var(--ink);
  padding: 6px 10px; border-radius: 8px; text-decoration: none; display: inline-flex; gap: 6px; align-items: center;
}
.visual .v-link svg { width: 14px; height: 14px; }
.drawer .visual { flex: none; aspect-ratio: auto; height: 280px; }

/* ---------- carousel (real images) ---------- */
.visual.has-media { padding: 0; background: #0F1115; }
.visual.has-media::after { display: none; }
.slides {
  position: absolute; inset: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; cursor: pointer; user-select: none; }
.visual.fit-contain .slides img { object-fit: contain; cursor: zoom-in; }
.visual .v-format { z-index: 2; }
.v-count {
  position: absolute; top: 12px; right: 12px; z-index: 2; font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(15, 17, 21, .62); padding: 3px 9px; border-radius: 999px;
}
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.92); color: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .15s;
}
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; }
.visual:hover .v-nav, .v-nav:focus-visible { opacity: 1; }
.v-dots { position: absolute; bottom: 10px; left: 0; right: 0; z-index: 2; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.v-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.5); transition: width .2s, background .2s; }
.v-dots i.on { width: 16px; border-radius: 3px; background: #fff; }
.v-zoom {
  position: absolute; bottom: 10px; right: 10px; z-index: 2; width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: rgba(255,255,255,.92); color: var(--ink); display: grid; place-items: center;
}
.v-zoom svg { width: 16px; height: 16px; }
.visual .v-empty { position: absolute; top: 14px; right: 12px; font-size: 11px; font-weight: 600; color: rgba(255,255,255,.85); }
@media (hover: none) { .v-nav { display: none; } }

.thumb.has-img { padding: 0; overflow: hidden; position: relative; background: #0F1115; }
.thumb.has-img img { width: 100%; height: 100%; object-fit: cover; }
.thumb.has-img b {
  position: absolute; right: 2px; bottom: 2px; font-size: 10px; line-height: 1; color: #fff; background: rgba(15,17,21,.7);
  padding: 2px 4px; border-radius: 4px;
}

/* ---------- media manager ---------- */
.media-manager { display: flex; flex-direction: column; gap: 10px; }
.mm-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.mm-item {
  position: relative; aspect-ratio: 4 / 5; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: #0F1115;
  cursor: grab; transition: transform .12s, box-shadow .12s, opacity .12s;
}
.mm-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.mm-item.dragging { opacity: .4; }
.mm-item.drop-over { box-shadow: 0 0 0 2px var(--myrtille); transform: scale(1.03); }
.mm-n {
  position: absolute; top: 5px; left: 5px; min-width: 20px; height: 20px; border-radius: 6px; background: rgba(255,255,255,.94);
  font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px;
}
.mm-tools { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.mm-item:hover .mm-tools, .mm-item:focus-within .mm-tools { opacity: 1; }
@media (hover: none) { .mm-tools { opacity: 1; } }
.mm-tools button {
  width: 26px; height: 26px; border-radius: 7px; border: 0; background: rgba(255,255,255,.94); color: var(--ink); display: grid; place-items: center;
}
.mm-tools button svg { width: 14px; height: 14px; }
.mm-tools button:disabled { opacity: .35; cursor: default; }
.mm-tools button[data-action="media-remove"] { color: var(--red-ink); margin-left: auto; }
.dropzone {
  display: flex; align-items: center; gap: 12px; padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone svg { width: 22px; height: 22px; color: var(--myrtille); }
.dropzone strong { display: block; color: var(--ink); }
.dropzone small { color: var(--ink-3); font-size: 12px; }
.dropzone:hover, .dropzone.drop-over { border-color: var(--myrtille); background: var(--myrtille-50); }
.dropzone.busy { pointer-events: none; opacity: .7; }
.mm-hint { margin: 0; font-size: 12px; color: var(--ink-3); }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(10, 11, 14, .94); display: none; align-items: center; justify-content: center;
  padding: 64px 16px 24px;
}
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; color: #E7E9EE; font-weight: 600; }
.lb-top .icon-btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center;
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }

/* ---------- client portal ---------- */
.portal { max-width: 1120px; width: 100%; margin: 0 auto; padding: 8px 24px 120px; }
.hello { display: flex; gap: 24px; align-items: center; padding: 24px 0 18px; flex-wrap: wrap; }
.hello h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.hello p { margin: 0; color: var(--ink-2); }
.progress { flex: 1; min-width: 240px; max-width: 360px; margin-left: auto; }
.progress-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.bar { height: 8px; background: var(--muted); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--myrtille); border-radius: 999px; transition: width .4s; }
.week { margin-top: 26px; }
.week-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.week-head h3 { margin: 0; font-size: 15px; }
.week-head .muted { font-size: 13px; }
.week-head .btn { margin-left: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card .visual { border: 0; border-radius: 0; aspect-ratio: 4 / 3; cursor: pointer; }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.card-meta .chip { margin-left: auto; }
.card h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.card .excerpt { color: var(--ink-2); font-size: 13px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.card .read-more { border: 0; background: none; padding: 0; color: var(--myrtille-700); font-weight: 600; font-size: 13px; align-self: flex-start; }
.card-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.card-actions .btn { flex: 1; }
.card-done { margin: 0 16px 16px; padding: 10px 12px; border-radius: var(--radius); font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.card-done.ok { background: var(--green-bg); color: var(--green-ink); }
.card-done.ko { background: var(--red-bg); color: var(--red-ink); }
.card-done button { margin-left: auto; border: 0; background: none; color: inherit; text-decoration: underline; font-size: 12px; }
.card .composer-wrap { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.card .composer-wrap .row { display: flex; gap: 8px; }
.card .composer-wrap .row .btn { flex: 1; }

.portal-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; color: var(--ink-2);
  display: inline-flex; gap: 6px; align-items: center;
}
.pill b { font-size: 11px; background: var(--muted); color: var(--ink-2); border-radius: 999px; padding: 1px 7px; }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.on b { background: rgba(255,255,255,.18); color: #fff; }
.all-done { text-align: center; padding: 56px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); margin-top: 24px; }
.all-done .big { width: 56px; height: 56px; border-radius: 50%; background: var(--green-bg); color: var(--green-ink); display: grid; place-items: center; margin: 0 auto 12px; }
.all-done .big svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 12px 10px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center;
  animation: pop .2s ease-out; font-weight: 500;
}
.toast svg { color: #8FE3B0; }
.toast button { border: 0; background: rgba(255,255,255,.12); color: #fff; border-radius: 8px; padding: 4px 10px; font-weight: 600; font-size: 13px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-pillar { display: none; }
}
@media (max-width: 1024px) {
  .app { padding: 0; gap: 0; }
  .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; height: 100vh; background: var(--bg); transform: translateX(-100%);
    transition: transform .25s; box-shadow: var(--shadow-lg);
  }
  .sidebar.on { transform: none; }
  .main { border-radius: 0; border: 0; min-height: 100vh; }
  .menu-btn { display: grid; }
  .header { position: sticky; top: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); z-index: 30; padding: 12px 16px; }
  .toolbar, .kpis { padding-left: 16px; padding-right: 16px; }
  .table-wrap, .cal, .bulkbar { margin-left: 16px; margin-right: 16px; }
  .hide-md { display: none !important; }
}
@media (max-width: 720px) {
  .header { gap: 8px; }
  .header > div:nth-child(2) { flex: 1; }
  .header h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-actions { margin-left: 0; gap: 6px; }
  .role-switch button { padding: 6px 9px; }
  .crumbs { display: none; }
  .hide-sm { display: none !important; }
  .toolbar { gap: 8px; }
  .toolbar .tabs { width: 100%; }
  .toolbar .tab { flex: 1; justify-content: center; }
  .toolbar .spacer { display: none; }
  .toolbar .select { flex: 1 1 40%; min-width: 0; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px; gap: 8px; }
  .kpi-icon { display: none; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 12px; }
  .table-wrap table { display: none; }
  .m-list { display: block; }
  .m-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .m-item:last-child { border-bottom: 0; }
  .m-item .grow { flex: 1; min-width: 0; }
  .m-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-item small { color: var(--ink-3); font-size: 12px; }
  .table-foot .muted { display: none; }
  .cal-day { min-height: 64px; padding: 3px; }
  .cal-ev { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
  .cal-dow { padding: 6px 4px; text-align: center; }
  .portal { padding: 0 16px 120px; }
  .hello h2 { font-size: 20px; }
  .progress { max-width: none; }
  .cards { grid-template-columns: 1fr; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 92vh; border-radius: 18px 18px 0 0; transform: translateY(100%); }
  .drawer.on { transform: none; }
  .week-head { flex-wrap: wrap; }
  .week-head .btn { margin-left: 0; width: 100%; }
}

/* ===================== application connectée ===================== */
.app.bare .sidebar { display: none; }
.app.bare .main { background: transparent; border: 0; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.workspace .icon-btn.sm { border-color: transparent; }
.nav a.sub.on { color: var(--ink); font-weight: 600; }

.input {
  width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 12px; background: var(--surface);
  outline: 0; color: var(--ink);
}
.input:focus { border-color: var(--myrtille); box-shadow: 0 0 0 3px var(--myrtille-50); }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form-err { color: var(--red-ink); font-size: 13px; margin: 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--myrtille-700); font-weight: 600; text-decoration: underline; cursor: pointer; }

.auth { min-height: calc(100vh - 32px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 18px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.auth-card.wide { max-width: 480px; }
.auth-card .brand { padding: 0 0 6px; }
.auth-card h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.auth-card p { margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.auth-form .btn { height: 44px; margin-top: 4px; }
.auth-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--myrtille-50); color: var(--myrtille); display: grid; place-items: center; }
.auth-icon svg { width: 24px; height: 24px; }
.auth-note { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: 13px; color: var(--ink-2); }
.auth-note svg { flex: none; margin-top: 1px; color: var(--ink-3); }
.auth-foot { color: var(--ink-3); font-size: 12px; margin: 0; }
.copyable { cursor: pointer; color: var(--myrtille-700); word-break: break-all; }

.loader { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--myrtille-100); border-top-color: var(--myrtille); animation: spin .8s linear infinite; }
.loader.small { width: 20px; height: 20px; border-width: 2px; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-hero { max-width: 560px; margin: 64px auto; padding: 0 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-hero h2 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.02em; }
.empty-hero p { margin: 0; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.preview-banner { display: flex; gap: 10px; align-items: center; margin: 16px 24px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--myrtille-50); color: var(--myrtille-700); border: 1px solid var(--myrtille-100); font-size: 13px; }

.invite-row { display: flex; gap: 8px; }
.invite-row .btn { height: 42px; }
.people { display: flex; flex-direction: column; gap: 4px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); }
.person:hover { background: var(--surface-2); }
.person .grow { flex: 1; min-width: 0; }
.person strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { color: var(--ink-3); font-size: 12px; }
.person.pending .avatar { background: var(--muted); color: var(--ink-3); }
.person .avatar svg { width: 15px; height: 15px; }

.toast.err { background: #3A1512; }
.toast.err svg { color: #FDA29B; }
.btn:disabled { opacity: .55; cursor: default; }

/* ===================== application installée (PWA) ===================== */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
@media (max-width: 1024px) {
  .header { padding-top: calc(12px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
  .sidebar { padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .portal, .table-wrap, .cal { margin-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .bulkbar { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
.auth { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(24px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); }
.lightbox { padding-top: calc(64px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.lb-top { padding-top: calc(12px + env(safe-area-inset-top)); }
@media (max-width: 720px) {
  .drawer { padding-bottom: env(safe-area-inset-bottom); }
  .is-standalone .drawer { height: calc(100vh - env(safe-area-inset-top) - 8px); }
  .btn, .icon-btn, .pill, .tab { min-height: 40px; }
  .card-actions .btn { height: 44px; }
}

.pwa-banner {
  position: fixed; z-index: 70; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: var(--shadow-lg);
  transform: translateY(140%); transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.pwa-banner.on { transform: none; }
.pwa-banner img { border-radius: 11px; flex: none; }
.pwa-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-text strong { font-size: 15px; }
.pwa-text span { font-size: 13px; color: var(--ink-2); }
.pwa-steps { margin: 8px 0 2px; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.pwa-steps .i { width: 16px; height: 16px; vertical-align: -3px; color: var(--myrtille); }
.pwa-actions { display: flex; gap: 8px; margin-top: 8px; }
.pwa-steps[hidden] { display: none; }
.pwa-text strong { padding-right: 28px; }
.pwa-close { position: absolute; top: 8px; right: 8px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--ink-3); width: 32px; height: 32px; border-radius: 8px; }
.pwa-close:hover { background: var(--muted); }
