/* ===========================================================
   Staff Gestão — Estilo base
   Paleta moderna, responsiva, sem dependências externas.
   =========================================================== */
:root {
  --bg: #0f172a;
  --bg-soft: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --sidebar-w: 250px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Garante que o atributo hidden sempre oculte o elemento,
   mesmo quando o elemento tem display definido no CSS. */
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff; font-weight: 700; font-size: 16px;
  display: grid; place-items: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { font-size: 12px; color: #94a3b8; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  font-size: 14px; text-align: left; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; }

.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
}
.page-title { font-size: 20px; margin: 0; flex: 1; }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text); }
.topbar-actions { display: flex; gap: 10px; }

.content { padding: 28px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ---------- Views ---------- */
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid; gap: 16px; margin-bottom: 24px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; display: flex; gap: 14px;
  align-items: center; box-shadow: var(--shadow);
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 20px;
}
.stat-icon.accent { background: #e0e7ff; color: #4f46e5; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Grid / Panels ---------- */
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; margin: 0; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px;
}
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.dot.agendada { background: var(--primary); }
.dot.realizada { background: var(--success); }
.dot.visitado { background: var(--success); }
.tl-body { flex: 1; }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-sub { font-size: 12px; color: var(--text-muted); }
.tl-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------- Toolbar / Inputs ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; background: var(--surface);
  color: var(--text); transition: .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.input { cursor: pointer; }
.toolbar .input { width: auto; min-width: 220px; flex: 1; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 16px; text-align: left; font-size: 14px; }
.table th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr + tr { border-top: 1px solid var(--border); }
.table tbody tr:hover { background: #f8fafc; }
.ta-right { text-align: right; }
.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }

/* ---------- Cards (visitas) ---------- */
.cards-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.visit-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.visit-card[data-visita-id] { cursor: pointer; }
.visit-card[data-visita-id]:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline li[data-visita-id] { cursor: pointer; }
.timeline li[data-visita-id]:hover { border-color: var(--primary); background: var(--primary-soft); }
.visit-card .vc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge.agendada { background: var(--primary-soft); color: var(--primary); }
.badge.realizada { background: var(--success-soft); color: var(--success); }
.badge.visitado { background: var(--success-soft); color: var(--success); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.neutral { background: var(--bg-soft); color: var(--text-muted); }
.vc-title { font-weight: 600; font-size: 15px; }
.vc-sub { font-size: 13px; color: var(--text-muted); }
.vc-audio { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--primary); }
.vc-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px;
  font-weight: 500; cursor: pointer; font-family: inherit; transition: .15s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: #e0e7ff; }
.btn-ghost.recording { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
.btn-ghost.dictating { background: var(--primary); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: pop .2s ease;
}
.modal-lg { max-width: 640px; }
.modal-sm { max-width: 420px; }
.confirm-body { padding: 18px 22px; }
.confirm-body p { margin: 0; font-size: 14px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; }
.form { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- Status de visitas no cadastro do cliente ---------- */
.visita-status {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; background: #f8fafc;
}
.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vs-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
.vs-label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  color: var(--text-muted); text-transform: uppercase;
}
.vs-value { font-size: 20px; font-weight: 700; }
.vs-item.ok { border-color: var(--success); background: var(--success-soft); }
.vs-item.warn { border-color: var(--warn); background: var(--warn-soft); }
.vs-item.danger { border-color: var(--danger); background: #fee2e2; }
.vs-item.neutral { border-color: var(--border); }

/* ---------- Registro histórico do cliente ---------- */
.registro-historico {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px; max-height: 280px; overflow-y: auto;
}
.rh-item {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: var(--surface);
  border-left: 3px solid var(--primary);
}
.rh-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 4px;
}
.rh-numero {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); padding: 2px 8px; border-radius: 6px;
  letter-spacing: .04em;
}
.rh-data { font-size: 12px; color: var(--text-muted); }
.rh-texto { margin: 0; font-size: 13px; white-space: pre-wrap; }

.input[readonly] {
  background: var(--bg-soft); color: var(--text-muted); cursor: default;
}

/* ---------- Histórico de visitas ---------- */
.historico-list {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 260px; overflow-y: auto;
}
.historico-item {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: var(--surface);
}
.historico-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; gap: 8px;
}
.historico-date { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.historico-item p { margin: 0; font-size: 13px; white-space: pre-wrap; }

/* ---------- Novidades / controle de versão ---------- */
.novidades-body { padding: 18px 22px; max-height: 60vh; overflow-y: auto; }
.nv-secao + .nv-secao { margin-top: 18px; }
.nv-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 6px;
}
.nv-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: #fff; background: var(--primary);
  padding: 2px 9px; border-radius: 999px;
}
.nv-data { font-size: 12px; color: var(--text-muted); }
.nv-titulo { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.nv-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; }
.nv-lista { margin: 0; padding-left: 20px; font-size: 14px; }
.nv-lista li { margin-bottom: 6px; }
.nv-ftp {
  margin-top: 16px; padding: 12px 14px;
  background: var(--primary-soft); border-radius: 10px;
  font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.nv-ftp strong { color: var(--primary); }

.form-section {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; background: #f8fafc;
}
.form-section h3 { font-size: 14px; margin: 0 0 4px; }
.contact-row {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; background: var(--surface);
}
.contact-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.contact-num { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field.check {
  flex-direction: row; align-items: center; gap: 8px;
}
.field.check input {
  width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer;
}
.field.check span { margin: 0; }

.audio-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.audio-preview { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #f8fafc; display: flex; flex-direction: column; gap: 8px; }
.audio-meta { display: flex; justify-content: space-between; font-size: 13px; }

/* ---------- Misc ---------- */
.empty { color: var(--text-muted); text-align: center; padding: 30px; font-size: 14px; }
.muted { color: var(--text-muted); margin: 0; }
.muted.small { font-size: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow); animation: fade .2s ease;
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 600px at 50% -10%, #312e81, var(--bg));
  display: grid; place-items: center; padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 18px; padding: 36px 32px;
  width: 100%; max-width: 380px; box-shadow: 0 30px 80px rgba(0,0,0,.4);
  text-align: center; animation: pop .25s ease;
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px;
  font-size: 20px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.google-btn { margin-top: 22px; display: flex; justify-content: center; }
.google-btn > div { width: 100% !important; }
.login-hint {
  margin: 16px 0 0; font-size: 12px; color: var(--text-muted);
  background: var(--bg-soft); border-radius: 8px; padding: 8px 10px;
}

.footer-actions {
  display: flex; gap: 14px; margin-top: 8px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
