/* =================================================================== CRM IKKO */
:root {
  --bg: #f3f5f9; --card: #fff; --text: #3b4656; --muted: #8a94a6; --line: #e6e9ef;
  --blue: #3c8dbc; --blue-d: #2f74a0; --link: #3a7fc4; --teal: #36c2cf; --green: #27ae60; --green-l: #45b9a3;
  --red: #e84c55; --orange: #f39c45; --gold: #c9a24a; --purple: #8e44ad; --grey: #e4e4e4;
  --radius: 4px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Open Sans", "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; margin: 0 0 12px; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ Formulaires */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=email], input[type=search], input[type=tel], input[type=color], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid #cfd6e0; border-radius: var(--radius); background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(60,141,188,.15); }
label { display: block; font-size: 12px; font-weight: 600; color: #5b6676; margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; font-size: 14px; color: var(--text); cursor: pointer; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--blue); color: #fff; cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none !important; white-space: nowrap; }
.btn:hover { filter: brightness(.95); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-green { background: var(--green); } .btn-teal { background: var(--green-l); } .btn-red { background: var(--red); }
.btn-orange { background: var(--orange); } .btn-grey { background: #fff; color: var(--text); border-color: #cfd6e0; }
.btn-dark { background: #3b4656; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

/* ------------------------------------------------------------------ Cartes & tableaux */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-title { display: flex; align-items: center; gap: 8px; color: var(--blue-d); font-weight: 700; text-transform: uppercase;
  font-size: 14px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.card-title .grow { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; color: #6b7685; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid #f0f2f6; vertical-align: top; }
tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eef1f5; color: #4b5563; white-space: nowrap; }
.st-nouvelle { background: #e3f0fb; color: #1f6fb2; } .st-a_rappeler { background: #efe6fa; color: #7d3cb5; }
.st-en_relance { background: #fff2df; color: #b26a00; } .st-confirmee { background: #dff5e7; color: #1e8449; }
.st-annulee { background: #fde4e4; color: #c0392b; } .st-cloturee { background: #ececec; color: #666; }
.dl-a_envoyer { background: #fff2df; color: #b26a00; } .dl-envoyee, .dl-en_cours { background: #e3f0fb; color: #1f6fb2; }
.dl-erreur, .dl-retour { background: #fde4e4; color: #c0392b; } .dl-livree { background: #dff5e7; color: #1e8449; } .dl-annulee { background: #ececec; color: #666; }
.cat-positif { color: var(--green); } .cat-argumente { color: var(--blue); } .cat-non_argumente { color: var(--orange); }
.alert { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #e8f7ee; border-color: #b8e4c8; color: #1e7a45; }
.alert-error { background: #fdecec; border-color: #f5c2c2; color: #b03030; }
.alert-info { background: #e8f2fb; border-color: #bcd8f1; color: #23628f; }
.pager { margin-top: 14px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.pager a.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters > div { min-width: 140px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 14px; border-left: 3px solid var(--line); margin-left: 4px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.timeline li.positif::before { background: var(--green); } .timeline li.non_argumente::before { background: var(--orange); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--blue-d); border-color: var(--blue); }
.modal-bg { position: fixed; inset: 0; background: rgba(30,36,46,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 4px; width: 100%; max-width: 1100px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-close { background: none; border: 0; font-size: 24px; color: #aaa; cursor: pointer; }

/* =================================================================== Interface agent (style Comunik) */
.ag-top { position: sticky; top: 0; z-index: 50; height: 74px; background: #fff; display: flex; align-items: center; padding: 0 20px; gap: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.ag-burger { width: 22px; height: 16px; border-top: 2px solid #c3c9d2; border-bottom: 2px solid #c3c9d2; position: relative; margin-right: 30px; }
.ag-burger::after { content: ""; position: absolute; left: 0; right: 0; top: 5px; border-top: 2px solid #c3c9d2; }
.ag-actions { position: relative; }
.ag-actions > button { background: #f0625a; color: #fff; border: 0; padding: 7px 12px; font-size: 13px; border-radius: 2px; cursor: pointer; }
.dropdown { position: absolute; top: 100%; left: 0; background: #4f5b69; min-width: 220px; border-radius: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.2); display: none; z-index: 60; padding: 6px 0; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 16px; color: #fff; background: none; border: 0; text-align: left; cursor: pointer; font-size: 13px; }
.dropdown a:hover, .dropdown button:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.pill { background: #6b6f75; color: #fff; padding: 5px 12px; border-radius: 12px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill.live { background: var(--green); } .pill.alert { background: var(--red); }
.ag-user { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 74px; background: #f7f8fa; color: var(--link); font-weight: 700; font-size: 13px; position: relative; cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #b9bec5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='15' r='8' fill='%23878d95'/%3E%3Cpath d='M5 38c2-9 8-13 15-13s13 4 15 13z' fill='%23878d95'/%3E%3C/svg%3E") center/cover; }
.ag-user .dropdown { left: auto; right: 0; top: 74px; }
.ag-wrap { display: flex; gap: 16px; padding: 20px; align-items: flex-start; }
.ag-rail { width: 54px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); padding: 10px 0; position: sticky; top: 94px; flex-shrink: 0; }
.ag-rail a { display: flex; justify-content: center; padding: 12px 0; color: #9aa3ae; position: relative; }
.ag-rail a:hover, .ag-rail a.active { color: var(--blue); background: #f3f6fa; }
.ag-rail svg { width: 20px; height: 20px; }
.ag-rail .count { position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; padding: 1px 5px; font-weight: 700; }
.ag-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.ag-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.profile { text-align: center; padding: 30px 18px; }
.profile .avatar { width: 150px; height: 150px; margin: 0 auto 16px; }
.profile .name { font-size: 20px; font-weight: 700; color: #4d5866; }
.profile .meta { color: var(--link); font-weight: 700; font-size: 13px; margin: 12px 0; text-transform: uppercase; }
.state-box { margin-top: 10px; font-size: 13px; }
.pauses h3 { font-size: 16px; color: #5b6676; font-weight: 600; margin-bottom: 14px; }
.pauses form button { display: flex; align-items: center; gap: 14px; background: none; border: 0; color: var(--link); font-weight: 600; padding: 8px 0; cursor: pointer; width: 100%; text-align: left; }
.pauses form button.on { color: var(--red); }
.pause-ico { width: 18px; height: 16px; display: inline-flex; gap: 4px; }
.pause-ico i { width: 6px; background: #b6bcc5; display: block; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; }
@media (max-width: 1250px) { .tiles { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.tile { position: relative; overflow: hidden; height: 118px; color: #fff; padding: 18px 16px; text-align: right; border-radius: 1px; }
.tile .v { font-size: 34px; line-height: 1; font-weight: 300; position: relative; }
.tile .l { font-size: 16px; position: relative; margin-top: 4px; }
.tile .f { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 11px; text-align: left; background: rgba(0,0,0,.1); text-transform: uppercase; }
.tile .bgico { position: absolute; left: 6px; top: 8px; width: 90px; height: 90px; opacity: .22; }
.tile.time .v { font-size: 34px; }
.t-gold { background: #c49a45; } .t-teal { background: #31c3d1; } .t-grey { background: #e2e2e2; color: #333; }
.t-blue { background: #3b97de; } .t-purple { background: #8e44ad; } .t-blue2 { background: #3498db; } .t-red { background: #e74c56; } .t-cyan { background: #2fc4d0; }
.ag-footer { position: fixed; bottom: 0; left: 0; right: 0; background: #e9edf5; padding: 9px 40px; display: flex; gap: 18px; font-size: 13px; z-index: 40; align-items: center; flex-wrap: wrap; }
.ag-footer b { color: var(--link); }
.ag-footer .copy { margin-right: 160px; }
body.agent { padding-bottom: 50px; }
.tile .v { font-size: clamp(22px, 2.4vw, 34px) !important; white-space: nowrap; }
@media (max-width: 1150px) {
  .ag-side { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .ag-side > .card { flex: 1 1 260px; }
  .profile .avatar { width: 90px; height: 90px; }
  .ag-footer .copy { margin-right: 20px; }
}
@media (max-width: 800px) {
  .ag-top { height: auto; min-height: 60px; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .ag-burger, #pillState, .ag-user .avatar { display: none; }
  .ag-user { height: 44px; padding: 0 8px; background: none; }
  .ag-user .dropdown { top: 44px; }
  .ag-wrap { padding: 10px; gap: 10px; }
  .ag-rail { position: fixed; bottom: 40px; top: auto; left: 0; right: 0; width: auto; display: flex; justify-content: space-around; padding: 0; z-index: 45; }
  .ag-rail a { padding: 10px; }
  body.agent { padding-bottom: 110px; }
  .ag-footer { padding: 6px 12px; gap: 10px; font-size: 11px; }
  .ag-footer .copy { display: none; }
  .tiles { gap: 10px; }
  .tile { height: 96px; padding: 12px; }
  .cal td { height: 44px; }
}

/* Calendrier des rappels */
.cal-layout { display: grid; grid-template-columns: 230px 1fr; gap: 24px; }
@media (max-width: 1000px) { .cal-layout { grid-template-columns: 1fr; } }
.qfilter { display: block; width: 100%; text-align: left; background: #4a90e2; color: #fff; border: 0; border-left: 34px solid #d5d7da; padding: 8px 12px; margin-bottom: 8px; cursor: pointer; font-size: 14px; }
.qfilter.off { opacity: .45; }
.cal-head { display: flex; align-items: center; margin-bottom: 14px; }
.cal-head .nav button { background: #f4f4f4; border: 1px solid #ccc; padding: 4px 12px; cursor: pointer; }
.cal-head h2 { flex: 1; text-align: center; font-size: 28px; font-weight: 400; margin: 0; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { text-align: center; border: 1px solid #ddd; padding: 2px; font-size: 12px; text-transform: none; color: #333; font-weight: 700; }
.cal td { border: 1px solid #ddd; height: 56px; vertical-align: top; padding: 2px; text-align: right; font-size: 11px; color: #333; }
.cal td.other { color: #aaa; } .cal td.today { background: #fcf8e3; }
.cal .ev { display: block; background: var(--orange); color: #fff; text-align: left; padding: 1px 4px; margin-top: 2px; font-size: 10px; cursor: pointer; border-radius: 2px; }
.cb-card { background: #f4f7fa; border: 1px solid #dfe5ec; padding: 18px 20px; font-size: 12px; }
.cb-card h4 { color: #5d7591; text-transform: uppercase; font-size: 16px; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid #dfe5ec; }
.cb-card .who { display: flex; align-items: center; gap: 8px; color: var(--red); font-size: 16px; margin-bottom: 8px; }
.cb-card .who .ico { background: var(--green-l); color: #fff; width: 40px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cb-card div.l { margin: 5px 0; color: #555; } .cb-card div.l b { color: #333; }

/* Fiche de traitement */
.lead-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 16px; }
@media (max-width: 1150px) { .lead-grid { grid-template-columns: 1fr; } }
.lead-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lead-head .phone { font-size: 24px; font-weight: 700; color: var(--blue-d); letter-spacing: .5px; }
.items td { padding: 5px 4px; } .items input { padding: 5px 7px; }
.qual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; margin-bottom: 12px; }
.qual-grid label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-left: 4px solid var(--c); padding: 8px; border-radius: 3px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--text); margin: 0; }
.qual-grid input { width: auto; margin: 0; }
.qual-grid label:has(input:checked) { background: #eef5fc; border-color: var(--c); }
.timer { font-family: Consolas, monospace; font-size: 18px; color: var(--blue-d); }

/* =================================================================== Admin (Control Hub) */
body.admin { background: #f4f6fb; }
.ad-shell { display: flex; min-height: 100vh; }
.ad-side { width: 240px; background: #1d2033; color: #c9cde0; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.ad-brand { padding: 20px; font-weight: 700; color: #fff; font-size: 17px; border-bottom: 1px solid #2c3048; }
.ad-brand small { display: block; font-weight: 400; color: #8c91ad; font-size: 11px; margin-top: 2px; }
.ad-side h6 { margin: 18px 20px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6e7393; }
.ad-side a { display: flex; gap: 10px; padding: 8px 20px; color: #c9cde0; font-size: 13px; }
.ad-side a:hover { background: #262a42; text-decoration: none; color: #fff; }
.ad-side a.active { background: #2d3150; color: #fff; border-left: 3px solid #7c6cf2; padding-left: 17px; }
.ad-main { flex: 1; min-width: 0; }
.ad-top { background: #fff; height: 60px; display: flex; align-items: center; padding: 0 24px; gap: 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.ad-top h1 { margin: 0; font-size: 18px; flex: 1; }
.ad-content { padding: 22px 24px 40px; }
.kpi { background: #fff; border-radius: 6px; padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--kc, var(--blue)); }
.kpi .v { font-size: 26px; font-weight: 700; color: #2b3445; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.bar { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--blue); }
.hub { background: linear-gradient(180deg,#1c1f33,#22253c); min-height: 100vh; padding: 30px; color: #d6d9ea; }
.hub-head { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); border-top: 3px solid #a46bf2; border-radius: 12px; text-align: center; padding: 26px; margin-bottom: 28px; }
.hub-head h1 { color: #fff; font-size: 26px; }
.hub-head input { max-width: 420px; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #fff; }
.hub h2 { font-size: 15px; color: #fff; margin: 26px 0 12px; border-left: 3px solid #7c6cf2; padding-left: 10px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 14px; }
.hub-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 16px; color: #d6d9ea; display: block; position: relative; }
.hub-card:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.hub-card b { color: #fff; display: block; margin: 10px 0 4px; font-size: 14px; }
.hub-card span { font-size: 12px; color: #9da2bf; }
.hub-card .ico { width: 34px; height: 34px; border-radius: 8px; background: rgba(124,108,242,.25); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.hub-card .tag { position: absolute; top: 12px; right: 12px; font-size: 9px; font-weight: 700; background: #f39c12; color: #fff; border-radius: 8px; padding: 2px 7px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 6px; }
.dot.production { background: var(--green); } .dot.pause { background: var(--orange); } .dot.debrief { background: var(--purple); } .dot.idle { background: #3b97de; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1d2033,#3c8dbc); padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
pre.json { background: #1d2033; color: #c9e3ff; padding: 12px; font-size: 11px; max-height: 260px; overflow: auto; border-radius: 4px; white-space: pre-wrap; word-break: break-all; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.chart .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); }
.chart .c .b { width: 100%; display: flex; flex-direction: column-reverse; height: 120px; justify-content: flex-start; }
.chart .c .b i { display: block; width: 100%; } .chart .b .r { background: #c9d9ec; } .chart .b .k { background: var(--green); }

/* Admin : écrans étroits (placé en fin de fichier pour primer sur les règles de base) */
@media (max-width: 900px) {
  .ad-shell { flex-direction: column; }
  .ad-side { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 8px; }
  .ad-side .ad-brand { width: 100%; }
  .ad-side h6 { display: none; }
  .ad-side a { padding: 6px 10px; font-size: 12px; }
  .ad-side a.active { padding-left: 7px; }
  .ad-content { padding: 14px; }
  .ad-top { padding: 0 14px; }
  .lead-grid, .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
