/* Torre de Controle Laf — design system do mockup aprovado */
:root {
  --bg: #0B0E17;
  --surface: #111624;
  --surface-2: #151B2E;
  --surface-deep: #0E1220;
  --hair: #1C2338;
  --hair-2: #161C2E;
  --border: #232B42;
  --border-strong: #2A3554;
  --text: #EAEEF8;
  --text-2: #98A2BC;
  --text-3: #C6CEE2;
  --muted: #5E6883;
  --ok: #34D388;
  --wait: #FFB020;
  --late: #FF4D5E;
  --late-soft: #E39BA3;
  --late-strong: #FFD9DC;
  --blue: #3D8BFF;
  --grad: linear-gradient(135deg, #0A6CFF, #A000C8);
  --av-blue-bg: #1C2742; --av-blue-fg: #A9C3F5;
  --av-violet-bg: #241E3D; --av-violet-fg: #CBB8EE;
  --av-off-bg: #171D30;
  --av-strong-bg: #1C2742; --av-strong-fg: #C9D6F5;
  --nav-active-fg: #C9D6F5;
  --late-track: #3A2230;
  --alert-fg: #FFB3BA;
  --font: 'Space Grotesk', 'Avenir Next', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

[data-theme="light"] {
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-deep: #ECEFF6;
  --hair: #E4E8F1;
  --hair-2: #EEF1F7;
  --border: #D7DDEA;
  --border-strong: #C4CCDF;
  --text: #171D2E;
  --text-2: #5A6478;
  --text-3: #3D4660;
  --muted: #8A93A9;
  --ok: #17925C;
  --wait: #B87A00;
  --late: #DC3145;
  --late-soft: #A54350;
  --late-strong: #7E1B28;
  --blue: #1F6BE0;
  --av-blue-bg: #DCE7FB; --av-blue-fg: #2E5AA8;
  --av-violet-bg: #EBDDF6; --av-violet-fg: #7A3FA8;
  --av-off-bg: #E4E8F1;
  --av-strong-bg: #DCE7FB; --av-strong-fg: #24509B;
  --nav-active-fg: #3A4C88;
  --late-track: #F3D2D6;
  --alert-fg: #A32636;
}

* { box-sizing: border-box; }
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); -webkit-font-smoothing: antialiased; font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: #6FA9FF; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea {
  font-family: var(--font); font-size: 13.5px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3D5AA9; }
input.mono, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(52,211,136,.45); } 70% { box-shadow: 0 0 0 6px rgba(52,211,136,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,136,0); } }
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(255,77,94,.4); } 70% { box-shadow: 0 0 0 9px rgba(255,77,94,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,94,0); } }
@keyframes pulseAmber { 0% { box-shadow: 0 0 0 0 rgba(255,176,32,.35); } 70% { box-shadow: 0 0 0 7px rgba(255,176,32,0); } 100% { box-shadow: 0 0 0 0 rgba(255,176,32,0); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.live-dot { animation: pulseDot 2.4s ease-out infinite; border-radius: 50%; }
.late-ring { animation: pulseRed 1.8s ease-out infinite; border-radius: 50%; }
.wait-ring { animation: pulseAmber 2.8s ease-out infinite; border-radius: 50%; }

/* ── Estrutura ── */
.shell { display: flex; height: 100vh; overflow: hidden; }
.rail {
  width: 68px; flex: none; display: flex; flex-direction: column; align-items: center;
  padding: 18px 0 20px; border-right: 1px solid var(--hair); gap: 10px;
}
.rail img.logo { width: 38px; height: 38px; margin-bottom: 18px; }
.rail button.nav {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
}
.rail button.nav svg { stroke: var(--muted); }
.rail button.nav:hover svg { stroke: var(--text-3); }
.rail button.nav.active {
  background: linear-gradient(135deg, rgba(10,108,255,.22), rgba(160,0,200,.22));
  border-color: rgba(90,90,220,.35);
}
.rail button.nav.active svg { stroke: var(--nav-active-fg); }
.rail .spacer { flex: 1; }
.rail .me {
  width: 36px; height: 36px; border-radius: 50%; background: var(--av-blue-bg); color: var(--av-blue-fg);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 68px; flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 28px; border-bottom: 1px solid var(--hair);
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.topbar .sub { font-size: 12px; color: var(--text-2); }
.topbar .grow { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--text-3);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.alert { border-color: rgba(255,77,94,.45); background: rgba(255,77,94,.08); color: var(--alert-fg); font-weight: 500; }
.clock { font-family: var(--mono); font-size: 13px; color: var(--text-2); }

/* ── Régua de números ── */
.pulse-row { display: flex; align-items: stretch; padding: 18px 28px; border-bottom: 1px solid var(--hair); flex: none; }
.pulse-row .fig { display: flex; flex-direction: column; gap: 4px; padding: 0 36px; }
.pulse-row .fig:first-child { padding-left: 0; }
.pulse-row .sep { width: 1px; background: var(--hair); }
.cap { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.cap.strong { color: var(--text-2); font-weight: 600; }
.fig .val { font-family: var(--mono); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.fig .val small { color: var(--muted); font-size: 16px; }

/* ── Corpo ── */
.body { flex: 1; display: flex; gap: 20px; padding: 20px 28px 24px; min-height: 0; overflow: auto; }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

.queue-col { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sec-head { display: flex; align-items: baseline; gap: 12px; }
.sec-head .hint { font-size: 12px; color: var(--muted); }
.sec-head .grow { flex: 1; }

.grad-border {
  border: 1px solid transparent;
  background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box, var(--grad) border-box;
}

.next-card { border-radius: 16px; padding: 20px 22px; display: flex; align-items: center; gap: 18px; }
.next-card .ring { width: 62px; height: 62px; border-radius: 50%; padding: 2px; background: var(--grad); flex: none; }
.next-card .ring .av { width: 100%; height: 100%; border-radius: 50%; background: var(--av-strong-bg); color: var(--av-strong-fg); display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; }
.next-card .name { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.tag-davez { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #fff; padding: 3px 9px; border-radius: 999px; background: var(--grad); }
.meta { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }

.row-card {
  display: flex; align-items: center; gap: 16px; background: var(--surface);
  border: 1px solid var(--hair); border-radius: 12px; padding: 12px 18px;
}
.row-card.overdue { background: rgba(255,77,94,.06); border-color: rgba(255,77,94,.45); }
.row-card .pos { width: 18px; font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: center; flex: none; }
.av-sm { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.av-blue { background: var(--av-blue-bg); color: var(--av-blue-fg); }
.av-violet { background: var(--av-violet-bg); color: var(--av-violet-fg); }
.av-off { background: var(--av-off-bg); color: var(--muted); }
.arc-wrap { position: relative; width: 44px; height: 44px; flex: none; }
.arc-wrap svg { position: absolute; inset: 0; }
.arc-wrap .av { position: absolute; inset: 7px; border-radius: 50%; background: var(--av-strong-bg); color: var(--av-strong-fg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.row-card .who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-card .who .nm { font-size: 14.5px; font-weight: 500; }
.row-card .who .md { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.row-card .grow { flex: 1; }
.state { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.state .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.timer-col { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.timer { font-family: var(--mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.timer.amber { color: var(--wait); }
.timer.red { color: var(--late); font-size: 16px; font-weight: 600; }
.timer-sub { font-size: 11.5px; color: var(--text-2); }
.timer-sub.red { color: var(--late-soft); }

.row-tools { display: flex; gap: 4px; }
.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; color: var(--muted);
  font-size: 12px; line-height: 1;
}
.icon-btn:hover { border-color: var(--border); color: var(--text-3); }

.off-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.off-row {
  flex: 1; display: flex; align-items: center; gap: 12px; background: var(--surface-deep);
  border: 1px dashed var(--hair); border-radius: 12px; padding: 10px 16px; opacity: .68;
}
.off-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.off-grid .off-row { min-width: 300px; }

.toggle { width: 40px; height: 23px; border-radius: 999px; background: var(--border); padding: 2px; display: flex; border: none; flex: none; transition: background .15s; }
.toggle .knob { width: 19px; height: 19px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle.on { background: var(--grad); justify-content: flex-start; }
.toggle.on .knob { background: #fff; transform: translateX(17px); }

/* ── Alerta ── */
.alert-banner {
  display: flex; align-items: center; gap: 16px; border-radius: 14px; padding: 14px 20px;
  background: rgba(255,77,94,.09); border: 1px solid rgba(255,77,94,.4); animation: slideIn .25s ease-out;
}
.alert-banner .txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.alert-banner .t1 { font-size: 14.5px; font-weight: 600; color: var(--late-strong); }
.alert-banner .t2 { font-size: 12.5px; color: var(--late-soft); }
.alert-banner .grow { flex: 1; }

.btn { border: none; border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 600; }
.btn-danger { background: var(--late); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-3); border: 1px solid var(--border-strong); font-weight: 400; }
.btn-grad { background: var(--grad); color: #fff; }
.btn-link { background: none; border: none; color: var(--blue); font-size: 13px; padding: 0; }
.btn-link.danger { color: var(--late); }

/* ── Feed ── */
.feed-col {
  width: 372px; flex: none; background: var(--surface); border: 1px solid var(--hair);
  border-radius: 16px; display: flex; flex-direction: column; min-height: 0;
}
.feed-head { display: flex; align-items: center; gap: 9px; padding: 16px 20px; border-bottom: 1px solid var(--hair); }
.feed-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.feed-item { display: flex; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--hair-2); animation: slideIn .25s ease-out; }
.feed-item:first-child { border-top: none; }
.feed-item.hl { background: rgba(255,77,94,.05); }
.feed-item .tm { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 36px; flex: none; padding-top: 2px; }
.feed-item .dotcol { width: 8px; flex: none; display: flex; justify-content: center; padding-top: 5px; }
.feed-item .dotcol .dot { width: 8px; height: 8px; border-radius: 50%; }
.feed-item .fx { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.feed-item .l1 { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.feed-item .l1.red { color: var(--late-strong); }
.feed-item .l1.gray { color: var(--text-2); }
.feed-item .l2 { font-size: 11.5px; color: var(--text-2); }
.dot-grad { background: var(--grad); }
.dot-ok { background: var(--ok); }
.dot-late { background: var(--late); }
.dot-gray { background: var(--muted); }
.dot-wait { background: var(--wait); }
.dot-blue { background: var(--blue); }

/* ── Cards genéricos (config/cadastro) ── */
.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); }
.hr { height: 1px; background: var(--hair); }
.setting-row { display: flex; align-items: center; gap: 14px; }
.setting-row .txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setting-row .t1 { font-size: 14px; font-weight: 500; }
.setting-row .t2 { font-size: 12px; color: var(--text-2); }
.setting-row .grow { flex: 1; }

/* ── Vendedores ── */
.sellers-layout { display: flex; gap: 20px; flex: 1; min-height: 0; width: 100%; }
.sellers-list { width: 400px; flex: none; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.seller-item {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--hair);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; text-align: left; width: 100%; color: var(--text);
}
.seller-item.selected { border: 1px solid transparent; background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box, var(--grad) border-box; }
.seller-item.off { opacity: .68; }
.seller-item .si-name { font-size: 14px; font-weight: 500; }
.seller-item .si-sub { font-size: 11.5px; color: var(--text-2); }
.seller-editor { flex: 1; min-width: 0; overflow-y: auto; }

.mode-cards { display: flex; gap: 12px; }
.mode-card {
  flex: 1; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-deep); border: 1px solid var(--hair); cursor: pointer; opacity: .6; color: var(--text);
  text-align: left;
}
.mode-card.selected { opacity: 1; border: 1px solid transparent; background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box, var(--grad) border-box; }
.mode-card .mc-t { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mode-card .mc-d { font-size: 12px; color: var(--text-2); line-height: 1.45; }

.sched-editor { display: flex; flex-direction: column; gap: 6px; }
.sched-day {
  display: flex; align-items: center; gap: 14px; padding: 8px 12px;
  border: 1px solid var(--hair); border-radius: 12px; background: var(--surface);
  min-height: 52px;
}
.sched-day.closed { opacity: .6; border-style: dashed; background: var(--surface-deep); }
.day-pill {
  min-width: 48px; height: 32px; border-radius: 9px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--surface-deep); border: 1px dashed var(--hair); cursor: pointer; flex: none;
}
.day-pill.on { color: #fff; background: var(--grad); border: none; }
.ivals { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.ival {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px 6px;
}
.ival input[type="time"] {
  border: none; background: transparent; padding: 3px 2px; border-radius: 6px;
  font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; width: 78px;
}
.ival input[type="time"]:focus { outline: 1px solid #3D5AA9; }
.ival-x { background: none; border: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 3px; }
.ival-x:hover { color: var(--late); }
.ival-add {
  background: none; border: 1px dashed var(--border); border-radius: 9px;
  color: var(--text-2); font-size: 12px; padding: 7px 11px;
}
.ival-add:hover { border-color: var(--border-strong); color: var(--text-3); }
.copy-btn {
  background: none; border: none; color: var(--blue); font-size: 12px; padding: 4px 6px; flex: none;
  opacity: 0; transition: opacity .12s;
}
.sched-day:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { text-decoration: underline; }

.day-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-chip {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-deep);
  border: 1px dashed var(--hair); cursor: pointer;
}
.day-chip.on { color: #fff; background: var(--grad); border: none; }
.sched-row { display: flex; align-items: center; gap: 10px; }
.sched-row .day-label { width: 44px; font-size: 12.5px; color: var(--text-2); flex: none; }
.sched-row input { width: 100%; }

.tpl-box { width: 100%; min-height: 74px; resize: vertical; line-height: 1.5; border-radius: 12px; padding: 12px 14px; }
.varchip { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }

.actions { display: flex; align-items: center; gap: 12px; }
.actions .grow { flex: 1; }

.empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.note { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; color: var(--text-3); z-index: 50;
  animation: slideIn .2s ease-out; max-width: 380px;
}
.toast.err { border-color: rgba(255,77,94,.5); color: var(--alert-fg); }

/* ── Lista de leads (overlay) ── */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 16, .55); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px;
}
[data-theme="light"] .overlay { background: rgba(23, 29, 46, .35); }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px;
  width: 860px; max-width: 100%; max-height: 80vh; display: flex; flex-direction: column;
  animation: slideIn .18s ease-out; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--hair); }
.modal-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { overflow-y: auto; padding: 6px 0 12px; }
.lead-row { display: flex; align-items: center; gap: 14px; padding: 11px 22px; border-top: 1px solid var(--hair-2); font-size: 13px; }
.lead-row:first-child { border-top: none; }
.lead-row .lr-time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); width: 40px; flex: none; }
.lead-row .lr-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lead-row .lr-name { font-weight: 500; }
.lead-row .lr-sub { font-size: 11.5px; color: var(--text-2); }
.lead-row .lr-notes {
  font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lead-row .lr-extra { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.kv {
  font-size: 11px; color: var(--text-3); background: var(--surface-deep);
  border: 1px solid var(--hair); border-radius: 6px; padding: 2px 7px;
}
.kv b { font-weight: 600; color: var(--text-2); text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
.badge { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 10px; flex: none; }
.badge-ok { color: var(--ok); background: rgba(52,211,136,.12); }
.badge-wait { color: var(--wait); background: rgba(255,176,32,.12); }
.badge-late { color: var(--late); background: rgba(255,77,94,.12); }
.badge-gray { color: var(--text-2); background: var(--surface-deep); }
.badge-blue { color: var(--blue); background: rgba(61,139,255,.12); }
.fig.clickable { cursor: pointer; border-radius: 10px; }
.fig.clickable:hover .cap { color: var(--text-2); }
.fig.clickable:hover .val { color: var(--blue); }

/* ── Login ── */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 16px; align-items: stretch; text-align: center; }
.login-card img { width: 56px; height: 56px; margin: 0 auto; }
.login-card h1 { font-size: 19px; margin: 0; }
.login-card .sub { font-size: 13px; color: var(--text-2); margin-top: -8px; }
.login-err { color: var(--alert-fg); font-size: 12.5px; min-height: 16px; }
