:root {
  --bg: #f4efe6;
  --surface: #fbf8f2;
  --surface-2: #efe8db;
  --line: #e2d9c8;
  --ink: #2a251e;
  --ink-2: #6b6255;
  --ink-3: #9a907f;
  --accent: #b5703f;
  --accent-soft: #f1dfcd;
  --green: #3f7d4f;
  --green-soft: #dcebdc;
  --red: #b4473a;
  --red-soft: #f3dad5;
  --amber-soft: #f4e6c4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 45, 25, .05), 0 8px 24px rgba(60, 45, 25, .06);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* Marque */
.brand { display: flex; align-items: center; gap: 10px; font: 600 20px var(--serif); letter-spacing: -.01em; }
.brand-lg { font-size: 30px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 18px; border-radius: 999px; font-weight: 500; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fbf8f2; }
.btn-primary:hover { background: #3d362c; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { background: var(--surface); border-color: var(--red-soft); color: var(--red); }
.btn-block { width: 100%; padding: 13px; }
.btn-small { padding: 7px 14px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.link:hover { color: var(--ink); }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 36px 30px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-card .muted { margin: -8px 0 8px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.login-card input { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--red); margin: 0; font-size: 14px; }

/* Structure */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 28px 18px; display: flex; flex-direction: column; gap: 32px; position: sticky; top: 0; height: 100vh; }
.nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 11px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 500; text-align: left; }
.nav-item svg { width: 18px; height: 18px; fill: currentColor; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #fbf8f2; }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; font-size: 14px; }
.presence { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.presence-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.presence-dot.err { background: var(--red); }
.me { font-weight: 600; }
.sidebar-foot .link { justify-self: start; }

.main { padding: 36px 40px 60px; min-width: 0; }
.demo-banner { background: var(--amber-soft); border: 1px solid #e7d3a3; color: #6d5520; padding: 10px 16px; border-radius: 12px; font-size: 14px; margin-bottom: 24px; }
.page-head { margin-bottom: 24px; display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
.page-head h1 { font: 500 34px/1.1 var(--serif); letter-spacing: -.02em; margin: 0; flex-basis: 100%; }
.page-head p { margin: 0; max-width: 560px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 8px; }
.card-head h2 { margin: 0; font: 500 19px var(--serif); }

/* Téléphone */
.phone-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 24px; align-items: start; }
.dialer { padding: 24px; }
.field-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.select { width: 100%; margin: 6px 0 18px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; }
.search { position: relative; }
.number-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: center; font: 500 28px var(--sans); letter-spacing: .02em; padding: 10px 0 14px; outline: none; }
.number-input::placeholder { color: var(--ink-3); font-size: 20px; letter-spacing: 0; }
.number-input:focus { border-color: var(--accent); }
.suggestions { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.suggestions li { padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.suggestions li:hover { background: var(--surface-2); }
.suggestions small { color: var(--ink-3); }
.contact-chip { margin-top: 12px; text-align: center; font-size: 14px; color: var(--accent); font-weight: 500; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 8px 6px; }
.key { aspect-ratio: 1.5; border: 1px solid var(--line); background: #fff; border-radius: 16px; display: grid; place-content: center; text-align: center; line-height: 1.1; transition: background .1s; }
.key:hover { background: var(--surface-2); }
.key:active { transform: scale(.97); }
.key b { font-size: 22px; font-weight: 500; }
.key small { font-size: 10px; letter-spacing: .14em; color: var(--ink-3); }
.dial-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 18px; }
.btn-call, .btn-hangup { width: 66px; height: 66px; border-radius: 50%; border: 0; display: grid; place-items: center; transition: transform .1s; }
.btn-call { background: var(--green); box-shadow: 0 6px 18px rgba(63, 125, 79, .3); }
.btn-hangup { background: var(--red); box-shadow: 0 6px 18px rgba(180, 71, 58, .3); }
.btn-call:active, .btn-hangup:active { transform: scale(.95); }
.btn-call svg, .btn-hangup svg { width: 28px; height: 28px; fill: #fff; }
.btn-call:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost-round { justify-self: center; background: none; border: 0; font-size: 22px; color: var(--ink-3); width: 48px; height: 48px; border-radius: 50%; }
.btn-ghost-round:hover { background: var(--surface-2); color: var(--ink); }

.dial-live { display: grid; justify-items: center; text-align: center; padding: 18px 0 4px; }
.avatar { width: 84px; height: 84px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 600 30px var(--serif); margin-bottom: 14px; }
.live-name { font: 500 24px var(--serif); }
.live-number { color: var(--ink-2); }
.live-status { margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.live-timer { font: 500 34px var(--sans); font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.rec-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--red); background: var(--red-soft); padding: 4px 12px; border-radius: 999px; }
.rec-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.keypad-small { width: 100%; max-width: 260px; gap: 8px; margin: 18px auto 0; }
.keypad-small .key { aspect-ratio: 1.8; }
.live-actions { display: flex; align-items: center; gap: 20px; margin-top: 26px; }
.btn-round { width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--line); background: #fff; display: grid; place-content: center; line-height: 1.1; }
.btn-round span { font-size: 18px; }
.btn-round small { font-size: 10px; color: var(--ink-2); }
.btn-round.on { background: var(--ink); color: #fbf8f2; border-color: var(--ink); }
.btn-round.on small { color: #d8cfbf; }

/* Listes d'appels */
.call-list { list-style: none; margin: 0; padding: 6px 10px 12px; }
.call-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 12px; cursor: pointer; }
.call-row:hover { background: var(--surface-2); }
.call-row.selected { background: var(--accent-soft); }
.call-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; background: var(--surface-2); color: var(--ink-2); }
.call-icon.in { background: var(--green-soft); color: var(--green); }
.call-icon.missed { background: var(--red-soft); color: var(--red); }
.call-main { min-width: 0; }
.call-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-sub { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-meta { text-align: right; font-size: 13px; color: var(--ink-2); }
.call-meta .tag { display: inline-block; margin-top: 2px; }
.list-empty { padding: 28px 12px; text-align: center; color: var(--ink-3); }

.tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: #7b5e1e; }

/* Historique */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab { border: 0; background: none; padding: 7px 16px; border-radius: 999px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.history-grid { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 24px; align-items: start; }
.list-card { max-height: calc(100vh - 190px); overflow: auto; }
.filter-input { width: calc(100% - 28px); margin: 14px 14px 4px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px; outline: none; }
.filter-input:focus { border-color: var(--accent); }
.detail { padding: 28px; min-height: 360px; position: sticky; top: 24px; }
.empty { color: var(--ink-3); text-align: center; padding: 80px 20px; }
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font: 500 26px var(--serif); }
.detail-facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0 22px; font-size: 14px; color: var(--ink-2); }
.detail audio { width: 100%; margin-bottom: 22px; }
.block { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.block h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.summary { background: var(--accent-soft); border-radius: 12px; padding: 14px 18px; white-space: pre-wrap; }
.transcript { white-space: pre-wrap; color: var(--ink-2); font-size: 14px; max-height: 360px; overflow: auto; }
.pending { color: var(--ink-3); font-style: italic; }

/* Appel entrant */
.incoming { position: fixed; z-index: 20; top: 20px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 32px)); background: var(--ink); color: #fbf8f2; border-radius: 20px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 18px 40px rgba(30, 22, 12, .35); animation: drop .25s ease-out; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -12px); } }
.incoming-pulse { width: 12px; height: 12px; border-radius: 50%; background: #6fcf86; box-shadow: 0 0 0 0 rgba(111, 207, 134, .6); animation: pulse 1.3s infinite; flex: none; }
@keyframes pulse { to { box-shadow: 0 0 0 14px rgba(111, 207, 134, 0); } }
.incoming-body { display: grid; flex: 1; min-width: 0; }
.incoming-body small { color: #c9bfae; font-size: 12px; }
.incoming-body strong { font-size: 17px; }
.incoming-body .muted { color: #c9bfae; font-size: 12px; }
.incoming-actions { display: flex; gap: 8px; }
.incoming .btn-danger { background: transparent; border-color: #5a5045; color: #f0c4bd; }

.toast { position: fixed; z-index: 30; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fbf8f2; padding: 11px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Mobile */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar-foot .me, .sidebar-foot .link { display: none; }
  .nav { display: flex; flex: 1; }
  .nav-item { flex: 1; justify-content: center; flex-direction: column; gap: 2px; font-size: 12px; padding: 8px; }
  .sidebar-foot { margin: 0; }
  .presence span:last-child { display: none; }
  .main { padding: 20px 16px 100px; }
  .toast { bottom: 84px; }
  .page-head h1 { font-size: 28px; }
  .phone-grid, .history-grid { grid-template-columns: 1fr; }
  .detail { position: static; padding: 22px 18px; }
  .list-card { max-height: none; }
}
