/* ONCALL S3: History (mockups 3 + 4) and Leads with pagination. */
/* Only the active page shows: .page{display:none} must win over the flex layout. */
.page.hl-page.active{display:flex;flex-direction:column;gap:12px;min-width:0}
.hl-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.hl-topbar h2{margin:0}
.hl-topbar p{margin:2px 0 0;color:#64748b;font-size:13px}
.hl-searchbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.hl-filter-toggle{width:40px;min-height:40px;border:1px solid #c7d2fe;border-radius:10px 0 0 10px;background:#eef2ff;color:#4338ca;font-weight:700}
.hl-filter-toggle[aria-expanded="true"]{background:#4338ca;color:#fff}
.hl-search{flex:1 1 260px;min-width:0;margin:0}
.hl-search input{width:100%;min-height:40px;border:1px solid #cbd5e1;border-radius:0 10px 10px 0;padding:0 12px}
#history-clear{min-height:40px;padding:6px 12px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;font:inherit;font-weight:600;color:#1e293b;cursor:pointer}
.hl-chips{display:flex;flex-wrap:wrap;gap:6px;min-width:0}
.hl-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 4px 2px 10px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:12px;font-weight:600}
.hl-chip button{border:0;background:transparent;color:inherit;min-width:24px;min-height:24px;border-radius:999px;cursor:pointer}
.hl-chip button:hover{background:#c7d2fe}
.hl-match{margin:0 0 0 auto;color:#475569;font-size:13px;white-space:nowrap}
.hl-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;align-items:start;min-width:0}
#conversations.filters-open .hl-layout{grid-template-columns:300px minmax(0,1fr)}
#conversations.show-transcript .hl-layout{grid-template-columns:minmax(300px,.9fr) minmax(0,1.3fr)}
#conversations.show-transcript.filters-open .hl-layout{grid-template-columns:300px minmax(280px,.8fr) minmax(0,1.2fr)}
#conversations:not(.show-transcript) #conversation-detail{display:none}
.hl-list-col{display:flex;flex-direction:column;min-width:0;border:1px solid #e2e8f0;border-radius:14px;background:#fff;overflow:hidden}
.hl-table{display:flex;flex-direction:column;min-width:0}
.hl-row{display:grid;grid-template-columns:minmax(120px,1.1fr) minmax(100px,1fr) minmax(90px,.8fr) 80px minmax(200px,2.6fr);gap:12px;align-items:center;width:100%;min-height:52px;padding:8px 14px;border:0;border-bottom:1px solid #f1f5f9;background:#fff;text-align:left;font:inherit;color:#0f172a;cursor:pointer}
.hl-table.compact .hl-row{grid-template-columns:minmax(110px,1.2fr) minmax(90px,1fr) minmax(80px,.8fr) 70px}
.hl-row.lead{grid-template-columns:minmax(120px,1fr) minmax(150px,1.3fr) minmax(160px,2fr) minmax(110px,1fr) 100px}
.hl-row.hl-head{min-height:36px;background:#f8fafc;color:#64748b;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;cursor:default}
.hl-row:not(.hl-head):hover{background:#f8fafc}
.hl-row[aria-current="true"]{background:#eef2ff;box-shadow:inset 3px 0 0 #4338ca}
.hl-row:focus-visible{outline:3px solid #6366f1;outline-offset:-3px}
.hl-row>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hl-name{font-weight:400;color:#475569}
.hl-row.named .hl-name{font-weight:700;color:#0f172a}
.hl-offline,.hl-live{margin-left:6px;padding:1px 6px;border-radius:6px;background:#f1f5f9;color:#475569;font-size:11px;font-weight:600}
.hl-live{background:#dcfce7;color:#166534}
.hl-msgs{display:flex;align-items:center;gap:8px}
.hl-count{flex:none;min-width:26px;padding:2px 6px;border-radius:6px;background:#f1f5f9;text-align:center;font-size:12px;font-weight:700}
.hl-preview{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#334155}
.hl-preview mark,.hl-msgs mark{background:#fef08a;color:inherit;border-radius:3px;padding:0 1px}
.hl-rating.good{color:#15803d;font-weight:700}
.hl-rating.bad{color:#b91c1c;font-weight:700}
.hl-rating.none{color:#94a3b8}
.hl-empty{padding:32px 16px}
.hl-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:10px 14px;border-top:1px solid #e2e8f0;color:#475569;font-size:13px}
.hl-pager{display:inline-flex;align-items:center;gap:4px;padding:2px;border:1px solid #e2e8f0;border-radius:999px;background:#fff;font-size:13px;font-weight:700}
.hl-pager button{min-width:36px;min-height:36px;border:0;border-radius:999px;background:transparent;font-size:18px;cursor:pointer}
.hl-pager button:hover:not(:disabled){background:#eef2ff}
.hl-pager button:disabled{opacity:.35;cursor:default}
.hl-pager button:focus-visible,.hl-filter-toggle:focus-visible,.hl-tabs button:focus-visible{outline:3px solid #6366f1;outline-offset:2px}
/* The panel is an <aside>: undo the sidebar's global aside rules (sticky, 100vh, dark, flex) so [hidden] really hides it. */
.hl-filter-panel{position:static;height:auto;padding:0;display:block;color:inherit;border:1px solid #e2e8f0;border-radius:14px;background:#fff;min-width:0}
.hl-filter-panel[hidden],.hl-lead-detail[hidden]{display:none}
.hl-filter-form{display:flex;flex-direction:column;max-height:calc(100dvh - 210px)}
.hl-filter-form header,.hl-filter-form footer{display:flex;align-items:center;gap:8px;padding:12px 14px}
.hl-filter-form header{justify-content:space-between;border-bottom:1px solid #f1f5f9}
.hl-filter-form header h3{margin:0;font-size:15px}
.hl-active{padding:2px 8px;border-radius:999px;background:#eef2ff;color:#4338ca;font-size:12px;font-weight:700}
.hl-filter-body{overflow:auto;padding:4px 14px 12px;scrollbar-width:thin}
.hl-filter-body h4{margin:14px 0 6px;color:#64748b;font-size:11px;letter-spacing:.08em;text-transform:uppercase}
.hl-field{display:grid;grid-template-columns:86px minmax(0,1fr);gap:8px;align-items:center;margin:6px 0;border:0;padding:0;font-size:13px}
.hl-field>span:first-child,.hl-field legend{color:#334155}
.hl-field legend{float:left;width:86px;padding:0}
.hl-field input:not([type=radio]):not([type=checkbox]),.hl-field select{width:100%;min-height:36px;border:1px solid #cbd5e1;border-radius:8px;padding:0 8px}
.hl-inline{display:flex;align-items:center;gap:6px}
.hl-inline input{max-width:72px}
.hl-dates{display:grid;gap:6px}
.hl-help{display:block;margin:-2px 0 4px 94px;color:#64748b;font-size:12px}
.hl-muted{color:#64748b;font-size:13px}
.hl-seg,.hl-toggles{display:flex;flex-wrap:wrap;gap:4px}
.hl-seg label,.hl-toggles label{position:relative}
.hl-seg input,.hl-toggles input{position:absolute;opacity:0;inset:0;margin:0;cursor:pointer}
.hl-seg span,.hl-toggles span{display:inline-flex;align-items:center;min-height:32px;padding:0 10px;border:1px solid #e2e8f0;border-radius:8px;font-weight:600;font-size:12px;color:#475569}
.hl-seg input:checked+span,.hl-toggles input:checked+span{border-color:#6366f1;background:#eef2ff;color:#3730a3}
.hl-seg input:focus-visible+span,.hl-toggles input:focus-visible+span{outline:3px solid #6366f1;outline-offset:1px}
.hl-filter-form footer{border-top:1px solid #f1f5f9}
.hl-filter-form footer .text-button{margin-left:auto}
#conversation-detail.history-transcript{border:1px solid #e2e8f0;border-radius:14px;background:#fff;min-width:0;display:flex;flex-direction:column;max-height:calc(100dvh - 180px);overflow:auto}
.hl-open-head{display:flex;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid #e2e8f0;position:sticky;top:0;background:#fff;z-index:1}
.hl-avatar{display:grid;place-items:center;flex:none;width:42px;height:42px;border-radius:999px;background:#e0f2fe;color:#0369a1;font-weight:800}
.hl-open-title{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.hl-open-title h3{margin:0;font-size:17px}
.hl-open-title small{flex-basis:100%;color:#64748b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hl-badge{padding:1px 8px;border-radius:6px;background:#f1f5f9;color:#475569;font-size:12px;font-weight:700}
.hl-badge.accent{background:#ede9fe;color:#5b21b6}
.hl-open-actions{display:flex;gap:6px;flex:none}
.hl-open-actions button{min-width:40px;min-height:40px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;font-weight:700;cursor:pointer}
.hl-open-actions button:disabled{opacity:.4;cursor:default}
/* Mockup 4 has one header: the open view's own head replaces the reused transcript head (its Back is the × above). */
#history-panel-transcript .history-transcript-head{display:none}
.hl-filter-form footer button:not(.primary):not(.text-button){min-height:36px;padding:6px 12px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;font:inherit;font-weight:600;color:#1e293b;cursor:pointer}
.hl-tabs{display:flex;gap:4px;padding:0 14px;border-bottom:1px solid #e2e8f0}
.hl-tabs button{min-height:44px;padding:0 10px;border:0;border-bottom:3px solid transparent;background:transparent;color:#475569;font-weight:700;font-size:13px;letter-spacing:.04em;text-transform:uppercase;cursor:pointer}
.hl-tabs button[aria-selected="true"]{color:#4338ca;border-bottom-color:#4338ca}
.hl-tab-count{padding:0 6px;border-radius:999px;background:#f1f5f9;font-size:11px}
.hl-panel{padding:12px 14px}
.hl-panel[hidden]{display:none}
.hl-summary{display:grid;grid-template-columns:110px minmax(0,1.4fr) minmax(0,1.3fr);gap:12px;padding:10px 12px;border:1px solid #e2e8f0;border-radius:12px}
.hl-summary small,.hl-stats dt{display:block;color:#64748b;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.hl-tags{display:flex;flex-wrap:wrap;gap:4px}
.hl-tag{padding:1px 8px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:12px;font-weight:700}
.hl-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;margin:10px 0;border:1px solid #e2e8f0;border-radius:12px}
.hl-stats div{padding:8px 12px;border-left:1px solid #e2e8f0}
.hl-stats div:first-child{border-left:0}
.hl-stats dd{margin:2px 0 0;font-weight:700;font-size:13px}
.hl-stats dd[data-outcome="completed"]{color:#15803d}
.hl-stats dd[data-outcome="missed"],.hl-stats dd[data-outcome="dropped"]{color:#b45309}
.hl-foot-note{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;padding:10px 14px;border-top:1px solid #e2e8f0;color:#64748b;font-size:12px}
.leads-layout{grid-template-columns:minmax(0,1fr)}
#leads.show-lead .leads-layout{grid-template-columns:minmax(0,1.4fr) minmax(300px,1fr)}
.hl-lead-detail{border:1px solid #e2e8f0;border-radius:14px;background:#fff;min-width:0}
.hl-detail{display:grid;gap:0;margin:0;padding:6px 14px}
.hl-detail div{display:grid;grid-template-columns:130px minmax(0,1fr);gap:8px;padding:8px 0;border-bottom:1px solid #f1f5f9}
.hl-detail dt{color:#64748b;font-size:13px}
.hl-detail dd{margin:0;overflow-wrap:anywhere}
.hl-pre{white-space:pre-wrap}
.hl-detail-actions{padding:12px 14px}
.hl-contact,.hl-source{color:#334155}
@media (max-width:1100px){
  #conversations.filters-open .hl-layout,#conversations.show-transcript.filters-open .hl-layout{grid-template-columns:minmax(0,1fr)}
  .hl-filter-panel{position:relative}
  .hl-row{grid-template-columns:minmax(110px,1fr) minmax(90px,.8fr) 90px 60px minmax(140px,1.6fr)}
}
@media (max-width:900px){
  #conversations.show-transcript .hl-layout{grid-template-columns:minmax(0,1fr)}
  #conversations.show-transcript .hl-list-col,#conversations.show-transcript .hl-searchbar,#conversations.show-transcript .hl-filter-panel{display:none}
  #conversation-detail.history-transcript{max-height:none}
  /* Phones: title on its own row, actions below it, so the name and email never squeeze. */
  .hl-open-head{flex-wrap:wrap}
  .hl-open-title{flex:1 1 calc(100% - 64px)}
  .hl-open-actions{flex:1 1 100%;justify-content:flex-end}
  #leads.show-lead .leads-layout{grid-template-columns:minmax(0,1fr)}
  #leads.show-lead .hl-list-col{display:none}
  .hl-row,.hl-table.compact .hl-row,.hl-row.lead{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"name time" "msgs msgs";row-gap:2px;min-height:60px}
  .hl-row.hl-head{display:none}
  .hl-name{grid-area:name}.hl-time{grid-area:time;font-size:12px;color:#64748b}
  .hl-msgs,.hl-row.lead .hl-preview{grid-area:msgs}
  .hl-agents,.hl-rate,.hl-contact,.hl-source{display:none}
  .hl-summary{grid-template-columns:minmax(0,1fr)}
  .hl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .hl-stats div:nth-child(3){border-left:0}
  .hl-stats div:nth-child(n+3){border-top:1px solid #e2e8f0}
  .hl-match{margin-left:0}
  .hl-field{grid-template-columns:minmax(0,1fr)}
  .hl-field legend{float:none;width:auto}
  .hl-help{margin-left:0}
  .hl-detail div{grid-template-columns:minmax(0,1fr)}
}
@media (prefers-reduced-motion:reduce){.hl-page *{transition:none!important;animation:none!important;scroll-behavior:auto!important}}
