/* PhoneAI — Adega Gaucha. Claro é o padrão (como o modelo); escuro via html[data-theme="dark"]. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --surface-3: #efede8;
  --border: #e5e2dc;
  --border-soft: #eeece7;
  --text: #191714;
  --text-muted: #6b675f;
  --text-dim: #9c978d;

  --accent: #e8730c;
  --accent-hi: #cf6409;
  --accent-bg: #fff3e8;
  --accent-soft: #fde2c8;

  --green: #1f9254;   --green-bg: #e9f7ef;
  --red: #d33a2c;     --red-bg: #fdecea;
  --blue: #2f64c8;    --blue-bg: #eaf0fb;
  --yellow: #a07a00;  --yellow-bg: #fbf4dc;

  --sidebar: #0b0b0d;
  --sidebar-text: #c9c6c0;
  --sidebar-dim: #7a7770;

  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(20,18,15,.05), 0 1px 3px rgba(20,18,15,.04);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e0e11;
  --surface: #16161a;
  --surface-2: #1b1b20;
  --surface-3: #232329;
  --border: #2a2a32;
  --border-soft: #202027;
  --text: #ecebe7;
  --text-muted: #9a978f;
  --text-dim: #66635c;
  --accent: #f08a2e;
  --accent-hi: #ff9b45;
  --accent-bg: rgba(240,138,46,.12);
  --accent-soft: rgba(240,138,46,.24);
  --green: #3fbf77;  --green-bg: rgba(63,191,119,.12);
  --red: #ef6355;    --red-bg: rgba(239,99,85,.12);
  --blue: #6b97ea;   --blue-bg: rgba(107,151,234,.12);
  --yellow: #d8b33c; --yellow-bg: rgba(216,179,60,.12);
  --shadow: none;
  color-scheme: dark;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--sidebar); color: var(--sidebar-text);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 100;
  transition: transform .2s ease;
}
.main { margin-left: 232px; flex: 1; min-width: 0; padding: 28px 32px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 26px 22px 22px; text-decoration: none; }
.brand img { height: 46px; width: auto; display: block; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--sidebar-dim); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--r);
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: 14.5px;
  border-left: 3px solid transparent; transition: background .15s, color .15s;
}
.nav a:hover { background: #18181c; color: #fff; }
.nav a.active { background: #1c1612; color: var(--accent); border-left-color: var(--accent); }
.nav svg { width: 19px; height: 19px; flex-shrink: 0; }

.side-foot { padding: 16px 20px 20px; border-top: 1px solid #1d1d22; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.status-line { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2fbf63; box-shadow: 0 0 0 3px rgba(47,191,99,.18); }
.dot.off { background: #e0483a; box-shadow: 0 0 0 3px rgba(224,72,58,.2); }
.side-user { color: var(--sidebar-dim); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-links { display: flex; gap: 14px; align-items: center; }
.side-links a, .side-links button { color: var(--sidebar-dim); background: none; border: none; cursor: pointer; text-decoration: none; font-size: 12.5px; padding: 0; }
.side-links a:hover, .side-links button:hover { color: var(--accent); }
.side-links a, .side-links button { display: inline-flex; align-items: center; gap: 6px; }
.side-links svg { width: 15px; height: 15px; flex-shrink: 0; }
.version { color: #4c4a45; font-size: 11.5px; }

.topbar { display: none; }
.backdrop { display: none; }

/* ── Page header ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.page-head p { color: var(--text-muted); margin-top: 6px; font-size: 14.5px; }
.page-date { color: var(--text-muted); font-size: 13px; padding-top: 6px; white-space: nowrap; }

/* ── KPI cards ── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow);
}
.kpi.hot { background: var(--accent-bg); border-color: var(--accent-soft); }
.kpi-icon { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon svg { width: 25px; height: 25px; }
.kpi-icon.orange { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.grey { background: var(--surface-3); color: var(--text-muted); }
.kpi-icon.red { background: var(--red-bg); color: var(--red); }
.kpi-num { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.kpi-num.orange { color: var(--accent); }
.kpi-num.red { color: var(--red); }
.kpi-label { color: var(--text-muted); margin-top: 6px; font-size: 14px; }
.kpi-help { cursor: help; border-bottom: 1px dotted var(--text-dim); }

/* ── Filters ── */
.filters { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 14px; margin-bottom: 16px; align-items: end; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.select, .input {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color .15s;
}
.select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%237a766e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
.select:focus, .input:focus { border-color: var(--accent); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-dim); }
.search .input { padding-left: 40px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 13px; }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Calls: table + side panel ── */
.calls-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table.calls { width: 100%; border-collapse: collapse; }
table.calls th { text-align: left; font-size: 13px; font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.calls td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; font-size: 14px; }
table.calls tr.row { cursor: pointer; transition: background .12s; }
table.calls tr.row:hover { background: var(--surface-2); }
table.calls tr.row.sel { background: var(--accent-bg); }
table.calls tr:last-child td { border-bottom: none; }
.c-time { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.c-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.c-name { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.c-dur { font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-sum { min-width: 240px; width: 45%; line-height: 1.35; }
table.calls td.c-contact { white-space: nowrap; }
@media (max-width: 1600px) {
  table.calls th, table.calls td { padding-left: 10px; padding-right: 10px; }
  table.calls th:last-child, table.calls td.c-go { display: none; }
}
.c-sum .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-go { color: var(--text-dim); width: 28px; }
.muted { color: var(--text-dim); }
.italic { font-style: italic; }

.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }
.status svg { width: 16px; height: 16px; }
.status.in_progress { color: var(--accent); }
.status.completed { color: var(--green); }
.status.missed { color: var(--red); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.empty { padding: 48px 20px; text-align: center; color: var(--text-muted); }
.banner { padding: 11px 16px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.banner.bad { background: var(--red-bg); color: var(--red); border-color: transparent; }
.banner.warn { background: var(--yellow-bg); color: var(--yellow); border-color: transparent; }

.panel { position: sticky; top: 20px; padding: 22px 22px 24px; max-height: calc(100vh - 40px); overflow-y: auto; }
.panel-top { display: flex; align-items: center; gap: 12px; }
.panel-ico { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.panel-ico svg { width: 22px; height: 22px; }
.panel-ico.completed { background: var(--green-bg); color: var(--green); }
.panel-ico.missed { background: var(--red-bg); color: var(--red); }
.tag { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tag.in_progress { background: var(--accent-bg); color: var(--accent); }
.tag.completed { background: var(--green-bg); color: var(--green); }
.tag.missed { background: var(--red-bg); color: var(--red); }
.panel-timer { margin-left: auto; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.panel-close { margin-left: 8px; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 22px; line-height: 1; }
.panel h2 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 18px; line-height: 1.2; word-break: break-word; }
.panel .p-num { font-size: 21px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.panel .p-loc { color: var(--text-muted); margin-top: 8px; }
.tabs { display: flex; gap: 4px; margin: 22px -4px 16px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: none; padding: 10px 14px; color: var(--text-muted); cursor: pointer; font-weight: 500; font-size: 14.5px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.facts { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--r); padding: 6px 18px; }
.fact { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.fact:last-child { border-bottom: none; }
.fact svg { width: 19px; height: 19px; color: var(--text-muted); flex-shrink: 0; margin-top: 1px; }
.fact-k { font-size: 13.5px; color: var(--text-muted); }
.fact-v { font-size: 14.5px; margin-top: 2px; word-break: break-word; }
.chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--accent-bg); color: var(--accent); margin: 2px 4px 2px 0; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.grey { background: var(--surface-3); color: var(--text-muted); }

.audio { width: 100%; margin: 4px 0 12px; }
.talk { display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.45; max-width: 92%; }
.bubble b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; color: var(--text-muted); }
.bubble.agente { background: var(--surface-3); align-self: flex-start; }
.bubble.cliente { background: var(--accent-bg); align-self: flex-end; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; font-size: 13.5px; }
.link:hover { text-decoration: underline; }
.panel-empty { color: var(--text-muted); text-align: center; padding: 40px 10px; }
.panel-empty svg { width: 40px; height: 40px; color: var(--text-dim); margin-bottom: 10px; }

/* ── Notes (aba de observações) ── */
.c-note { display: inline-flex; vertical-align: -2px; margin-left: 8px; color: var(--accent); }
.c-note svg { width: 16px; height: 16px; }
.note-box { border: 1px solid var(--border); border-radius: var(--r); padding: 16px; background: var(--surface); }
.note-box h3 { font-size: 15px; margin-bottom: 12px; }
.note-hint { color: var(--text-muted); font-size: 13.5px; margin: 6px 0 0; }
.note-type { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.note-type label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.note-select { width: auto; min-width: 190px; height: 36px; font-size: 13.5px; font-weight: 600; }
.note-select.cat-ai_answer_issue { background-color: var(--red-bg); color: var(--red); border-color: transparent; }
.note-select.cat-response_adjustment { background-color: var(--blue-bg); color: var(--blue); border-color: transparent; }
.note-select.cat-internal_note { background-color: var(--surface-3); color: var(--text-muted); border-color: transparent; }
.note-text-wrap { position: relative; }
.note-text { width: 100%; min-height: 104px; padding: 11px 13px 26px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit; resize: vertical; outline: none; display: block; }
.note-text:focus { border-color: var(--accent); }
.note-count { position: absolute; right: 10px; bottom: 7px; font-size: 11.5px; color: var(--text-dim); pointer-events: none; }
.note-save { width: 100%; margin-top: 12px; }
.note-private { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-dim); font-size: 12.5px; margin-top: 10px; }
.note-private svg { width: 14px; height: 14px; }
.note-prev { font-size: 14px; margin: 20px 0 10px; }
.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-item { border: 1px solid var(--border-soft); border-left: 3px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.note-item.cat-ai_answer_issue { border-left-color: var(--red); }
.note-item.cat-response_adjustment { border-left-color: var(--blue); }
.note-meta { display: flex; align-items: center; gap: 8px; }
.note-meta .chip { margin: 0; font-size: 12px; }
.note-date { margin-left: auto; color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.note-body { margin-top: 8px; white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5; }
.note-by { display: flex; align-items: center; margin-top: 8px; color: var(--text-dim); font-size: 12.5px; }
.note-del { margin-left: auto; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12.5px; }
.note-del:hover { color: var(--red); }
.tabs { overflow-x: auto; scrollbar-width: none; gap: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { white-space: nowrap; padding-left: 11px; padding-right: 11px; }

/* ── Recordings ── */
.rec-list { display: flex; flex-direction: column; }
.rec { display: grid; grid-template-columns: 110px 130px 1fr 320px; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); align-items: center; }
.rec:last-child { border-bottom: none; }
.rec audio { width: 100%; height: 36px; }
.rec-actions { display: flex; align-items: center; gap: 10px; }

/* ── Reports ── */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px 20px; }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.box { padding: 18px 20px; }
.box h3 { font-size: 15px; margin-bottom: 14px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13.5px; }
.bar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.days { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.day-bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.day-lbl { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.day-n { font-size: 11.5px; color: var(--text-muted); }
.note { color: var(--text-dim); font-size: 12.5px; margin-top: 14px; }

/* ── Settings ── */
.form { padding: 22px; max-width: 760px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.form-row .field { flex: 1; min-width: 220px; }
.checks { margin-bottom: 18px; }
.checks-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.hint { color: var(--text-dim); font-size: 12.5px; }
.btn { height: 42px; padding: 0 20px; border-radius: var(--r-sm); border: none; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-hi); }
.btn-sm { height: 30px; padding: 0 11px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; font-size: 12.5px; margin-right: 6px; }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.danger:hover { border-color: var(--red); color: var(--red); }
table.users { width: 100%; border-collapse: collapse; }
table.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--border); }
table.users td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
h2.section { font-size: 17px; margin: 30px 0 12px; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; gap: 22px; align-items: center; justify-content: center; padding: 20px; background: var(--sidebar); }
.login-logo { height: 62px; display: block; }
.login { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--r-lg); padding: 30px 28px; }
.login h1 { text-align: center; font-size: 19px; margin: 0 0 22px; }
.login .field { margin-bottom: 14px; }
.login .btn { width: 100%; margin-top: 6px; }

/* ── Responsivo ── */
/* Faixas: celular ≤767 · tablet 768–1279 (menu só com ícones) · desktop ≥1280 */
/* Sem ligação selecionada o painel some e a tabela usa a largura toda */
.calls-layout.no-sel { grid-template-columns: 1fr; }
.calls-layout.no-sel .panel { display: none; }
@media (max-width: 1600px) {
  .calls-layout { grid-template-columns: 1fr; }
  .panel { display: none; }
  .panel.open {
    display: block; position: fixed; inset: 0 0 0 auto; width: min(460px, 100%); max-height: none; height: 100vh;
    z-index: 300; border-radius: 0; top: 0; box-shadow: -10px 0 40px rgba(0,0,0,.25);
  }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet em pé e celular: a tabela de ligações vira lista de cartões */
@media (max-width: 1099px) {
  table.calls thead { display: none; }
  table.calls, table.calls tbody, table.calls tr, table.calls td { display: block; width: 100%; }
  table.calls tr.row { display: grid; grid-template-columns: 104px 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
  table.calls td { padding: 0; border: none; }
  table.calls td.c-time { grid-column: 1; grid-row: 1; }
  table.calls td.c-contact { grid-column: 2; grid-row: 1 / span 2; white-space: normal; min-width: 0; }
  table.calls td.c-status { grid-column: 3; grid-row: 1; text-align: right; }
  table.calls td.c-loc { grid-column: 1; grid-row: 2; color: var(--text-muted); font-size: 12.5px; }
  table.calls td.c-dur { grid-column: 3; grid-row: 2; text-align: right; color: var(--text-muted); font-size: 13px; }
  table.calls td.c-sum { grid-column: 1 / -1; grid-row: 3; min-width: 0; width: auto; max-width: none; color: var(--text-muted); font-size: 13px; margin-top: 4px; }
  table.calls td.c-go { display: none; }
}

/* Tablet: menu lateral só com ícones (o nome aparece no tooltip) */
@media (min-width: 768px) and (max-width: 1279px) {
  .sidebar { width: 76px; }
  .main { margin-left: 76px; padding: 22px 22px 28px; }
  .brand { padding: 18px 8px 14px; justify-content: center; }
  .brand img { height: 30px; margin: 0 auto; }
  .brand-sub, .nav-label, .side-user, .version { display: none; }
  .nav { padding: 10px; gap: 6px; }
  .nav a { justify-content: center; padding: 12px 0; border-left: none; }
  .nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
  .nav svg { width: 21px; height: 21px; }
  .side-foot { padding: 16px 0 20px; align-items: center; gap: 16px; }
  .side-links { flex-direction: column; gap: 16px; }
  .side-links svg { width: 20px; height: 20px; }
  .page-head h1 { font-size: 26px; }
  .kpis { gap: 12px; margin-bottom: 18px; }
  .kpi { padding: 14px; gap: 12px; }
  .kpi-icon { width: 42px; height: 42px; }
  .kpi-icon svg { width: 20px; height: 20px; }
  .kpi-num { font-size: 24px; }
  .kpi-label { font-size: 12.5px; }
  .select, .input { font-size: 16px; }  /* evita zoom do iOS */
}

/* Tablet em pé: lista + detalhe lado a lado, como no modelo */
@media (min-width: 768px) and (max-width: 1099px) {
  .calls-layout:not(.no-sel) { grid-template-columns: minmax(0, 1fr) min(400px, 56%); gap: 16px; }
  .panel.open {
    position: sticky; inset: auto; top: 16px; width: auto; height: auto; max-height: calc(100vh - 32px);
    border-radius: var(--r-lg); box-shadow: var(--shadow); z-index: auto;
  }
  /* com o detalhe aberto a lista fica estreita: cartão empilhado
     (horário + status / número / nome / unidade + duração) e sem resumo,
     que já aparece no painel */
  .calls-layout:not(.no-sel) table.calls td.c-sum { display: none; }
  .calls-layout:not(.no-sel) table.calls tr.row { grid-template-columns: 1fr auto; gap: 3px 10px; }
  .calls-layout:not(.no-sel) table.calls td.c-time { grid-column: 1; grid-row: 1; }
  .calls-layout:not(.no-sel) table.calls td.c-status { grid-column: 2; grid-row: 1; }
  .calls-layout:not(.no-sel) table.calls td.c-contact { grid-column: 1 / -1; grid-row: 2; }
  .calls-layout:not(.no-sel) table.calls td.c-loc { grid-column: 1; grid-row: 3; }
  .calls-layout:not(.no-sel) table.calls td.c-dur { grid-column: 2; grid-row: 3; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); z-index: 200; }
  html.nav-open .sidebar { transform: none; }
  html.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; }
  .main { margin-left: 0; padding: 16px 14px 28px; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 120;
    height: 56px; padding: 0 12px; background: var(--sidebar);
  }
  .topbar button { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid #26262c; background: #141417; color: #ddd; display: flex; align-items: center; justify-content: center; cursor: pointer; }
  .topbar button svg { width: 20px; height: 20px; }
  .topbar img { height: 32px; }
  .topbar .grow { flex: 1; }
  .page-head h1 { font-size: 24px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; gap: 12px; }
  .kpi-icon { width: 38px; height: 38px; }
  .kpi-icon svg { width: 18px; height: 18px; }
  .kpi-num { font-size: 22px; }
  .kpi-label { font-size: 12.5px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .filters .search label { display: none; }
  .select, .input { font-size: 16px; }  /* evita zoom do iOS */
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .rec { grid-template-columns: 1fr; gap: 8px; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  table.users { display: block; overflow-x: auto; white-space: nowrap; }
  /* celular: cartão empilhado, igual à lista estreita do tablet */
  table.calls tr.row { grid-template-columns: 1fr auto; gap: 3px 10px; }
  table.calls td.c-time { grid-column: 1; grid-row: 1; }
  table.calls td.c-status { grid-column: 2; grid-row: 1; }
  table.calls td.c-contact { grid-column: 1 / -1; grid-row: 2; }
  table.calls td.c-loc { grid-column: 1; grid-row: 3; }
  table.calls td.c-dur { grid-column: 2; grid-row: 3; }
  table.calls td.c-sum { grid-row: 4; }
}

/* ── Call Routing (tela única, sem menu lateral) ── */
.rt-head { background: var(--sidebar); position: sticky; top: 0; z-index: 50; }
.rt-head-in { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.rt-head img { height: 38px; }
.rt-title { color: #fff; font-weight: 600; font-size: 16px; padding-left: 14px; border-left: 1px solid #2a2a30; }
.rt-head .grow { flex: 1; }
.rt-back { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; }
.rt-back:hover { background: var(--accent-hi); }
.rt-back svg { width: 17px; height: 17px; }
.rt-icon { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid #26262c; background: #141417; color: #ccc;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.rt-icon:hover { color: var(--accent); }
.rt-icon svg { width: 18px; height: 18px; }
.rt-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 40px; }
.rt-main .page-head p { max-width: 720px; }
.rt-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.rt-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.rt-card.on { border-color: var(--accent-soft); }
.rt-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.rt-card h3 { font-size: 19px; }
.rt-num { color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 3px; }
.rt-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rt-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.rt-opt b { font-size: 14px; }
.rt-opt small { color: var(--text-muted); font-size: 12px; }
.rt-opt:hover:not(:disabled) { border-color: var(--accent); }
.rt-opt.cur { border: 2px solid var(--accent); background: var(--accent-bg); cursor: default; }
.rt-opt.cur::after { content: 'Current'; font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.rt-opt:disabled:not(.cur) { opacity: .5; cursor: wait; }
.rt-opt.wait::after { content: 'Switching…'; font-size: 11px; color: var(--accent); margin-top: 4px; }
.rt-card .banner { margin: 0; font-size: 13px; }
@media (max-width: 900px) { .rt-cards { grid-template-columns: 1fr; } }
.rt-back-short { display: none; }
@media (max-width: 560px) {
  .rt-title, .rt-back-long { display: none; }
  .rt-back-short { display: inline; }
  .rt-head-in { padding: 10px 14px; gap: 10px; }
  .rt-head img { height: 34px; }
  .rt-main { padding: 18px 14px 32px; }
  .rt-main .page-head h1 { font-size: 23px; }
  .rt-main .page-head p { font-size: 14px; }
  .rt-card { padding: 16px; }
  /* Histórico: cada troca vira um cartão (local + resultado / pedido + quando / quem) */
  #switches thead { display: none; }
  #switches, #switches tbody, #switches tr, #switches td { display: block; }
  #switches tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
  #switches tr:last-child { border-bottom: none; }
  #switches td { padding: 0; border: none; }
  #switches td.sw-loc { grid-column: 1; grid-row: 1; font-weight: 600; }
  #switches td.sw-res { grid-column: 2; grid-row: 1; text-align: right; }
  #switches td.sw-req { grid-column: 1; grid-row: 2; }
  #switches td.sw-when { grid-column: 2; grid-row: 2; text-align: right; color: var(--text-muted); font-size: 13px; }
  #switches td.sw-by { grid-column: 1 / -1; grid-row: 3; color: var(--text-muted); font-size: 13px; }
  #switches .chip { margin: 0; white-space: normal; }
}
