/* Tunnel — design épuré, clair, moderne */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- boutons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 14px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eceef2; }
.btn.wide { width: 100%; }
.btn.small { padding: 3px 9px; font-size: 13px; border-radius: 7px; }

/* ---------- login ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f4f5f7 60%);
}
.login-box {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-size: 26px; font-weight: 700; text-align: center; }
.login-sub { margin: -10px 0 6px; text-align: center; color: var(--muted); }
.login-box label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.login-box input {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-size: 15px;
}
.login-box input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.sso-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12.5px; margin: 2px 0;
}
.sso-sep::before, .sso-sep::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
a#sso-op { text-align: center; text-decoration: none; display: block; }
/* Mode SSO seul : le formulaire mot de passe disparaît, le bouton OpenProject devient l'action principale */
.sso-only .pw-only { display: none !important; }
.sso-only #sso-op { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.sso-only #sso-op:hover { background: #4338ca; }

/* ---------- topbar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
#nav { display: flex; gap: 2px; overflow-x: auto; }
#nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
}
#nav a:hover { background: #f1f3f6; color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.user-chip { color: var(--muted); font-size: 14px; white-space: nowrap; }

#view { padding: 20px 18px 60px; }
.page { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.loading { color: var(--muted); text-align: center; padding: 50px 0; }

/* ---------- kanban ---------- */
.kanban {
  display: flex; gap: 14px; align-items: flex-start;
  overflow-x: auto; padding-bottom: 14px;
}
.col {
  flex: 0 0 292px; max-width: 292px;
  background: #ebedf1; border-radius: var(--radius);
  padding: 10px;
}
.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 4px 10px; font-size: 14px;
}
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #94a3b8); flex: none; }
.col-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; margin-left: auto; }
.col-add {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; flex: none;
}
.col-add:hover { background: #dde1e7; color: var(--text); }
.col-cards { display: flex; flex-direction: column; gap: 8px; min-height: 24px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; cursor: grab;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.card:hover { border-color: #c7cdd6; }
.card.ghost { opacity: .4; }
.card-title { font-weight: 600; font-size: 14px; }
.card-company { color: var(--muted); font-size: 13px; margin-top: 1px; }
.card-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.amount { font-weight: 700; font-size: 13px; color: var(--accent); margin-right: auto; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  background: #f1f5f9; color: var(--muted);
}
.badge.late { background: #fef2f2; color: var(--danger); }
.badge.today { background: #fffbeb; color: var(--warn); }
.badge.soon { background: #f0f9ff; color: #0369a1; }
.badge.notes { background: #f8fafc; }

/* ---------- KPI + entonnoir ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.kpi-num { font-size: 24px; font-weight: 700; }
.kpi-lab { color: var(--muted); font-size: 13px; margin-top: 2px; }
.funnel { display: flex; flex-direction: column; gap: 4px; }
.frow { padding: 4px 0; }
.fbar {
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--c, #94a3b8) 18%, white);
  border-left: 4px solid var(--c, #94a3b8);
  border-radius: 8px; padding: 9px 14px; min-width: 190px;
}
.fname { font-weight: 600; font-size: 14px; }
.fnum { margin-left: auto; font-weight: 700; }
.fmeta { color: var(--muted); font-size: 12.5px; padding: 3px 2px 0; }
.conv { color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 2px 14px; }
.lost-line { color: var(--muted); font-size: 13px; border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 10px; }

/* ---------- relances ---------- */
.rel-group h3 { margin: 4px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.rel-group h3.late { color: var(--danger); }
.rel-group h3.today { color: var(--warn); }
.rel-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; cursor: pointer;
}
.rel-row:hover { border-color: #c7cdd6; }
.rel-main { min-width: 0; }
.rel-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-sub { color: var(--muted); font-size: 13px; }
.stage-chip {
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 20px;
  background: color-mix(in srgb, var(--c, #94a3b8) 16%, white);
  color: color-mix(in srgb, var(--c, #94a3b8) 80%, black);
  white-space: nowrap;
}
.rel-date { margin-left: auto; font-size: 13px; font-weight: 600; white-space: nowrap; }
.rel-date.late { color: var(--danger); }
.rel-date.today { color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* ---------- évolution ---------- */
.chart-panel { height: 380px; }
.chart-panel canvas { max-height: 330px; }

/* ---------- réglages ---------- */
.stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stage-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: #fafbfc;
}
.stage-item .drag { cursor: grab; color: var(--muted); user-select: none; }
.stage-item input[type="color"] {
  width: 30px; height: 30px; border: none; background: none; padding: 0; cursor: pointer;
}
.stage-item input[type="text"] {
  flex: 1; border: 1px solid transparent; background: transparent;
  border-radius: 7px; padding: 5px 8px; font-weight: 600;
}
.stage-item input[type="text"]:hover { border-color: var(--border); background: var(--panel); }
.stage-item input[type="text"]:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.terminal-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.add-stage { display: flex; gap: 8px; margin-top: 12px; }
.add-stage input { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label, .modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.form-grid input, .form-grid select, .modal input, .modal select, .modal textarea {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; font-size: 14.5px;
  background: var(--panel); width: 100%;
}
.form-grid input:focus, .modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.settings-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.users-line { color: var(--muted); font-size: 14px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 14px; overflow-y: auto;
}
.modal {
  width: min(620px, 100%); background: var(--panel);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
  padding: 22px 24px;
}
.modal h2 { margin: 0 0 16px; font-size: 17px; }
.modal .form-grid { margin-bottom: 12px; }
.followup-row { display: flex; align-items: flex-end; gap: 8px; }
.followup-row label { flex: 1; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.modal-foot .grow { flex: 1; }
.notes-sec { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.notes-sec h3 { margin: 0 0 10px; font-size: 14px; }
.note-add { display: flex; gap: 8px; margin-bottom: 12px; }
.note-add textarea { flex: 1; resize: vertical; min-height: 40px; }
.note {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; margin-bottom: 7px; font-size: 14px;
}
.note-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  #topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { font-size: 15px; }
  #nav { order: 3; width: 100%; }
  .user-chip { display: none; }
  #view { padding: 14px 10px 50px; }
  .col { flex-basis: 260px; }
  .form-grid { grid-template-columns: 1fr; }
}
