/* ============================================================
   CHECK LIST — DESIGN SYSTEM v2
   Sem imagem de fundo · Dark mode nativo · Mobile-first
   ============================================================ */

/* ── Tokens ────────────────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --primary-muted:  rgba(37,99,235,.10);
  --secondary:      #10b981;
  --secondary-dark: #059669;
  --accent:         #f97316;
  --danger:         #ef4444;
  --danger-dark:    #dc2626;
  --warning:        #f59e0b;

  /* Superfícies */
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;

  /* Bordas */
  --border:     #e2e8f0;
  --border-med: #cbd5e1;

  /* Texto */
  --text:       #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-md: 0 8px 20px rgba(0,0,0,.10);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.14);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Misc */
  --transition: .18s ease;
  --header-height: 108px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Imagem de fundo controlada por DW_CONFIG.BG_IMAGE via js/app-config.js */
  background-image: var(--dw-bg-image, none);
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* Camada de opacidade sobre o bg para manter legibilidade */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(241,245,249,.88);
  z-index: 0;
  pointer-events: none;
}

/* Elementos sempre acima do fundo */
#app-header, #app-main, #pwa-banner,
#app-drawer, #app-drawer-overlay,
#busca-global-overlay, #config-modal-overlay,
#modal-overlay, #edit-drawer-overlay,
.toast {
  position: relative;
  z-index: 1;
}
#app-header         { z-index: 100; }
#app-drawer-overlay { z-index: 200; }
#app-drawer         { z-index: 201; }
#edit-drawer-overlay{ z-index: 500; }
#busca-global-overlay { z-index: 9000; }
#config-modal-overlay { z-index: 8500; }
.toast              { z-index: 9999; }

/* ── PWA standalone ─────────────────────────────────────────── */
@media (display-mode: standalone), (display-mode: fullscreen), (-webkit-standalone: 1) {
  body { min-height: 100dvh; overflow: hidden auto; }
  #pwa-banner { display: none !important; }
}

/* ── Banner de instalação PWA ───────────────────────────────── */
#pwa-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 2px solid var(--primary);
  box-shadow: 0 2px 12px rgba(37,99,235,.12);
  animation: slideDown .3s ease;
}
#pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  max-width: 680px;
  margin: 0 auto;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Header ─────────────────────────────────────────────────── */
#app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(37,99,235,.25);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: #fff;
  min-width: 0;
}
.logo-area > .hdr-menu-btn { margin-left: auto; flex-shrink: 0; }
.logo-area > i { font-size: 24px; opacity: .95; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,.2)); }
.logo-area > div:first-of-type { flex-shrink: 1; min-width: 0; overflow: hidden; }
.logo-area h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logo-area span {
  font-size: 10px;
  opacity: .78;
  font-weight: 400;
  letter-spacing: .4px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 150px;
}

/* Tab nav no header */
.tab-nav { display: flex; gap: 2px; }

.tab-btn {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(255,255,255,.72);
  padding: 9px 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-btn i { font-size: 14px; flex-shrink: 0; }
.tab-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.tab-btn.active {
  background: rgba(255,255,255,.16);
  border-bottom-color: #fff;
  color: #fff;
  font-weight: 700;
}

/* ── Hamburger ──────────────────────────────────────────────── */
.hdr-menu-btn {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.hdr-menu-btn:hover { background: rgba(255,255,255,.26); }

/* ── App Drawer ─────────────────────────────────────────────── */
#app-drawer.open { right: 0 !important; }

.app-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.app-drawer-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.app-drawer-item i { width: 18px; text-align: center; color: var(--text-muted); flex-shrink: 0; }
.app-drawer-item:hover i { color: var(--primary); }

/* ── Main ───────────────────────────────────────────────────── */
#app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ── Tab content ────────────────────────────────────────────── */
.tab-content { display: none; animation: fadeIn .22s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form header ────────────────────────────────────────────── */
.form-header {
  text-align: center;
  padding: 24px 0 12px;
  margin-bottom: 4px;
}
.form-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  letter-spacing: -.2px;
}
.form-header h2 i { color: var(--primary); }
.form-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
  font-weight: 400;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  transition: box-shadow .2s;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 16px;
  padding-bottom: 11px;
  border-bottom: 1.5px solid var(--primary-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i {
  font-size: 13px;
  background: var(--primary-muted);
  color: var(--primary);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

/* ── Form grid ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-full { grid-column: 1 / -1; }

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface2);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 90px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: var(--surface);
}
input::placeholder, textarea::placeholder {
  color: var(--text-light);
  font-size: 13px;
}

/* ── Ações / Botões principais ──────────────────────────────── */
.actions-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
  letter-spacing: .15px;
}

#btn-salvar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.30);
  font-size: 15px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
}
#btn-salvar:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(37,99,235,.40);
  transform: translateY(-1px);
}
#btn-salvar:active { transform: translateY(0); box-shadow: none; }
#btn-salvar:disabled { opacity: .55; cursor: not-allowed; transform: none; }

#btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,211,102,.28);
  font-size: 15px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
}
#btn-whatsapp:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(37,211,102,.38);
  transform: translateY(-1px);
}

#btn-limpar {
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  font-size: 13px;
  padding: 11px 20px;
}
#btn-limpar:hover { background: var(--surface3); border-color: var(--border-med); }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}
.filter-bar label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.filter-bar input[type="date"] { flex: 1; min-width: 130px; font-size: 14px; padding: 8px 12px; }

.btn-refresh {
  background: var(--primary-light);
  color: var(--primary);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.btn-refresh:hover { background: var(--primary); color: #fff; }

/* ── Lista de atendimentos ──────────────────────────────────── */
#lista-atendimentos { display: flex; flex-direction: column; gap: 10px; }

.atendimento-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
}
.atendimento-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.atendimento-header {
  background: linear-gradient(90deg, var(--primary-light) 0%, #e0eeff 100%);
  padding: 11px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid #dce9fb;
}
.atendimento-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}
.atendimento-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.atendimento-meta span { display: flex; align-items: center; gap: 4px; }
.atendimento-actions { display: flex; gap: 5px; flex-shrink: 0; }

.btn-icon {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  transition: var(--transition);
}
.btn-icon.btn-wpp-icon  { color: #25D366; border-color: #25D366; }
.btn-icon.btn-wpp-icon:hover  { background: #25D366; color: #fff; }
.btn-icon.btn-edit-icon { color: var(--primary); border-color: var(--primary); }
.btn-icon.btn-edit-icon:hover { background: var(--primary); color: #fff; }
.btn-icon.btn-del-icon  { color: var(--danger); border-color: var(--danger); }
.btn-icon.btn-del-icon:hover  { background: var(--danger); color: #fff; }

.atendimento-body { padding: 14px 16px; }

/* Collapse */
.at-collapsible:hover { background: linear-gradient(90deg, #d4e4fb, #c8d8f8); }
.at-chevron {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.06); flex-shrink: 0;
}
.at-collapsible:hover .at-chevron { background: rgba(37,99,235,.15); color: var(--primary) !important; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.info-value { font-size: 13px; color: var(--text); font-weight: 500; word-break: break-word; }

/* ── Relatório ──────────────────────────────────────────────── */
.relatorio-acoes { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.btn-copy {
  background: var(--primary-light);
  color: var(--primary);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  flex: 1;
}
.btn-copy:hover { background: var(--primary); color: #fff; }

.btn-wpp {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  flex: 1;
  box-shadow: 0 3px 10px rgba(37,211,102,.22);
}
.btn-wpp:hover { opacity: .92; }

#relatorio-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}
.relatorio-texto {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.relatorio-info { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; font-style: italic; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 44px; opacity: .22; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Badge ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: .3px;
}
.badge-green  { background: var(--secondary); }
.badge-orange { background: var(--accent); }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #0f172a;
  color: #fff;
  padding: 11px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  z-index: 9999;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .28s ease;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--secondary); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }
.toast.warning { background: #d97706; }
.toast.edit    { background: var(--primary); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 26px 26px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn .22s ease;
  border: 1px solid var(--border);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.9) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-icon { font-size: 40px; color: var(--warning); margin-bottom: 14px; }
.modal-box h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.modal-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 22px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns button { flex: 1; padding: 12px; font-size: 14px; border-radius: var(--radius-sm); }
#modal-cancel { background: var(--surface2); color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }

/* ── Seções preenchidas ─────────────────────────────────────── */
.section-preenchida { margin-bottom: 8px; }
.section-preenchida-titulo {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--primary-muted);
}
.card-group {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-group:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.card-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-group-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 13px;
  background: var(--primary);
  border-radius: 2px;
}
.info-item-vazio .info-label,
.info-item-vazio .info-value,
.valor-vazio { color: var(--text-light); font-style: italic; font-size: 12px; }

/* ── Abas internas de atendimentos ─────────────────────────── */
.at-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.at-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: var(--transition);
}
.at-tab-btn.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.at-tab-btn:not(.active):hover { background: var(--surface2); color: var(--text); }

/* ── Barra de busca ─────────────────────────────────────────── */
.busca-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.busca-input-wrap { position: relative; display: flex; align-items: center; }
.busca-ico { position: absolute; left: 13px; color: var(--text-muted); font-size: 14px; pointer-events: none; }
#busca-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 40px 11px 38px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
#busca-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
#busca-input::-webkit-search-cancel-button { display: none; }
.busca-clear {
  position: absolute;
  right: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: var(--transition);
}
.busca-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.busca-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.busca-filtros select {
  flex: 1; min-width: 130px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.busca-filtros select:focus { border-color: var(--primary); }
.busca-info { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.busca-info b { color: var(--primary); }
mark.busca-hl {
  background: rgba(37,99,235,.15);
  color: var(--primary-dark);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}

/* ── Drawer de edição ───────────────────────────────────────── */
#edit-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.50);
  z-index: 2000;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#edit-drawer-overlay.open { display: flex; align-items: flex-end; justify-content: center; }
#edit-drawer {
  background: var(--surface);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(0,0,0,.16);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.34,1.15,.64,1);
  overflow: hidden;
}
#edit-drawer-overlay.open #edit-drawer { transform: translateY(0); }
.drawer-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 11px auto 0; flex-shrink: 0; }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}
.drawer-header-left { display: flex; align-items: center; gap: 10px; }
.drawer-header-left i { font-size: 18px; color: var(--primary); }
.drawer-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.2; }
.drawer-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.drawer-close {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: var(--transition);
}
.drawer-close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; -webkit-overflow-scrolling: touch; }
.drawer-section { margin-bottom: 18px; }
.drawer-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--primary-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drawer-grid .field-full { grid-column: 1 / -1; }
.drawer-field { display: flex; flex-direction: column; gap: 4px; }
.drawer-field label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; }
.drawer-field input, .drawer-field select, .drawer-field textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface2);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.drawer-field input:focus, .drawer-field select:focus, .drawer-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.10);
  background: var(--surface);
}
.drawer-field textarea { resize: vertical; min-height: 72px; }
.drawer-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.drawer-footer .btn-salvar-edit {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .2s;
}
.drawer-footer .btn-salvar-edit:disabled { opacity: .6; cursor: not-allowed; }
.drawer-footer .btn-cancelar-edit {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}
.drawer-footer .btn-cancelar-edit:hover { background: var(--surface3); }

/* ── Offline ────────────────────────────────────────────────── */
.offline-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  animation: pulseIn .3s ease;
}
.offline-badge.offline  { background: rgba(239,68,68,.14); border: 1.5px solid rgba(239,68,68,.4); color: #ef4444; }
.offline-badge.pendente { background: rgba(245,158,11,.14); border: 1.5px solid rgba(245,158,11,.4); color: #f59e0b; }

#offline-barra {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  position: sticky;
  top: var(--header-height, 108px);
  z-index: 90;
  animation: slideDown .25s ease;
}
#offline-barra.offline  { background: #fef2f2; border-bottom: 2px solid #fca5a5; color: #991b1b; }
#offline-barra.pendente { background: #fffbeb; border-bottom: 2px solid #fcd34d; color: #92400e; }
#offline-barra i { font-size: 15px; flex-shrink: 0; }

@keyframes pulseIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Botões dark toggle / header icon ───────────────────────── */
.btn-dark-toggle {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  padding: 7px 11px;
  border-radius: var(--radius-xs);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-dark-toggle:hover { background: rgba(255,255,255,.28); }
.hdr-icon-btn { margin-left: 0; padding: 7px 9px; min-width: 34px; min-height: 34px; }

/* ── Dark Mode ──────────────────────────────────────────────── */
/* Dark mode: camada mais densa */
body.dark::before {
  background: rgba(10,14,26,.92);
}

body.dark {
  --primary:        #60a5fa;
  --primary-dark:   #3b82f6;
  --primary-light:  #1e3a5f;
  --primary-muted:  rgba(96,165,250,.12);
  --secondary:      #34d399;
  --secondary-dark: #10b981;
  --accent:         #fb923c;
  --danger:         #f87171;
  --danger-dark:    #ef4444;
  --warning:        #fbbf24;

  --bg:       #0a0e1a;
  --surface:  #111827;
  --surface2: #1a2035;
  --surface3: #1e2640;

  --border:     #1f2d45;
  --border-med: #2a3d58;

  --text:       #e8f0fe;
  --text-muted: #7b90b0;
  --text-light: #3a4d68;

  --shadow-xs: 0 1px 3px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 6px rgba(0,0,0,.45);
  --shadow:    0 4px 16px rgba(0,0,0,.55);
  --shadow-md: 0 8px 24px rgba(0,0,0,.6);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.7);
}

body.dark #app-header {
  background: linear-gradient(135deg, #1a2f4a 0%, #0d1b2e 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(0,0,0,.4);
}
body.dark .card { background: var(--surface); border-color: var(--border); }
body.dark input[type="text"], body.dark input[type="number"],
body.dark input[type="date"], body.dark input[type="time"],
body.dark input[type="search"], body.dark select, body.dark textarea {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
  color-scheme: dark;
}
body.dark input::placeholder, body.dark textarea::placeholder { color: var(--text-light); }
body.dark input:focus, body.dark select:focus, body.dark textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96,165,250,.14);
  background: var(--surface);
}
body.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237b90b0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;

}
body.dark .atendimento-header { background: linear-gradient(90deg, #1a2f4a, #1d2d45); border-bottom-color: var(--border); }
body.dark .atendimento-title { color: var(--primary); }
body.dark .btn-icon { background: var(--surface2); border-color: var(--border); color: var(--text-muted); }
body.dark .btn-icon.btn-wpp-icon  { color: #34d399; border-color: #34d399; }
body.dark .btn-icon.btn-edit-icon { color: var(--primary); border-color: var(--primary); }
body.dark .btn-icon.btn-del-icon  { color: var(--danger); border-color: var(--danger); }
body.dark .filter-bar   { background: var(--surface); border-color: var(--border); }
body.dark .btn-refresh  { background: var(--primary-light); color: var(--primary); }
body.dark .btn-refresh:hover { background: var(--primary); color: #fff; }
body.dark #relatorio-output { background: var(--surface); border-color: var(--border); }
body.dark .relatorio-texto { background: var(--surface2); border-color: var(--border); color: var(--text); }
body.dark .btn-copy { background: var(--primary-light); color: var(--primary); }
body.dark .btn-copy:hover { background: var(--primary); color: #fff; }
body.dark .modal-box { background: var(--surface); border: 1px solid var(--border); }
body.dark .modal-box h3 { color: var(--text); }
body.dark .modal-box p  { color: var(--text-muted); }
body.dark #modal-cancel { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
body.dark .at-tabs { background: var(--surface); border-color: var(--border); }
body.dark .at-tab-btn.active { background: var(--primary); color: #fff; }
body.dark #busca-input { background: var(--surface2); border-color: var(--border); color: var(--text); }
body.dark .busca-filtros select { background: var(--surface2); border-color: var(--border); color: var(--text); color-scheme: dark; }
body.dark .busca-clear { background: var(--surface2); border-color: var(--border); }
body.dark #edit-drawer { background: var(--surface); border-top: 1px solid var(--border); }
body.dark .drawer-header { border-bottom-color: var(--border); }
body.dark .drawer-footer { border-top-color: var(--border); background: var(--surface); }
body.dark .drawer-section-title { border-bottom-color: var(--border); color: var(--primary); }
body.dark .drawer-field input, body.dark .drawer-field select, body.dark .drawer-field textarea {
  background: var(--surface2); border-color: var(--border); color: var(--text); color-scheme: dark;
}
body.dark .drawer-close { background: var(--surface2); border-color: var(--border); color: var(--text-muted); }
body.dark .drawer-handle { background: var(--border); }
body.dark #btn-limpar { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
body.dark #btn-limpar:hover { background: var(--surface3); }
body.dark .card-title { color: var(--primary); border-bottom-color: var(--primary-muted); }
body.dark .form-header h2 { color: var(--text); }
body.dark .form-header h2 i { color: var(--primary); }
body.dark .section-preenchida-titulo { border-bottom-color: var(--border); }
body.dark .card-group { border-bottom-color: var(--border); }
body.dark .card-group-title { color: var(--primary); }
body.dark .card-group-title::before { background: var(--primary); }
body.dark .badge { background: var(--primary); }
body.dark .offline-badge.offline  { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.35); color: #f87171; }
body.dark .offline-badge.pendente { background: rgba(251,191,36,.12);  border-color: rgba(251,191,36,.35);  color: #fbbf24; }
body.dark #offline-barra.offline  { background: rgba(239,68,68,.10);  border-bottom-color: rgba(239,68,68,.35);  color: #fca5a5; }
body.dark #offline-barra.pendente { background: rgba(245,158,11,.10); border-bottom-color: rgba(245,158,11,.35); color: #fcd34d; }
body.dark #pwa-banner { background: var(--surface); border-bottom-color: var(--primary); }

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  html { font-size: 14px; }
  .header-inner { padding: 10px 12px 0; }
  .logo-area h1 { font-size: 17px; }
  .tab-btn { font-size: 10px; padding: 8px 4px; }
  #app-main { padding: 12px 12px 36px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: 1; }
  .info-grid { grid-template-columns: 1fr; }
  .card { padding: 14px 14px; }
  .relatorio-texto { font-size: 12px; max-height: 55vh; }
  #edit-drawer { max-height: 95vh; border-radius: 18px 18px 0 0; }
  .drawer-grid { grid-template-columns: 1fr; }
  .drawer-grid .field-full { grid-column: 1; }
  .drawer-header { padding: 12px 14px 10px; }
  .drawer-body   { padding: 12px 14px; }
  .drawer-footer { padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 380px) {
  .logo-area > i { display: none; }
  .logo-area h1 { font-size: 15px; }
  .hdr-icon-btn { padding: 6px 7px; min-width: 30px; min-height: 30px; font-size: 13px; }
}
@media (min-width: 601px) and (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media print {
  #app-header, .actions-card, .filter-bar, .atendimento-actions, .relatorio-acoes { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
