/* RelatIA — coque type TalentIA, accent bleu du logo */
:root {
  --side: #071422;
  --side-2: #0e1c36;
  --side-line: #1a335c;
  --side-text: #cbd5e1;
  --side-mute: #64748b;
  --accent: #5b8cff;
  --accent-2: #8eb0ff;
  --accent-deep: #3d6fe0;
  --bg: #0b1524;
  --panel: #122033;
  --stroke: #1e3348;
  --text: #e8eef8;
  --muted: #94a3b8;
  --field: #0f1c2a;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #7aa2ff;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 2px;
}

html[data-theme="light"] {
  --bg: #f8fafc;
  --panel: #ffffff;
  --stroke: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --field: #ffffff;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --info: #3d6fe0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.relatia-app {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--accent-deep); text-decoration: none; }
html[data-theme="dark"] a,
html:not([data-theme]) a { color: var(--accent-2); }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

.app-shell { min-height: 100vh; }
.sidebar {
  width: 14rem;
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  border-right: 1px solid var(--side-line);
}
.sidebar-brand {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--side-line);
}
.sidebar-brand a { display: block; line-height: 0; }
.sidebar-brand a:hover { text-decoration: none; }
.sidebar-logo {
  display: block;
  height: 4rem;
  width: auto;
  max-width: 10rem;
  object-fit: contain;
  object-position: left center;
}
.sidebar-close,
.sidebar-open {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  display: none;
}
.sidebar-close { color: var(--side-text); padding: 0.25rem; margin-top: 0.25rem; }
.sidebar-close:hover,
.sidebar-open:hover { background: var(--side-2); color: #fff; }
.sidebar-nav {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.62rem 1.15rem;
  color: var(--side-text);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.side-link:hover {
  background: var(--side-2);
  color: #fff;
  text-decoration: none;
}
.side-link.is-active {
  background: var(--side-2);
  color: #fff;
  border-left-color: var(--accent);
}
.side-link svg { flex: 0 0 auto; }
.side-link-text { min-width: 0; display: flex; flex-direction: column; }
.side-link-label { font-size: 0.875rem; font-weight: 500; }
.side-link-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--side-mute);
}
.app-main {
  margin-left: 14rem;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  backdrop-filter: blur(8px);
}
html[data-theme="light"] .app-top { background: rgba(255, 255, 255, 0.95); }
.app-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.app-rule {
  height: 0;
  border-top: 1px solid var(--stroke);
}
.relatia-app .delta-who { margin-left: auto; }
.relatia-app .delta-who__avatar {
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.16);
  background: radial-gradient(circle at 35% 30%, #1e3a6e, #071422 72%);
}
html[data-theme="light"] .relatia-app .delta-who__avatar {
  color: #0f172a;
  background: radial-gradient(circle at 35% 30%, #dbe7ff, #f8fafc 70%);
  border-color: rgba(61, 111, 224, 0.5);
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.12);
}
html[data-theme="dark"] .relatia-app .delta-who__role,
html:not([data-theme]) .relatia-app .delta-who__role {
  background: rgba(91, 140, 255, 0.16);
  color: #b9d0ff;
}
html[data-theme="light"] .relatia-app .delta-who__role {
  background: rgba(91, 140, 255, 0.14);
  color: #2f5ec4;
}
html[data-theme="dark"] .relatia-app .delta-who__out,
html:not([data-theme]) .relatia-app .delta-who__out {
  color: #b9d0ff;
  border-color: rgba(91, 140, 255, 0.45);
  background: rgba(7, 20, 34, 0.72);
}
html[data-theme="light"] .relatia-app .delta-who__out {
  color: #2f5ec4;
  border-color: rgba(61, 111, 224, 0.35);
  background: #fff;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 34, 0.6);
  z-index: 30;
}
.sidebar-backdrop.is-open { display: block; }

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.5rem 1.5rem 2.5rem;
  flex: 1;
}
.page-head { margin-bottom: 1rem; }
.page-head h1 {
  margin: 0.1rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.eyebrow {
  margin: 0;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.sub, .muted { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.8rem; }
.back { margin: -0.25rem 0 0.85rem; color: var(--muted); font-size: 0.85rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 0.95rem; }
.panel h3 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--accent-deep); }
html[data-theme="dark"] .panel h3,
html:not([data-theme]) .panel h3 { color: var(--accent-2); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-head h2 { margin: 0; }
.panel-sub {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--stroke);
}
.panel-sub p { margin: 0.3rem 0 0.7rem; color: var(--muted); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi-grid--compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kpi-val { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi-hint { color: var(--muted); font-size: 0.75rem; }

.split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.table-wrap { overflow: auto; }
.table-wrap.panel { padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: color-mix(in srgb, var(--bg) 70%, var(--panel));
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.keep { white-space: nowrap; }
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover, .th-sort.is-active { color: var(--accent-deep); text-decoration: none; }
html[data-theme="dark"] .th-sort:hover,
html[data-theme="dark"] .th-sort.is-active,
html:not([data-theme]) .th-sort:hover,
html:not([data-theme]) .th-sort.is-active { color: var(--accent-2); }
tr:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar input[type="search"],
.login-form input,
.stack-form input,
.stack-form textarea,
.stack-form select,
.inline-form input {
  background: var(--field);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  outline: none;
  min-width: 0;
  color: var(--text);
}
.toolbar input[type="search"] { flex: 1; min-width: 220px; }
.toolbar input:focus,
.login-form input:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus,
.inline-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.875rem;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #071422; }
.btn-primary:hover { background: #7aa2ff; }
.btn-ghost {
  background: transparent;
  border-color: var(--stroke);
  color: var(--text);
  font-weight: 600;
}
.btn-ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.flash {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--stroke);
}
.flash--ok { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); }
.flash--err { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }
.empty {
  padding: 0.9rem;
  color: var(--muted);
  border: 1px dashed var(--stroke);
  border-radius: var(--radius);
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge--ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.badge--warn { background: rgba(251, 191, 36, 0.14); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.badge--danger { background: rgba(248, 113, 113, 0.14); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.badge--info { background: rgba(91, 140, 255, 0.14); color: var(--info); border-color: rgba(91, 140, 255, 0.3); }
.badge--muted { background: rgba(100, 116, 139, 0.12); color: var(--muted); }

.kv { display: grid; gap: 0.45rem; margin: 0; }
.kv > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--stroke);
}
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; }

.crm-block { margin-bottom: 1.1rem; }
.stack-form, .inline-form { display: grid; gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-form { grid-template-columns: 1fr auto; align-items: center; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.12);
  border: 1px solid rgba(91, 140, 255, 0.28);
  font-size: 0.8rem;
}
.crm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.crm-list li {
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
  border: 1px solid var(--stroke);
}
.crm-list li.is-done { opacity: 0.55; text-decoration: line-through; }
.linkish {
  background: none;
  border: 0;
  color: var(--accent-deep);
  cursor: pointer;
  padding: 0;
  margin-top: 0.25rem;
}
html[data-theme="dark"] .linkish,
html:not([data-theme]) .linkish { color: var(--accent-2); }
.linkish:hover { text-decoration: underline; }
.check {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}

.action-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.action-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
  border: 1px solid var(--stroke);
}
.action-list--wide li { flex-wrap: wrap; }
.action-list li.is-overdue { border-color: rgba(248, 113, 113, 0.45); }
.action-list time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.pager { margin: 1rem 0; text-align: center; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0.85rem 1.5rem 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Connexion */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(700px 380px at 80% -10%, rgba(91, 140, 255, 0.2), transparent 55%),
    linear-gradient(180deg, #071422 0%, #0b1524 100%);
}
html[data-theme="light"] body.login-body {
  background:
    radial-gradient(700px 380px at 80% -10%, rgba(91, 140, 255, 0.16), transparent 55%),
    linear-gradient(180deg, #eef2f8 0%, #f8fafc 100%);
}
.gate-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.gate-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}
.gate-hero[hidden],
.gate-box[hidden] { display: none !important; }
.gate-hero img { display: block; height: 96px; width: auto; object-fit: contain; }
.login-card, .gate-box {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 48px));
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 48px);
}
html[data-theme="light"] .gate-box {
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}
.gate-box.is-pinned { position: fixed; margin: 0; }
.gate-box.is-max {
  position: fixed;
  inset: 16px;
  width: auto;
  height: auto;
  max-height: none;
  margin: 0;
}
.gate-box.is-min {
  position: fixed;
  left: 18px;
  bottom: 70px;
  width: auto;
  height: auto;
  max-height: none;
  border-radius: 999px;
  border-top-width: 0;
}
.gate-box.is-min .gate-body,
.gate-box.is-min .gate-resize { display: none; }
.gate-box.is-min .gate-header {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #122033;
}
html[data-theme="light"] .gate-box.is-min .gate-header { background: #fff; }
.gate-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: #0c1828;
  border-bottom: 1px solid var(--side-line);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.gate-box.is-max .gate-header,
.gate-box.is-min .gate-header { cursor: default; }
.gate-box.is-max .gate-header { padding-right: 3.4rem; }
html[data-theme="light"] .gate-header {
  background: #e8f0ff;
  border-bottom-color: #d5e3f6;
}
.gate-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  flex: 1;
  min-width: 0;
  color: #e2e8f0;
}
html[data-theme="light"] .gate-header h2 { color: #071422; }
.gate-win {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  flex-shrink: 0;
}
.km-win {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 -1px 1px rgba(0, 0, 0, 0.18) inset;
}
.km-win:hover { transform: scale(1.1); }
.km-win-min { background: radial-gradient(120% 90% at 30% 18%, #ffe27a 0%, #ffc53d 38%, #f5a623 72%, #d8890c 100%); }
.km-win-max { background: radial-gradient(120% 90% at 30% 18%, #7dff8f 0%, #3fd65a 38%, #22c53e 72%, #14a32e 100%); }
.km-win-close { background: radial-gradient(120% 90% at 30% 18%, #ff9a93 0%, #ff6b63 38%, #ff3b30 72%, #d92018 100%); }
.km-win::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: center / 11px 11px no-repeat;
  pointer-events: none;
}
.km-win-min::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6h7.6' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.km-win-max::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Crect x='2.6' y='2.6' width='6.8' height='6.8' rx='0.6' fill='none' stroke='%23fff' stroke-width='1.7'/%3E%3C/svg%3E"); }
.km-win-max.is-restore::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.2 2.8h5v5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3Crect x='2.4' y='4' width='5.2' height='5.2' rx='0.4' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E"); }
.km-win-close::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3l6 6M9 3L3 9' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.gate-body {
  padding: 1.25rem 1.4rem 1.4rem;
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.gate-logo {
  display: block;
  margin: 0 auto 0.35rem;
  height: 72px;
  width: auto;
  object-fit: contain;
}
.gate-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 2;
}
.gate-resize::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
}
.gate-box.is-max .gate-resize { display: none; }
.login-lead { text-align: center; color: var(--muted); margin: 0.2rem 0 1rem; font-size: 13px; }
.login-form { display: grid; gap: 0.85rem; }
.login-form label { display: grid; gap: 0.35rem; }
.login-form label span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-form .btn { margin-top: 0.15rem; }

@media (max-width: 1100px) {
  .kpi-grid, .kpi-grid--compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.is-open { transform: none; }
  .sidebar-close, .sidebar-open { display: inline-flex; }
  .app-main { margin-left: 0; }
  .app-kicker { display: none; }
  .kpi-grid, .kpi-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row2, .inline-form { grid-template-columns: 1fr; }
  .kv > div { grid-template-columns: 1fr; }
}
