/* =========================================================
   Painel Admin — Dra. Marianny
   Paleta: petróleo + cobre (mesma do site)
   ========================================================= */
:root {
  --bg:      #F5F0E8;
  --bg-2:    #EBE2D4;
  --card:    rgba(255,255,255,.88);
  --p-900:   #0C2828;
  --p-800:   #142E2E;
  --p-700:   #1E3E3E;
  --p-600:   #2A5050;
  --p-200:   #A8BCBC;
  --c-500:   #C87848;
  --c-400:   #D08050;
  --c-100:   #F2DDD0;
  --ink:     #0F2020;
  --muted:   #4A6060;
  --subtle:  #7A9090;
  --line:    rgba(12,40,40,.14);
  --line-s:  rgba(12,40,40,.08);
  --serif:   "Cormorant Garamond", Georgia, serif;
  --sans:    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --r:       8px;
  --ease:    cubic-bezier(.22,1,.36,1);
  --sidebar: 220px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); min-height: 100dvh; -webkit-font-smoothing: antialiased; }

/* ── Screens ── */
.screen { display: none; }
.screen.is-active { display: flex; }
.screen-app.is-active { display: block; }
/* Login visível por padrão (fallback se o JS não carregar) */
.screen-login { display: flex; }

/* ── Login ── */
.screen-login { min-height: 100dvh; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--p-900) 0%, var(--p-700) 100%); }
.login-card { background: var(--bg); border-radius: 16px; padding: 44px 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); text-align: center; }
.login-logo { border-radius: 50%; margin-bottom: 16px; }
.login-title { font-family: var(--serif); font-weight: 400; font-size: 28px; color: var(--p-800); }
.login-sub { font-size: 13px; color: var(--muted); margin: 6px 0 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.mfa-hint { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 8px; }
.qr-wrap { display: flex; justify-content: center; margin: 16px 0; }
.qr-wrap canvas { border-radius: 8px; border: 4px solid var(--bg-2); }
.mfa-secret-label { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }
.mfa-secret { display: block; text-align: center; font-size: 13px; letter-spacing: .12em; background: var(--bg-2); padding: 8px 12px; border-radius: 6px; word-break: break-all; margin: 6px 0 0; }
.login-error { font-size: 13px; color: #c0392b; text-align: center; padding: 8px; background: #fdf0ee; border-radius: 6px; }

/* ── App shell ── */
.screen-app { min-height: 100dvh; }
.sidebar {
  width: var(--sidebar); min-height: 100dvh; background: var(--p-800);
  display: flex; flex-direction: column; padding: 0; position: fixed; left: 0; top: 0; bottom: 0; z-index: 20;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand img { border-radius: 50%; }
.sidebar-brand span { font-family: var(--serif); font-size: 17px; color: #fff; font-weight: 500; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-nav li { }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  color: rgba(255,255,255,.7); text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: .25s var(--ease); position: relative;
}
.nav-link:hover, .nav-link.is-active { color: #fff; background: rgba(255,255,255,.08); }
.nav-link.is-active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; background: var(--c-400); border-radius: 0 3px 3px 0; }
.badge { background: var(--c-400); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; margin-left: auto; }
.sidebar-logout { margin: 0 12px 20px; background: transparent; border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.6); cursor: pointer; padding: 10px 16px; border-radius: var(--r); font-size: 12.5px; display: flex; align-items: center; gap: 8px; transition: .25s var(--ease); }
.sidebar-logout:hover { border-color: rgba(255,255,255,.5); color: #fff; }

.main-content { margin-left: var(--sidebar); padding: 32px 36px; min-height: 100dvh; }

/* ── Views ── */
.view { display: block; }
.view[hidden] { display: none; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.view-header h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; color: var(--p-800); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Agenda ── */
.agenda-date-label { font-size: 15px; font-weight: 600; color: var(--p-700); min-width: 160px; text-align: center; }
.agenda-grid { display: flex; flex-direction: column; gap: 10px; }
.appt-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 20px; display: flex; align-items: center; gap: 16px;
  transition: .25s var(--ease);
}
.appt-card:hover { box-shadow: 0 8px 24px -12px rgba(12,40,40,.4); }
.appt-time { font-size: 22px; font-family: var(--serif); color: var(--p-700); min-width: 60px; }
.appt-info { flex: 1; }
.appt-cli { font-weight: 600; color: var(--p-800); font-size: 15px; }
.appt-obs { font-size: 13px; color: var(--muted); margin-top: 2px; }
.appt-status { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.status-solicitado  { background: #FEF3C7; color: #92400E; }
.status-confirmado  { background: #D1FAE5; color: #065F46; }
.status-atendido    { background: #DBEAFE; color: #1E40AF; }
.status-cancelado   { background: #F3F4F6; color: #6B7280; }
.appt-actions { display: flex; gap: 6px; }

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: 0 2px 12px -8px rgba(12,40,40,.3); }
.data-table th { background: var(--p-800); color: rgba(255,255,255,.85); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 12px 16px; text-align: left; }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--line-s); font-size: 14px; color: var(--ink); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(12,40,40,.03); }
.loading { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

/* ── Campos ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1.5px solid var(--line); background: #fff; border-radius: 6px;
  padding: 10px 12px; font-size: 14.5px; font-family: var(--sans); color: var(--ink);
  transition: border-color .3s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-400); }
.field textarea { resize: vertical; }
.search-input { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 16px; font-size: 13.5px; font-family: var(--sans); color: var(--ink); min-width: 220px; transition: border-color .3s var(--ease); }
.search-input:focus { outline: none; border-color: var(--c-400); }
.req { color: var(--c-400); }

/* ── Botões ── */
.btn-primary {
  background: var(--p-800); color: #fff; border: none; cursor: pointer;
  padding: 11px 22px; border-radius: 6px; font-family: var(--sans); font-size: 13px; font-weight: 600;
  letter-spacing: .04em; transition: .25s var(--ease);
}
.btn-primary:hover { background: var(--p-900); }
.btn-primary.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--muted); cursor: pointer; padding: 10px 20px; border-radius: 6px; font-family: var(--sans); font-size: 13px; font-weight: 600; transition: .25s var(--ease); }
.btn-ghost:hover { border-color: var(--p-700); color: var(--p-800); }
.btn-ghost.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-icon { background: transparent; border: 1.5px solid var(--line); color: var(--p-700); cursor: pointer; width: 34px; height: 34px; border-radius: 6px; font-size: 16px; display: grid; place-items: center; transition: .25s var(--ease); }
.btn-icon:hover { border-color: var(--p-700); background: var(--p-800); color: #fff; }
.btn-danger { background: #c0392b; color: #fff; border: none; cursor: pointer; padding: 8px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; transition: .25s var(--ease); }
.btn-danger:hover { background: #a93226; }

/* ── Modais ── */
.modal-veil { position: fixed; inset: 0; z-index: 50; background: rgba(12,40,40,.45); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; animation: fadeIn .3s ease; }
.modal-veil[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: var(--bg); border-radius: 12px; padding: 36px 32px 28px; width: 100%; max-width: 480px; position: relative; box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); animation: slideUp .35s var(--ease); }
.modal-card-wide { max-width: 680px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--p-800); }
.modal-title { font-family: var(--serif); font-weight: 400; font-size: 26px; color: var(--p-800); margin-bottom: 22px; }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.form-error { font-size: 13px; color: #c0392b; padding: 8px 12px; background: #fdf0ee; border-radius: 6px; }

/* ── Detalhe cliente ── */
.detail-content { display: flex; flex-direction: column; gap: 16px; }
.detail-row { display: flex; gap: 8px; }
.detail-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); min-width: 100px; }
.detail-value { font-size: 14.5px; color: var(--ink); }
.hist-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.hist-item { background: var(--bg-2); border-radius: 6px; padding: 10px 14px; font-size: 13.5px; color: var(--muted); }
.hist-item strong { color: var(--p-700); }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 100; background: var(--p-800); color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px -8px rgba(0,0,0,.5); animation: toastIn .3s var(--ease); }
.toast[hidden] { display: none; }
.toast.is-error { background: #c0392b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Intake cards ── */
.intake-regioes { font-size: 12px; color: var(--muted); }
.intake-desc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 768px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px; }
}

/* ── Segurança / MFA ── */
.qr-wrap img { border-radius: 8px; border: 4px solid var(--bg-2); image-rendering: pixelated; width: 200px; height: 200px; }
.security-panel { display: flex; flex-direction: column; gap: 20px; max-width: 620px; }
.sec-card { background: var(--card); border-radius: var(--r); padding: 24px 26px; box-shadow: 0 2px 12px -8px rgba(12,40,40,.3); border: 1px solid var(--line-s); }
.sec-card-head { display: flex; gap: 14px; align-items: flex-start; }
.sec-card-head svg { color: var(--p-700); flex: none; margin-top: 2px; }
.sec-card h3 { font-family: var(--serif); font-weight: 500; font-size: 21px; color: var(--p-800); }
.sec-status { font-size: 13px; font-weight: 600; margin-top: 4px; }
.sec-card.is-on .sec-status { color: #1E7A4D; }
.sec-card.is-off .sec-status { color: #B45309; }
.sec-desc { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 16px 0 18px; }
.badge-warn { background: #F59E0B !important; }

/* ═══════════════════════════════════════════════════════════
   REFINAMENTO PREMIUM — v2
   ═══════════════════════════════════════════════════════════ */

/* Login aura */
.login-aura { position: fixed; inset: 0; pointer-events: none; background:
  radial-gradient(600px circle at 20% 20%, rgba(208,128,80,.18), transparent 60%),
  radial-gradient(700px circle at 80% 80%, rgba(42,80,80,.35), transparent 60%); }
.login-card { position: relative; z-index: 2; }
.btn-block { width: 100%; }

/* Topbar (mobile) */
.topbar { display: none; }

/* Subtítulos de view */
.view-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ta-right { text-align: right; }
.pos { color: #1E7A4D; } .neg { color: #C0392B; }

/* ── Dashboard: stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line-s); border-radius: 12px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: 0 2px 16px -10px rgba(12,40,40,.4);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgba(12,40,40,.5); }
.stat-card.stat-accent { background: linear-gradient(140deg, var(--p-800), var(--p-600)); border: none; }
.stat-card.stat-accent .stat-label, .stat-card.stat-accent .stat-foot { color: rgba(255,255,255,.7); }
.stat-card.stat-accent .stat-value { color: #fff; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 30px; font-weight: 500; color: var(--p-800); letter-spacing: -.01em; }
.stat-foot { font-size: 12px; color: var(--subtle); }

.dash-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--line-s); border-radius: 12px; padding: 22px 24px; box-shadow: 0 2px 16px -10px rgba(12,40,40,.4); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; color: var(--p-800); }
.panel-sub { font-size: 12px; color: var(--subtle); }

/* Chart de barras */
.chart-bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-pair { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.bar { width: 14px; border-radius: 4px 4px 0 0; min-height: 3px; transition: height .6s var(--ease); }
.bar-r { background: linear-gradient(180deg, var(--p-600), var(--p-800)); }
.bar-d { background: linear-gradient(180deg, var(--c-400), var(--c-500)); }
.chart-x { font-size: 11px; color: var(--subtle); text-transform: capitalize; }

/* Mini agenda */
.mini-agenda { display: flex; flex-direction: column; gap: 8px; }
.mini-appt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-2); border-radius: 8px; }
.mini-time { font-family: var(--serif); font-size: 17px; color: var(--p-700); min-width: 48px; }
.mini-cli { flex: 1; font-size: 13.5px; color: var(--ink); font-weight: 500; }

/* ── Clientes: card grid ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cli-card {
  display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line-s); border-radius: 12px; padding: 16px 18px;
  font-family: var(--sans); transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.cli-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgba(12,40,40,.5); border-color: var(--c-400); }
.cli-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, var(--p-700), var(--p-600)); color: #fff; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.cli-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cli-name { font-size: 15px; font-weight: 600; color: var(--p-800); }
.cli-since { font-size: 12px; color: var(--subtle); }
.cli-arrow { color: var(--p-200); transition: transform .25s var(--ease); }
.cli-card:hover .cli-arrow { color: var(--c-400); transform: translateX(3px); }

/* ── Form rows ── */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 120px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { background: none; border: none; cursor: pointer; padding: 10px 18px; font-family: var(--sans); font-size: 13.5px; font-weight: 600; color: var(--muted); position: relative; transition: color .25s var(--ease); }
.tab:hover { color: var(--p-700); }
.tab.is-active { color: var(--p-800); }
.tab.is-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--c-400); border-radius: 2px; }
.tab-panel { animation: fadeIn .3s ease; }
.detail-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ── Prontuário ── */
.pront-form { background: var(--bg-2); border-radius: 10px; padding: 16px 18px; margin-bottom: 20px; }
.pront-timeline { display: flex; flex-direction: column; gap: 12px; max-height: 380px; overflow-y: auto; padding-right: 4px; }
.pront-entry { border-left: 3px solid var(--c-400); padding: 4px 0 4px 16px; position: relative; }
.pront-entry::before { content: ""; position: absolute; left: -7px; top: 8px; width: 11px; height: 11px; border-radius: 50%; background: var(--c-400); border: 2px solid var(--bg); }
.pront-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.pront-tipo { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--p-800); color: #fff; }
.pront-tipo.tipo-procedimento { background: var(--c-500); }
.pront-tipo.tipo-avaliacao { background: var(--p-600); }
.pront-tipo.tipo-retificacao { background: #B45309; }
.pront-tipo.tipo-observacao { background: var(--subtle); }
.pront-date { font-size: 12px; color: var(--subtle); }
.pront-text { font-size: 14px; color: var(--ink); line-height: 1.6; }

/* ── Financeiro ── */
.fin-summary { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.fin-sum-item { flex: 1; min-width: 140px; background: var(--card); border: 1px solid var(--line-s); border-radius: 10px; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.fin-sum-item span { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.fin-sum-item strong { font-family: var(--serif); font-size: 24px; font-weight: 500; }
.fin-tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
.fin-receita { background: #D1FAE5; color: #065F46; }
.fin-despesa { background: #FEE2E2; color: #991B1B; }
.fin-pend { font-size: 10px; color: #B45309; background: #FEF3C7; padding: 1px 6px; border-radius: 999px; margin-left: 4px; }

/* Segmented toggle */
.seg-toggle { display: flex; background: var(--bg-2); border-radius: 8px; padding: 3px; gap: 3px; }
.seg-opt { flex: 1; border: none; background: transparent; cursor: pointer; padding: 9px; border-radius: 6px; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); transition: .25s var(--ease); }
.seg-opt.is-active { background: #fff; color: var(--p-800); box-shadow: 0 2px 8px -4px rgba(12,40,40,.4); }

/* ── Alertas WhatsApp ── */
.wa-note { font-size: 13px; color: var(--muted); background: var(--bg-2); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; line-height: 1.5; }
.wa-note:empty { display: none; }
.wa-hint { font-size: 12px; color: var(--muted); background: var(--bg-2); border-radius: 8px; padding: 10px 14px; line-height: 1.5; }
.wa-hint strong { color: var(--p-700); }

/* ── Responsivo ── */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar: 0px; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    background: var(--p-800); padding: 12px 16px; color: #fff; }
  .topbar img { border-radius: 50%; }
  .topbar span { font-family: var(--serif); font-size: 16px; font-weight: 500; }
  .topbar-burger { background: none; border: none; color: #fff; cursor: pointer; display: grid; place-items: center; }
  .sidebar { display: flex; transform: translateX(-100%); transition: transform .3s var(--ease); width: 250px; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-veil { position: fixed; inset: 0; z-index: 19; background: rgba(12,40,40,.5); backdrop-filter: blur(2px); }
  .sidebar-veil[hidden] { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .view-header h2 { font-size: 26px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 24px; }
  .card-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 28px 22px 22px; }
}
