/* ============================================================
   Omnis Core — coquille visuelle commune.

   La barre supérieure, le lanceur d'applications, le menu de
   compte, la bascule Perso/Pro : identiques dans les quatre
   applications. Une seule feuille — sinon les quatre dérivent.
   ============================================================ */

:root {
  --bg-app:       #f6f8fc;
  --bg-primary:   #ffffff;
  --bg-secondary: #f1f3f6;
  --bg-tertiary:  #e6e9ee;
  --border:       #e3e6eb;
  --border-hov:   #cfd4dc;
  --t-primary:    #16181d;
  --t-secondary:  #454a54;
  --t-muted:      #6b7280;
  --t-dim:        #8b919c;
  --green:        #10a37f;
  --green-d:      #0a7a5e;
  --indigo:       #5c7cfa;
  --indigo-d:     #4c6ef5;
  --sancti:       #7c3aed;
  --amber:        #b76e00;
  --red:          #cc3f3f;
  --radius:       10px;
  --topbar-h:     62px;
  --shadow-pop:   0 12px 40px -12px rgba(16,24,40,.28), 0 2px 8px -2px rgba(16,24,40,.12);
}

* { box-sizing: border-box; }
/* `hidden` doit gagner : plusieurs règles imposent un display. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-app);
  color: var(--t-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; display: block; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; stroke-width: 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; transition: all .14s ease; text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-d); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: var(--bg-primary); border-color: var(--border); color: var(--t-primary); }
.btn-ghost:hover { border-color: var(--border-hov); background: var(--bg-secondary); }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--t-muted);
  padding: 8px; border-radius: 50%; display: flex; transition: background .12s ease;
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--t-primary); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---------------- Barre supérieure ---------------- */

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0; position: relative;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--bg-app);
}
.brand {
  display: flex; align-items: baseline; gap: 5px; font-size: 18px;
  color: var(--t-primary); text-decoration: none; white-space: nowrap; margin-right: 18px;
}
.brand .wm-omnis { font-weight: 800; letter-spacing: -.015em; }
.brand .wm-app { font-weight: 500; font-size: 14px; }

.search { flex: 1; max-width: 720px; position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 14px; color: var(--t-muted); }
.search input {
  width: 100%; padding: 11px 40px 11px 42px; border-radius: 8px;
  border: 1px solid transparent; background: var(--bg-secondary); outline: none;
}
.search input:focus {
  background: var(--bg-primary); border-color: var(--border); box-shadow: var(--shadow-pop);
}
.search-clear { position: absolute; right: 6px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.kind-switch { display: flex; background: var(--bg-secondary); border-radius: 999px; padding: 3px; margin-right: 6px; }
.kind-switch button {
  border: none; background: none; cursor: pointer; padding: 5px 15px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--t-muted);
}
.kind-switch button.active { background: var(--bg-primary); color: var(--t-primary); box-shadow: 0 1px 3px rgba(16,24,40,.14); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--indigo-d); color: #fff; font-weight: 700; font-size: 13.5px;
  display: grid; place-items: center;
}
.avatar:hover { box-shadow: 0 0 0 4px rgba(92,124,250,.18); }
.avatar-lg { width: 46px; height: 46px; font-size: 17px; }

/* ---------------- Lanceur et menu de compte ---------------- */

.popover {
  position: absolute; top: calc(var(--topbar-h) - 6px); right: 12px; z-index: 70;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 14px;
}
.apps-popover { width: 312px; }
.apps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.app-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px; border-radius: 12px; text-decoration: none; color: var(--t-secondary);
  font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.25;
}
.app-tile:hover { background: var(--bg-secondary); color: var(--t-primary); }
.app-tile .tile-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.02em;
}
.app-tile[aria-current="page"] { background: var(--bg-secondary); }
.popover-foot { margin: 12px 4px 2px; font-size: 11.5px; color: var(--t-dim); text-align: center; }

.profile-popover { width: 288px; }
.profile-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid var(--border); }
.profile-head strong { display: block; font-size: 14px; }
.profile-head span { display: block; font-size: 12.5px; color: var(--t-muted); word-break: break-all; }
.popover-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: none; background: none; cursor: pointer; text-align: left;
  border-radius: 8px; color: var(--t-secondary); font-size: 13.5px; text-decoration: none;
}
.popover-item:hover { background: var(--bg-secondary); color: var(--t-primary); }

/* ---------------- Structure commune ---------------- */

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 244px 1fr; }
.app.nav-collapsed .layout { grid-template-columns: 74px 1fr; }
.sidebar { padding: 4px 10px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.pane {
  background: var(--bg-primary); min-height: 0; min-width: 0;
  border: 1px solid var(--border); border-bottom: none; border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
}
.pane-head {
  flex-shrink: 0; padding: 14px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; font-weight: 700;
}
.pane-head .count { font-weight: 500; color: var(--t-dim); font-size: 12.5px; }
.pane-body { overflow-y: auto; flex: 1; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-list li button {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 7px 14px; border: none; background: none; cursor: pointer;
  border-radius: 0 999px 999px 0; color: var(--t-secondary); text-align: left; font-size: 13.5px;
}
.nav-list li button:hover { background: var(--bg-tertiary); }
.nav-list li button.active { background: rgba(16,163,127,.14); color: var(--green-d); font-weight: 700; }
.nav-list .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 700; color: var(--t-muted); }
.nav-list li button.active .badge { color: var(--green-d); }
.side-title {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--t-dim); padding-left: 14px;
}
.app.nav-collapsed .label,
.app.nav-collapsed .side-title { display: none; }

.empty { text-align: center; color: var(--t-dim); padding: 40px 20px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--t-primary); color: #fff; padding: 11px 20px; border-radius: 8px;
  font-size: 13px; z-index: 80; box-shadow: 0 10px 34px -10px rgba(0,0,0,.55);
}
.toast[data-tone="error"] { background: var(--red); }

/* ---------------- Connexion (développement) ---------------- */

.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(50% 42% at 50% 0%, rgba(124,58,237,.10), transparent 72%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: 18px; padding: 40px 34px;
  box-shadow: 0 28px 70px -34px rgba(16,24,40,.34); text-align: center;
}
.login-card .brand { justify-content: center; font-size: 26px; margin: 0 0 10px; }
.login-lead { color: var(--t-muted); margin: 0 0 26px; }
.btn-sancti { width: 100%; background: var(--sancti); color: #fff; }
.btn-sancti:hover { background: #6d28d9; color: #fff; }
.login-local { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 22px; }
.login-local input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.login-local input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(92,124,250,.15); }
.login-error { color: var(--red); font-size: 13px; margin: 0; }
.login-hint { color: var(--t-dim); font-size: 12px; margin: 0; text-align: center; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.nav-open .sidebar {
    display: flex; position: absolute; inset: var(--topbar-h) auto 0 0; width: 262px;
    z-index: 40; background: var(--bg-app); box-shadow: var(--shadow-pop);
  }
  .kind-switch, .brand { display: none; }
}
