@import url("https://fonts.googleapis.com/css2?family=Questrial&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --red: #d93831;
  --red-dark: #b42a24;
  --red-soft: #fbe9e8;
  --ink: #111111;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --line: #e7e4e1;
  --bg: #f6f4f2;
  --card: #ffffff;
  --green: #1f9d55;
  --green-soft: #e3f5ea;
  --amber: #c98500;
  --amber-soft: #fdf3dc;
  --blue: #1d6fd8;
  --blue-soft: #e4effc;
  --grey-soft: #efedeb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --font-title: "Century Gothic", "Questrial", "Avenir Next", sans-serif;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 400; margin: 0; letter-spacing: .01em; }
a { color: var(--red); }
[hidden] { display: none !important; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px; padding: 8px 24px; min-height: 74px;
}
.topbar .brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.topbar .brand img { height: 58px; width: auto; display: block; }
.topbar .sep { width: 1px; height: 34px; background: var(--line); }
.topbar .client-logo { height: 42px; max-width: 180px; object-fit: contain; }
.topbar .spacer { flex: 1; }
.topbar .title { font-family: var(--font-title); font-size: 18px; color: var(--ink-2); }
.topbar .title-block { text-align: right; min-width: 0; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px 14px; padding: 8px 16px; }
  .topbar .brand img { height: 44px; }
  .topbar .client-logo { height: 34px; }
  .topbar .title-hide { display: none; }
  .topbar .title-block { flex-basis: 100%; text-align: left; }
  .wrap { padding: 16px; }
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ---------- boutons & champs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: 500 14px var(--font); padding: 8px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #cfcac6; background: #faf9f8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
label.field small { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: 14px var(--font); padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(217,56,49,.25); border-color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.grid4 { display: grid; grid-template-columns: 2fr .8fr .8fr 1.2fr; gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-pad { padding: 20px; }
.muted { color: var(--ink-3); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- onglets ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 22px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
  appearance: none; border: 0; background: none; font: 500 14px var(--font); color: var(--ink-3);
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--red); }

/* ---------- liste des maquettes ---------- */
.mq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.mq-card { padding: 20px; cursor: pointer; display: flex; flex-direction: column; gap: 14px; transition: transform .15s, box-shadow .15s; }
.mq-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.mq-card .logo-box { height: 56px; display: flex; align-items: center; }
.mq-card .logo-box img { max-height: 56px; max-width: 180px; object-fit: contain; }
.mq-card .logo-ph { width: 56px; height: 56px; border-radius: 12px; background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; font: 22px var(--font-title); }
.mq-card h3 { font-size: 20px; }
.mq-stats { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--grey-soft); color: var(--ink-3); }
.pill.ring { background: var(--red-soft); color: var(--red); }
.pill.call { background: var(--blue-soft); color: var(--blue); }
.pill.err { background: #f6dedc; color: #7a1f1a; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; }
.page-head .client-logo-lg { height: 52px; max-width: 200px; object-fit: contain; }

/* ---------- supervision ---------- */
.board-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.summary .sum { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 120px; }
.summary .sum b { display: block; font: 26px var(--font-title); }
.summary .sum span { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.summary .sum.ring b { color: var(--red); }
.summary .sum.call b { color: var(--blue); }
.summary .sum.idle b { color: var(--green); }
.sort-hint { font-size: 12px; color: var(--ink-3); margin: -6px 0 14px; }

/* Carte "utilisateur" */
.phones { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.phone {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 22px 16px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  transition: border-color .25s, box-shadow .25s, opacity .15s, transform .15s;
}
.phone .ext-tag { position: absolute; top: 12px; left: 14px; font: 600 12px var(--font); color: var(--ink-3); }
.phone .grip { position: absolute; top: 8px; right: 10px; color: #c9c4c0; cursor: grab; padding: 4px; line-height: 0; }
.phone .grip svg { width: 16px; height: 16px; }
.phone[draggable=true] { cursor: grab; }
.phone[draggable=true] .btn { cursor: pointer; }
.phone.dragging { opacity: .35; transform: scale(.97); }

.avatar-wrap { position: relative; width: 92px; height: 92px; margin-top: 4px; }
.avatar {
  width: 92px; height: 92px; border-radius: 50%; overflow: hidden; display: grid; place-items: end center;
  background: var(--st-soft, var(--grey-soft)); color: var(--st, #9a9591);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--st, #d6d1cd); transition: background .25s, box-shadow .25s;
}
.avatar svg { width: 78px; height: 78px; margin-bottom: -6px; opacity: .9; }
.state-ico {
  position: absolute; right: -4px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--st, #9a9591); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 3px #fff;
}
.state-ico svg { width: 18px; height: 18px; }
.phone .ph-name { font: 20px/1.2 var(--font-title); word-break: break-word; margin-top: 8px; }
.phone .badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--st-soft, var(--grey-soft)); color: var(--st, var(--ink-3)); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.phone .ph-call { width: 100%; background: var(--bg); border-radius: 12px; padding: 8px 10px; font-size: 13px; min-height: 48px; display: flex; flex-direction: column; justify-content: center; }
.phone .ph-call .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone .ph-call .meta { color: var(--ink-3); font-size: 12px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.phone .progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 6px; }
.phone .progress i { display: block; height: 100%; background: var(--blue); width: 0; transition: width 1s linear; }
.phone .ph-actions { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; margin-top: auto; }
.phone .ph-actions .btn { flex: 1; justify-content: center; }

.phone.st-offline { --st: #a39e9a; --st-soft: var(--grey-soft); }
.phone.st-offline .avatar svg { opacity: .55; }
.phone.st-offline .ph-name { color: var(--ink-2); }
.phone.st-registering { --st: var(--amber); --st-soft: var(--amber-soft); }
.phone.st-registering .state-ico svg { animation: spin 1.2s linear infinite; }
.phone.st-error { --st: #7a1f1a; --st-soft: #f6dedc; }
.phone.st-idle { --st: var(--green); --st-soft: var(--green-soft); }
.phone.st-ringing { --st: var(--red); --st-soft: var(--red-soft); border-color: var(--red); }
.phone.st-ringing .avatar { animation: ringpulse 1.2s ease-out infinite; }
.phone.st-ringing .state-ico svg { animation: shake 1.2s ease-in-out infinite; transform-origin: 50% 60%; }
.phone.st-incall { --st: var(--blue); --st-soft: var(--blue-soft); border-color: rgba(29,111,216,.45); }
.phone.st-incall .badge .dot { animation: blink 1s infinite; }

@keyframes ringpulse { 0% { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--red), 0 0 0 6px rgba(217,56,49,.45); } 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--red), 0 0 0 22px rgba(217,56,49,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%,50%,100% { transform: rotate(0); } 5%,15%,25%,35% { transform: rotate(-14deg); } 10%,20%,30%,40% { transform: rotate(14deg); } }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .phone.st-ringing .avatar, .phone.st-ringing .state-ico svg, .phone.st-registering .state-ico svg { animation: none; } }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); font-size: 20px; margin-bottom: 6px; }

/* ---------- journal ---------- */
.journal { max-height: 640px; overflow-y: auto; }
.journal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.journal-head h3 { font-size: 17px; }
.ev { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #f1eeec; font-size: 13px; animation: evin .4s ease; }
.ev:last-child { border-bottom: 0; }
.ev .dot { margin-top: 6px; }
.ev .t { color: var(--ink-3); font-size: 12px; }
.ev b { font-weight: 600; }
.ev.k-ringing .dot { color: var(--red); }
.ev.k-answer .dot { color: var(--blue); }
.ev.k-hangup .dot, .ev.k-register .dot { color: var(--green); }
.ev.k-missed .dot, .ev.k-reject .dot, .ev.k-busy .dot { color: var(--amber); }
.ev.k-error .dot { color: #7a1f1a; }
@keyframes evin { from { background: #fff7d6; } to { background: transparent; } }

/* ---------- tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 14px; border-bottom: 1px solid #f1eeec; vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.code-chip { font: 600 15px ui-monospace, Menlo, monospace; letter-spacing: .08em; background: var(--grey-soft); padding: 3px 10px; border-radius: 8px; }

/* ---------- modale ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(17,17,17,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 18px; width: min(620px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 20px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.modal header h2 { font-size: 22px; }
.modal .body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal footer { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.section-title { font: 600 12px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 6px; }

.dropzone { border: 1.5px dashed #d4cfcb; border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 12px; background: #fcfbfa; }
.dropzone audio { height: 36px; max-width: 100%; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 14px; max-width: 360px; animation: evin2 .2s ease; }
.toast.err { background: var(--red); }
@keyframes evin2 { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login / vouchers ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 110% -10%, rgba(217,56,49,.10), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.login-card img.logo { width: 260px; max-width: 100%; align-self: center; }
.login-card .logos { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.login-card .logos img { max-height: 80px; max-width: 170px; object-fit: contain; }
.login-card h1 { font-size: 22px; text-align: center; }
.login-card p { margin: 0; text-align: center; color: var(--ink-2); }
.err-msg { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }
input.code-input { text-align: center; font: 600 22px ui-monospace, Menlo, monospace; letter-spacing: .15em; text-transform: uppercase; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.live-dot .dot { color: var(--green); animation: blink 2s infinite; }
.live-dot.down .dot { color: var(--red); animation: none; }

.footer { text-align: center; color: var(--ink-3); font-size: 12px; padding: 30px 0 10px; }
.footer b { color: var(--red); font-weight: 600; }

/* plein écran (TV) */
body.tv .wrap { max-width: none; }
body.tv .phones { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
body.tv .phone .ph-name { font-size: 24px; }

/* ---------- e-mails simulés ---------- */
.mail-btn { position: absolute; top: 7px; right: 10px; border: 0; background: transparent; color: var(--ink-3);
  cursor: pointer; padding: 4px 6px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px; }
.mail-btn.with-grip { right: 32px; }
.mail-btn:hover { background: var(--grey-soft); color: var(--ink); }
.mail-btn svg { width: 18px; height: 18px; }
.mail-count { font: 600 11px var(--font); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--grey-soft); color: var(--ink-2); display: grid; place-items: center; }
.mail-count.unread { background: var(--red); color: #fff; }
.phone.mail-flash { animation: mailflash 1.6s ease; }
.phone.st-ringing.mail-flash { animation: mailflash 1.6s ease; }
@keyframes mailflash { 0%, 60% { box-shadow: 0 0 0 4px rgba(29,111,216,.35), var(--shadow); } 100% { box-shadow: var(--shadow); } }

.modal.inbox { width: min(720px, 100%); }
.inbox-tools { display: flex; gap: 8px; padding: 14px 22px 0; flex-wrap: wrap; }
.compose { margin: 12px 22px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fcfbfa;
  display: flex; flex-direction: column; gap: 10px; }
.mail-list { padding: 14px 22px 22px; display: flex; flex-direction: column; gap: 8px; }
.mail { border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.mail:hover { border-color: #d6d1cd; }
.mail-head { display: grid; grid-template-columns: 10px 1fr auto; gap: 2px 10px; padding: 10px 14px; align-items: center; }
.mail-head .dot { color: transparent; }
.mail.unread .mail-head .dot { color: var(--red); }
.mail.unread .mail-from, .mail.unread .mail-subject { font-weight: 700; }
.mail-from { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-time { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.mail-subject { grid-column: 2 / 4; font-size: 13px; color: var(--ink-2); }
.mail-body { display: none; padding: 4px 14px 14px 34px; white-space: pre-wrap; font-size: 14px; border-top: 1px solid #f1eeec; padding-top: 12px; }
.mail.open .mail-body { display: block; }
.pill.ia { background: var(--blue-soft); color: var(--blue); font-size: 10px; padding: 1px 7px; vertical-align: 1px; }
.ev.k-email .dot { color: var(--blue); }
textarea { resize: vertical; }
.mcp-url { display: flex; gap: 8px; flex-wrap: wrap; }
.mcp-url input { flex: 1; min-width: 240px; }
pre.snippet { background: #1c1b1a; color: #f3f1ee; border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; margin: 0; }
