    /* ─── RESET & VARIÁVEIS ─── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      --primary:       #0EA5A5;   /* teal — VictaPro */
      --primary-dark:  #0B8484;
      --primary-light: #D4F0EF;
      --primary-ink:   #0A7575;   /* TEXTO em teal (o #0EA5A5 só chega a 3,0:1): 5,5:1 no branco, 4,6:1 sobre a névoa teal */
      --gold:          #F4C04E;   /* amarelo — acento VictaPro */
      --gold-dark:     #D4A017;
      --orange:        #F08A4B;   /* laranja — ações principais */
      --orange-dark:   #D06D30;
      --blue:          #4F6FE0;   /* azul — editar/cancelar */
      --blue-dark:     #3A55C0;
      --blue-light:    #E8EDF9;   /* fundo do selo/ícone da receita */
      --bg:            #FBFCFC;
      --white:         #FFFFFF;
      --text:          #15302F;
      --text-sub:      #436160;
      --text-muted:     #5B7978;   /* texto terciário (4,6:1) — o guia lista #7D9A99, que não lê bem */
      --border:        #EEF3F3;
      --shadow:        0 1px 4px rgba(21,48,47,0.10);
      --nav-h:         62px;
      --header-h:      56px;   /* celular; 64px a partir de 600px (veja o fim do :root) */
      --header-offset: calc(var(--header-h) + env(safe-area-inset-top));
      --green:         #4CB782;
      --red:           #C0392B;
      --red-light:     #FDECEA;
      --danger:         #E53935;   /* perigo/falta/negativo: bolinhas, bordas, ícones */
      --danger-text:    #D5201B;   /* o mesmo vermelho para TEXTO (5,2:1 no branco) */
      --line:           #CCD5D5;   /* linha/borda neutra da família teal (em vez de cinza puro) */
      --green-light:   #D6F0E2;
      --green-ink:     #23774F;   /* texto verde sobre --green-light */
      --orange-light:  #FEE8D6;   /* fundo do selo/ícone de adendo e exames */
    }
    html, body {
      height: 100%;
      font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
      background: var(--bg);
      color: var(--text);
      -webkit-tap-highlight-color: transparent;
    }
    button, input, select, textarea { font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }

    @media (min-width: 600px) { :root { --header-h: 64px; } }

    /* ─── HEADER ───
       Faixa teal com degradê leve: logo, clínica, valores (olho) e o menu da conta.
       Sem overflow:hidden de propósito: o menu da conta sai por baixo da faixa. */
    .header {
      background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 90%, var(--white)) 0%, var(--primary) 100%);
      color: var(--white);
      height: calc(var(--header-h) + env(safe-area-inset-top));
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
      gap: 12px;
      padding: env(safe-area-inset-top) 20px 0 20px;
      position: fixed;
      top: 0; left: 0; right: 0;
      z-index: 200;
      box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 2px 8px rgba(11,132,132,0.25);
    }
    .btn-back {
      background: none; border: none; color: var(--white);
      font-size: 28px; line-height: 1; cursor: pointer;
      padding: 8px 10px; display: none; flex: none;
    }
    .header-title {
      flex: 0 1 auto; min-width: 0; max-width: 38%; font-size: 11px; font-weight: 700;
      text-transform: uppercase; letter-spacing: 1.2px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .header-brand { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 0 1 auto; }
    .header-logo { height: 42px; width: auto; object-fit: contain; display: block; flex: none; }
    .header-sep { width: 1px; height: 30px; background: rgba(255,255,255,0.28); flex: none; }
    .header-ctx { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
    .header-ctx[hidden] { display: none; }
    .header-ctx small { font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; }
    .header-ctx strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
    .header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: nowrap; margin-left: auto; }
    .header-icon-btn {
      background: none; border: none; color: var(--white);
      cursor: pointer; padding: 6px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    .header-icon-btn:active { background: rgba(255,255,255,0.15); }
    .header-eye { width: 36px; height: 36px; padding: 0; background: rgba(255,255,255,0.14); transition: background .15s; }
    .header-eye:hover { background: rgba(255,255,255,0.24); }
    .header-conta { display: flex; align-items: center; }
    .header-user {
      display: flex; align-items: center; gap: 10px; background: none; border: none; color: var(--white);
      cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; transition: background .15s;
    }
    .header-user:hover, .header-user[aria-expanded="true"] { background: rgba(255,255,255,0.14); }
    .header-av {
      width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
      background: var(--white); color: var(--primary-ink); font-size: 13px; font-weight: 700; letter-spacing: 0.3px;
      box-shadow: 0 0 0 2px var(--gold);
    }
    .header-user-txt { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; text-align: left; }
    .header-user-txt #header-nome-medico { font-size: 13px; font-weight: 600; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-user-txt small { font-size: 12px; font-weight: 500; }
    .header-user-txt small:empty { display: none; }
    .header-chev { flex: none; transition: transform .15s; }
    .header-user[aria-expanded="true"] .header-chev { transform: rotate(180deg); }
    .header-menu {
      position: absolute; right: 20px; top: 100%; margin-top: 6px; width: 240px; padding: 6px;
      background: var(--white); color: var(--text); border-radius: 12px;
      box-shadow: 0 12px 32px rgba(21,48,47,0.22), 0 0 0 1px rgba(21,48,47,0.08);
    }
    .header-menu[hidden] { display: none; }
    /* Identidade no topo do menu: só no celular, onde o cabeçalho não tem espaço para o nome. */
    .header-menu-quem { display: none; padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); line-height: 1.3; }
    .header-menu-quem strong { display: block; font-size: 14px; font-weight: 600; }
    .header-menu-quem span { font-size: 12px; color: var(--text-muted); }
    .header-menu-item {
      display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none; border-radius: 8px;
      background: none; color: var(--text); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
    }
    .header-menu-item svg { color: var(--text-muted); flex: none; }
    .header-menu-item:hover, .header-menu-item:focus-visible { background: var(--neutro-d); }

    /* Celular: só logo, clínica, olho e avatar. Nome e especialidade ficam no menu. */
    @media (max-width: 599px) {
      .header { gap: 8px; padding: env(safe-area-inset-top) 10px 0 12px; }
      .header-brand { gap: 8px; }
      .header-logo { height: 34px; }
      .header-sep, .header-ctx small, .header-user-txt, .header-chev { display: none; }
      .header-ctx strong { font-size: 14px; max-width: 34vw; }
      .btn-back[style*="block"] ~ .header-brand .header-ctx { display: none; }
      .header-menu { right: 10px; }
      .header-menu-quem { display: block; }
    }

    /* ─── BOTÃO CRESCIMENTO (web-only, oculto no mobile) ─── */
    .btn-crescimento {
      display: flex;
      align-items: center; gap: 8px;
      padding: 10px 18px; margin: 0 12px 12px;
      background: var(--primary);
      color: var(--white); border: none; border-radius: 10px;
      font-family: inherit; font-size: 14px; font-weight: 600;
      cursor: pointer; text-decoration: none;
      transition: opacity 0.15s;
    }
    .btn-crescimento:hover  { opacity: 0.88; }
    .btn-crescimento:active { opacity: 0.75; }

    /* ─── CONTEÚDO ─── */
    .content {
      padding-top: var(--header-offset);
      padding-bottom: calc(var(--nav-h) + 4px);
      min-height: 100vh;
    }

    /* ─── BOTTOM NAV ─── */
    .bottom-nav {
      background: var(--white);
      border-top: 1px solid var(--border);
      height: var(--nav-h);
      display: flex;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 200;
    }
    .nav-tab {
      flex: 1; background: none; border: none; cursor: pointer;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 3px; color: var(--text-sub);
      font-size: 11px; font-weight: 600;
      letter-spacing: .6px; text-transform: uppercase;
      transition: color .2s;
      position: relative;
    }
    .nav-tab.active { color: var(--primary-ink); }
    .nav-tab.active::after {
      content: '';
      position: absolute;
      top: 0; left: 20%; right: 20%;
      height: 3px;
      background: var(--primary);
      border-radius: 0 0 4px 4px;
    }
    .nav-tab svg { width: 22px; height: 22px; }

    /* ─── VIEWS ─── */
    .view { display: none; }
    .view.active { display: block; }

    /* ─── SEARCH BAR ─── */
    .search-wrap {
      padding: 10px 14px 8px;
      background: var(--white);
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: var(--header-offset);
      z-index: 10;
    }
    .search-inner { position: relative; }
    .search-inner svg {
      position: absolute; left: 11px; top: 50%;
      transform: translateY(-50%);
      color: var(--text-sub); width: 17px; height: 17px;
      pointer-events: none;
    }
    .search-input {
      width: 100%; padding: 9px 14px 9px 36px;
      border: 1px solid var(--border);
      border-radius: 20px;
      font-size: 14px; background: var(--bg); outline: none;
      color: var(--text);
    }
    .search-input:focus { border-color: var(--primary); }

    /* ─── LISTAS ─── */
    .list-card {
      background: var(--white);
      margin: 10px 12px;
      border-radius: 12px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .list-item {
      display: flex; align-items: center;
      padding: 13px 14px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      transition: background .12s;
    }
    .list-item:last-child { border-bottom: none; }
    .list-item:active { background: var(--primary-light); }

    .avatar {
      width: 38px; height: 38px; border-radius: 50%;
      background: var(--gold);
      color: var(--white); font-size: 15px; font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; margin-right: 11px;
    }
    .item-body { flex: 1; min-width: 0; }
    .item-title {
      font-size: 14px; font-weight: 600;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .item-sub {
      font-size: 12px; color: var(--text-sub);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      margin-top: 2px;
    }
    .item-right { text-align: right; flex-shrink: 0; margin-left: 10px; }
    .item-value { font-size: 14px; font-weight: 700; color: var(--primary-ink); }
    .item-date  { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
    .chevron { color: var(--line); margin-left: 6px; flex-shrink: 0; }

    /* ─── TAGS ─── */
    .tag {
      font-size: 12px; font-weight: 700;
      padding: 2px 7px; border-radius: 10px;
      flex-shrink: 0;
    }
    .tag-sim        { background: var(--green-light); color: var(--green); }
    .tag-nao        { background: var(--red-light);   color: var(--danger-text); }
    .tag-reconsulta { background: var(--border); color: var(--text-sub); }
    .tag-convenio   { background: var(--primary-light); color: var(--primary-ink); }
    .age-convenio   { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--primary-light); color: var(--primary-ink); font-size: 12px; font-weight: 700; }
    .conv-outro     { margin-top: 8px; }

    /* Status de assinatura e fatura (aba Assinatura, Configurações) — mesma
       paleta do back-office: trial/aberta = ouro, ativa/paga = verde,
       inadimplente/vencida = vermelho, cancelada = neutro. */
    .tag-trial, .tag-aberta       { background: #FDF3DD; color: var(--gold-dark); }
    .tag-ativa, .tag-paga         { background: var(--green-light); color: var(--green); }
    .tag-inadimplente, .tag-vencida { background: var(--red-light); color: var(--red); }
    .tag-cancelada                { background: var(--border); color: var(--text-sub); }

    /* ─── DETALHE ─── */
    .section-card {
      background: var(--white);
      margin: 10px 12px;
      border-radius: 12px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .section-header {
      padding: 11px 14px 9px;
      border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
    }
    .section-title {
      font-size: 11px; font-weight: 700;
      color: var(--primary-ink);
      text-transform: uppercase; letter-spacing: 1.2px;
    }
    .puer-lembrar { display: inline-flex; align-items: center; gap: 6px; color: var(--text) !important; white-space: nowrap; }
    .puer-lembrar-ico { display: inline-flex; color: #25D366; }
    .section-action {
      background: none; border: none;
      color: var(--primary-ink); font-size: 13px; font-weight: 600;
      cursor: pointer;
    }
    .detail-row {
      display: flex; align-items: center;
      padding: 11px 14px;
      border-bottom: 1px solid var(--border);
    }
    .detail-row:last-child { border-bottom: none; }
    .detail-label {
      font-size: 12px; color: var(--text-sub);
      width: 130px; flex-shrink: 0;
    }
    .detail-val {
      font-size: 14px; font-weight: 500; flex: 1;
    }
    .detail-val.highlight {
      font-size: 18px; font-weight: 700; color: var(--green);
    }
    .detail-val.danger { color: var(--danger-text); }
    /* Texto em verde escuro (5:1); só o ícone fica no verde do WhatsApp. */
    .detail-link {
      color: #1F7A4D; font-weight: 600; text-decoration: none;
      display: inline-flex; align-items: center; gap: 6px;
    }
    .detail-link svg { width: 14px; height: 14px; color: #25D366; }
    .detail-link:active { opacity: .7; }

    /* ─── FORMULÁRIOS ─── */
    .form-card {
      background: var(--white);
      margin: 10px 12px;
      border-radius: 12px;
      box-shadow: var(--shadow);
      overflow: visible;
    }
    .form-card-title { padding: 14px 14px 0; font-size: 13px; font-weight: 700; color: var(--text); }
    .form-card-sub   { padding: 2px 14px 4px; font-size: 12px; color: var(--text-sub); }
    .form-field {
      padding: 0 14px;
      border-bottom: 1px solid var(--border);
      position: relative;
    }
    .form-field:last-child { border-bottom: none; }
    .form-label {
      display: block;
      font-size: 11px; font-weight: 700;
      color: var(--primary-ink);
      text-transform: uppercase; letter-spacing: 1px;
      padding-top: 11px; margin-bottom: 3px;
    }
    .req::after { content: ' *'; color: var(--primary-ink); }
    .form-input, .form-select {
      width: 100%; border: none; outline: none;
      font-size: 15px; color: var(--text);
      padding: 2px 0 11px;
      background: transparent;
    }
    
    /* ─── CEP DROPDOWN ─── */
    .cep-dropdown {
      position: absolute;
      top: 100%;
      left: 0; right: 0;
      background: var(--white);
      border: 1px solid var(--primary);
      border-top: none;
      border-radius: 0 0 8px 8px;
      max-height: 200px;
      overflow-y: auto;
      z-index: 100;
      box-shadow: 0 4px 12px rgba(14,165,165,0.15);
    }
    .cep-item {
      padding: 11px 14px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      font-size: 13px;
      transition: background .12s;
    }
    .cep-item:last-child { border-bottom: none; }
    .cep-item:active { background: var(--primary-light); }
    .cep-item-rua { font-weight: 600; color: var(--text); }
    .cep-item-bairro { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
    
    .cep-status {
      font-size: 12px;
      padding: 6px 0;
      min-height: 18px;
      color: var(--text-sub);
    }
    .cep-status.loading::before {
      content: '⏳ ';
    }
    .cep-status.erro {
      color: var(--danger-text);
    }
    .cep-status.erro::before {
      content: '! ';
    }
    .cep-status.ok {
      color: var(--green);
    }
    .form-input::placeholder { color: var(--text-muted); }
    .dk-field { border: 1px solid var(--border) !important; border-radius: 8px !important; padding: 8px 12px !important; background: var(--white) !important; box-sizing: border-box; }
    .form-select { appearance: none; cursor: pointer; }

    /* Tipos de consulta configuráveis */
    .cfg-tipo-row { display: grid; grid-template-columns: 1fr 108px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
    .cfg-tipo-del {
      width: 34px; height: 34px; border: none; border-radius: 8px;
      background: var(--red-light); color: var(--danger-text);
      font-size: 20px; line-height: 1; cursor: pointer;
    }
    .cfg-tipo-del:hover { filter: brightness(0.96); }
    /* Teleconsulta: tipo fixo — nome travado, sem remover, valor editável */
    .cfg-tipo-row.fixo .cfg-tipo-nome {
      display: flex; align-items: center; gap: 8px; font-weight: 600;
      background: var(--primary-light); border-color: #BFE6E5; color: var(--primary-ink);
    }
    .cfg-tipo-fixo-tag { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
    .cfg-tipo-lock {
      width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
      background: var(--primary-light); color: var(--primary-ink);
    }
    .cfg-tipo-fixo-help { font-size: 12px; color: var(--text-sub); margin: -2px 0 10px; line-height: 1.4; }

    .form-check-row {
      display: flex; align-items: center; gap: 10px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
    }
    @media (max-width: 599px) {
      .age-barra select { flex: 1 1 100%; max-width: none !important; }
      .age-barra { gap: 6px !important; }
      .age-barra .btn { flex: 0 1 auto; padding: 0 10px !important; }
      .age-barra .btn:first-of-type { flex-grow: 1; }
    }
    @media (pointer: coarse), (max-width: 899px) { .age-barra .btn { min-height: 44px !important; } }
    /* Agenda: consultas canceladas, recolhidas no fim da Lista */
    .age-canceladas-btn { display: inline-flex; align-items: center; gap: 8px; border: none; background: none; padding: 6px 2px; font: 600 13px 'Hanken Grotesk', sans-serif; color: var(--text-sub); cursor: pointer; }
    .age-canceladas-btn:hover { color: var(--text); }
    .age-canceladas-seta { display: inline-block; transition: transform .15s; }
    .age-canceladas.aberto .age-canceladas-seta { transform: rotate(90deg); }
    .age-canceladas:not(.aberto) .age-trow { display: none; }
    .age-canceladas-cards.aberto .age-canceladas-seta { transform: rotate(90deg); }
    .age-canceladas-cards:not(.aberto) > :not(.age-canceladas-btn) { display: none; }
    @media (prefers-reduced-motion: reduce) { .age-canceladas-seta { transition: none; } }
    /* Bloqueio de agenda: para quais profissionais */
    .blq-medicos { border: 1px solid var(--border); border-radius: 10px; max-height: 232px; overflow: auto; background: var(--white); }
    .blq-medicos .form-check-row { padding: 10px 12px; }
    .blq-medicos .form-check-row:last-child { border-bottom: none; }
    .blq-medicos .blq-todos { font-weight: 600; background: var(--bg); }
    .form-check-row input[type="checkbox"],
    .form-check-row input[type="radio"] {
      width: 18px; height: 18px; accent-color: var(--primary);
      cursor: pointer; flex-shrink: 0;
    }
    .form-check-label {
      font-size: 14px; color: var(--text); line-height: 1.3;
      cursor: pointer; user-select: none;
    }

    /* Resumo do tomador da NF no cadastro do paciente */
    .nf-resumo {
      font-size: 13px; line-height: 1.5;
      padding: 10px 12px; border-radius: 8px;
      background: var(--bg); border: 1px solid var(--border);
      color: var(--text-sub);
    }
    .nf-resumo b { color: var(--text); }
    .nf-resumo.nf-resumo-alerta {
      background: #fffbeb; border-color: #fcd34d; color: #92400e;
    }
    .nf-resumo.nf-resumo-alerta b { color: #92400e; }

    .toggle-row { display: flex; padding: 10px 0; gap: 0; }
    .toggle-opt {
      flex: 1; padding: 10px 6px;
      border: 2px solid var(--border);
      background: var(--bg);
      cursor: pointer; font-size: 14px; font-weight: 700;
      transition: all .18s; color: var(--text-sub);
    }
    .toggle-opt:first-child { border-radius: 8px 0 0 8px; }
    .toggle-opt:last-child  { border-radius: 0 8px 8px 0; border-left: none; }
    .toggle-opt.on { background: var(--primary); border-color: var(--primary); color: var(--white); }

    .form-btns {
      display: flex; justify-content: flex-end;
      padding: 14px 12px;
    }
    .btn-row {
      display: inline-grid;
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      gap: 10px;
    }
    .btn {
      padding: 10px 18px; border: none;
      border-radius: 10px; font-size: 14px; font-weight: 600;
      cursor: pointer; transition: opacity .15s; font-family: inherit;
    }
    .btn:active { opacity: .78; }
    .btn-primary   { background: var(--primary); color: var(--white); }
    .btn-secondary { background: var(--bg); color: var(--text-sub); border: 1px solid var(--border); }
    .btn-danger    { background: var(--red-light); color: var(--danger-text); }
    .btn-orange    { background: var(--orange); color: var(--white); }
    .btn-orange:hover { background: var(--orange-dark); }
    .btn-blue      { background: var(--blue); color: var(--white); }
    .btn-blue:hover { background: var(--blue-dark); }
    .btn-green     { background: var(--green); color: var(--white); }
    .btn-green:hover { background: #3a9e6a; }

    /* ─── RESULTADOS ─── */
    .summary-grid {
      display: grid; grid-template-columns: 1fr 1fr;
      gap: 10px; padding: 12px;
    }
    .sum-card {
      background: var(--white);
      border-radius: 12px; padding: 14px 12px;
      box-shadow: var(--shadow);
    }
    .sum-label { font-size: 11px; color: var(--text-sub); text-transform: uppercase; letter-spacing: .9px; font-weight: 600; margin-bottom: 5px; }
    .sum-val   { font-size: 20px; font-weight: 800; color: var(--primary-ink); }
    .sum-val.green { color: var(--green); }

    .results-table { width: 100%; border-collapse: collapse; }
    .results-table thead th {
      background: var(--primary); color: var(--white);
      padding: 9px 10px; font-size: 11px; font-weight: 700;
      text-align: right;
    }
    .results-table thead th:first-child { text-align: left; }
    .results-table tbody td {
      padding: 10px 10px; font-size: 12px;
      border-bottom: 1px solid var(--border);
      text-align: right;
    }
    .results-table tbody td:first-child { text-align: left; font-weight: 600; font-size: 13px; }
    .results-table tbody tr:nth-child(even) { background: var(--border); }

    /* ─── PORTAL FINANCEIRO ─── */
    .fin-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .fin-kpi-full { grid-column: 1 / -1; }
    @media (min-width: 600px) {
      .fin-kpi-grid { grid-template-columns: repeat(3, 1fr); }
      .fin-kpi-full { grid-column: auto; }
    }
    .fin-kpi { background: var(--white); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
    .fin-kpi-lbl { font-size: 11px; color: var(--text-sub); text-transform: uppercase; letter-spacing: .9px; font-weight: 600; margin-bottom: 4px; }
    .fin-kpi-val { font-size: 18px; font-weight: 800; color: var(--primary-ink); line-height: 1.2; }
    .fin-kpi-val.neg { color: var(--danger-text); }
    .fin-kpi-val.pos { color: var(--green); }
    .fin-kpi-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
    .fin-section-hdr { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
    .fin-section-lbl { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
    .desp-list { display: flex; flex-direction: column; gap: 6px; }
    .desp-item { background: var(--white); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
    .desp-cat { font-size: 12px; font-weight: 700; background: var(--border); color: var(--primary-dark); border-radius: 20px; padding: 2px 8px; white-space: nowrap; }

    .fid-badge-ok { background:#e7f8ef; color:#1e8e5a; font-size:12px; font-weight:700; border-radius:20px; padding:1px 8px; white-space: nowrap; }
    .desp-val { font-size: 14px; font-weight: 700; color: var(--danger-text); white-space: nowrap; }
    .desp-del { background: none; border: none; cursor: pointer; color: var(--text-sub); padding: 4px; border-radius: 6px; line-height: 1; }
    .desp-del:hover { color: var(--danger-text); background: var(--red-light); }
    .rec-list  { display: flex; flex-direction: column; gap: 6px; }
    .rec-item  { background: var(--white); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
    .rec-cat   { font-size: 12px; font-weight: 700; background: var(--green-light); color: #166534; border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
    .rec-val   { font-size: 14px; font-weight: 700; color: var(--green); white-space: nowrap; }
    .rec-del   { background: none; border: none; cursor: pointer; color: var(--text-sub); padding: 4px; border-radius: 6px; line-height: 1; }
    .rec-del:hover { color: var(--green); background: var(--green-light); }
    /* Linha de receita/despesa (a mesma nas duas telas). Computador: categoria, data,
       descrição, valor e ícones, em colunas que alinham de uma linha para outra.
       Celular: categoria + data + ícones em cima; descrição + valor embaixo. */
    .lanc { display: grid; align-items: center; column-gap: 12px;
      grid-template-columns: 176px 92px minmax(0, 1fr) auto auto; grid-template-areas: "tag data desc valor acoes"; }
    .lanc > .desp-cat, .lanc > .rec-cat { grid-area: tag; justify-self: start; }
    .lanc-data { grid-area: data; font-size: 12px; color: var(--text-sub); white-space: nowrap; }
    .lanc-desc { grid-area: desc; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
    .lanc > .desp-val, .lanc > .rec-val { grid-area: valor; justify-self: end; text-align: right; min-width: 112px; }
    .lanc-acoes { grid-area: acoes; display: flex; gap: 2px; }
    @media (max-width: 899px) {
      .lanc { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 6px; padding: 12px 14px;
        grid-template-areas: "tag data acoes" "desc desc valor"; }
      .lanc > .desp-val, .lanc > .rec-val { min-width: 0; font-size: 15px; }
      .lanc-desc { padding-right: 10px; }
    }
    .rec-cat-barra { background: var(--green-light); border-radius:4px; height:6px; margin-top:5px; overflow:hidden; }
    .rec-cat-barra-fill { background: var(--green); height:100%; border-radius:4px; transition:width .3s; }
    .desp-overlay { z-index: 450; align-items: flex-end; }
    @media (min-width: 600px) { .desp-overlay { align-items: center; } }
    .var-sobe   { color: var(--green); font-size: 12px; font-weight: 600; margin-top: 4px; }
    .var-desce  { color: var(--danger-text); font-size: 12px; font-weight: 600; margin-top: 4px; }
    .var-neutro { color: var(--text-sub); font-size: 12px; font-weight: 500; margin-top: 4px; }

    /* ─── FILTROS CONSULTAS ─── */
    .filtros-bar {
      background: var(--white);
      border-bottom: 1px solid var(--border);
      padding: 8px 12px;
      display: flex; gap: 8px; align-items: center;
      flex-wrap: wrap;
      position: sticky; top: var(--header-offset); z-index: 10;
    }
    .filtro-select {
      border: 1px solid var(--border); border-radius: 20px;
      padding: 6px 12px; font-size: 13px; font-weight: 500;
      background: var(--bg); color: var(--text);
      cursor: pointer; outline: none; appearance: none;
      flex: 1; min-width: 120px;
    }
    .filtro-select:focus { border-color: var(--primary); }
    .filtro-btn {
      border: 1.5px solid var(--border); border-radius: 20px;
      padding: 6px 14px; font-size: 13px; font-weight: 600;
      background: var(--bg); color: var(--text-sub);
      cursor: pointer; white-space: nowrap;
    }
    .filtro-btn.ativo { background: var(--primary); border-color: var(--primary); color: var(--white); }
    .totais-bar {
      display: flex; gap: 10px; padding: 8px 12px;
      background: var(--bg);
    }
    .totais-chip {
      flex: 1; background: var(--white);
      border-radius: 10px; padding: 8px 12px;
      box-shadow: var(--shadow); text-align: center;
    }
    .totais-chip-label { font-size: 11px; color: var(--text-sub); text-transform: uppercase; letter-spacing: .7px; font-weight: 600; }
    .totais-chip-val   { font-size: 15px; font-weight: 800; color: var(--primary-ink); margin-top: 2px; }
    .totais-chip-val.green { color: var(--green); }

    /* ─── DETALHE PACIENTE ─── */
    .pac-perfil-card { display:flex; align-items:center; gap:14px; padding:16px; background:var(--white); border-bottom:1px solid var(--border); margin-bottom:12px; }
    .pac-avatar { width:52px; height:52px; border-radius:50%; background:var(--gold); color:var(--white); font-size:24px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
    .pac-perfil-info { flex:1; min-width:0; }
    .pac-perfil-nome-linha { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
    .pac-perfil-nome { font-size:18px; font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
    .pac-perfil-sub { font-size:13px; color:var(--text-sub); margin-top:3px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
    .pac-faltas-badge { background:var(--red-light); color:var(--danger-text); font-size:12px; font-weight:700; border-radius:20px; padding:1px 8px; }
    .pac-cancel-badge { background:#fef3c7; color:#b45309; font-size:12px; font-weight:700; border-radius:20px; padding:1px 8px; }

    /* ─── FINANCEIRO MENSAL ─── */
    /* Ano e mês na MESMA linha, em qualquer tela (quebra só se faltar largura). */
    .fin-periodo { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:4px 16px; }
    .fin-periodo .ano-nav, .fin-periodo .fin-mes-nav { margin:0; padding:0; gap:4px; }
    .fin-periodo .ano-btn, .fin-periodo .fin-mes-arrow { min-width:36px; padding:4px 2px; }
    @media (max-width: 599px) {
      .fin-periodo { gap:4px 8px; }
      .fin-periodo .fin-ano-chip { padding:5px 12px; }
      .fin-periodo .fin-mes-label { min-width:78px; }
    }
    .fin-mes-nav { display:flex; align-items:center; justify-content:center; gap:6px; padding:2px 12px 4px; }
    .fin-ano-chip { border:1.5px solid var(--border); border-radius:20px; padding:5px 18px; font-size:13px; font-weight:700; color:var(--text-sub); background:var(--white); cursor:pointer; transition:all .15s; white-space:nowrap; }
    .fin-ano-chip:hover { border-color:var(--primary); color: var(--primary-ink); }
    .fin-ano-chip.ativo { background:var(--primary); border-color:var(--primary); color:var(--white); }
    .fin-mes-arrow { background:none; border:none; cursor:pointer; color: var(--primary-dark); font-size:20px; padding:4px 6px; border-radius:6px; line-height:1; }
    .fin-mes-arrow:disabled { opacity:.3; cursor:default; }
    .fin-mes-label { font-size:15px; font-weight:700; color:var(--text); min-width:90px; text-align:center; }
    .fin-mes-label.muted { color:var(--text-sub); font-weight:400; }
    .desp-cat-barra { background:var(--primary-light); border-radius:4px; height:6px; margin-top:5px; overflow:hidden; }
    .desp-cat-barra-fill { background:var(--primary); height:100%; border-radius:4px; transition:width .3s; }

    /* ─── CONFIG DESKTOP ─── */
    .cfg-page { padding: 16px; }
    .cfg-section-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
    /* overflow-y: hidden é obrigatório aqui. Declarar só `overflow-x: auto`
       faz o navegador resolver o eixo Y para `auto` também, e como os
       .cfg-tab usam margin-bottom:-2px para cobrir a borda, o conteúdo passa
       2px da caixa: o Windows então desenha uma BARRA DE ROLAGEM VERTICAL na
       direita da barra de abas — as duas setinhas que pareciam um campo
       numérico perdido. A rolagem horizontal é intencional, para caber as
       abas em tela estreita; a vertical é acidente. */
    .cfg-tab-bar { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; }
    .cfg-tab { padding: 8px 14px; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; background: none; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-sub); cursor: pointer; white-space: nowrap; }
    .cfg-tab.ativo { color: var(--primary-ink); border-bottom-color: var(--primary); }
    .cfg-card { background: var(--white); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
    .cfg-card-title { font-size: 11px; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
    .cfg-field { margin-bottom: 14px; }
    .cfg-field:last-child { margin-bottom: 0; }
    .cfg-field label { font-size: 11px; font-weight: 600; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 6px; }
    .cfg-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; background: var(--white); color: var(--text); box-sizing: border-box; font-family: inherit; transition: border-color .15s; appearance: auto; }
    .cfg-input:focus { border-color: var(--primary); }
    textarea.cfg-input { resize: vertical; }
    .cfg-row { display: flex; gap: 10px; }
    .cfg-row .cfg-field { flex: 1; margin-bottom: 0; }
    .cfg-hint { font-size: 12px; color: var(--text-sub); margin-top: 5px; }
    /* Checkbox com texto de apoio, no ritmo vertical dos .cfg-field */
    .cfg-check { margin: 4px 0 14px; }
    .cfg-check label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
    .cfg-check input[type="checkbox"] {
      width: 18px; height: 18px; margin: 0;
      accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
    }
    /* line-height igual a altura do box alinha a caixa com a 1a linha do texto */
    .cfg-check-title { display: block; font-size: 14px; line-height: 18px; color: var(--text); user-select: none; }
    .cfg-check .cfg-hint { display: block; margin-top: 4px; }
    /* Eco da data por extenso, abaixo dos campos type="date" */
    .eco-data { font-size: 12px; color: var(--text-sub); margin-top: 5px; }
    .eco-data:empty { display: none; }
    .form-field .eco-data { margin-top: 2px; padding-bottom: 10px; }
    .form-input.tem-eco { padding-bottom: 3px; }
    /* Configurações: o MESMO layout em qualquer tela. As colunas quebram sozinhas
       conforme a largura (auto-fit); não há versão própria para o celular. */
    @media (min-width: 600px) { .cfg-page { padding: 28px 32px; max-width: 1000px; margin: 0 auto; } }
      .cfg-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
      /* align-items:start — sem isso todo card estica até a altura do mais
         alto da linha, e o de Notificações de Puericultura, com um campo só,
         ficava do tamanho do card de endereço inteiro, com metade vazia. */
      .cfg-main-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
      /* Coluna do grid: empilha cards com altura independente da outra coluna */
      .cfg-col { display: flex; flex-direction: column; gap: 20px; }
      .cfg-bottom-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; margin-bottom: 20px; }
      .cfg-card { margin-bottom: 0; }
      .cfg-tab-bar { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
      .cfg-tab { padding: 9px 18px; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; background: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-sub); cursor: pointer; border-radius: 6px 6px 0 0; transition: color .15s; }
      .cfg-tab:hover { color: var(--text); }
      .cfg-tab.ativo { color: var(--primary-ink); border-bottom-color: var(--primary); background: var(--primary-light); }
      .cfg-modelos-left { display: flex; flex-direction: column; gap: 10px; }
      #modelos-editor.modelos-editor-open { display: flex !important; flex-direction: column; gap: 10px; margin-top: 0 !important; }
      .cfg-hdr-btns { display: flex; gap: 8px; }
      .cfg-section-title { flex-wrap: wrap; gap: 10px; }
      /* card modelos full-width 2 colunas */
      .cfg-card-modelos { grid-column: 1 / -1; }
      .cfg-modelos-layout { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 0; min-height: 340px; margin-top: 4px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
      .cfg-modelos-sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--bg); }
      .cfg-modelos-add-btn { margin: 10px; padding: 8px 12px; background: var(--primary); color: var(--white); border: none; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }
      .cfg-modelos-add-btn:hover { filter: brightness(.93); }
      .cfg-modelos-lista { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding: 0 6px 10px; }
      .cfg-modelo-item { text-align: left; background: none; border: none; border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      .cfg-modelo-item:hover { background: var(--primary-light); color: var(--primary-ink); }
      .cfg-modelo-item.ativo { background: var(--primary); color: var(--white); }
      .cfg-modelos-editor { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
      .cfg-modelos-vazio { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-sub); text-align: center; }
    @media (max-width: 599px) {
      .cfg-modelos-layout { grid-template-columns: minmax(0, 1fr); }
      .cfg-modelos-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
      .cfg-modelos-lista { max-height: 168px; }
    }

    /* ─── PUERICULTURA ─── */
    .search-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
    .search-row .search-inner { flex:1 1 160px; }
    .filter-fab {
      flex-shrink:0; width:42px; height:42px; border-radius:50%;
      border:1.5px solid var(--border); background:var(--bg); color:var(--text-sub);
      display:flex; align-items:center; justify-content:center;
      cursor:pointer; position:relative;
    }
    .filter-fab.ativo { background:var(--primary); border-color:var(--primary); color:var(--white); }
    .filter-badge {
      position:absolute; top:-3px; right:-3px;
      background:var(--primary); color:var(--white); border-radius:50%;
      width:17px; height:17px; font-size:12px; font-weight:700;
      display:none; align-items:center; justify-content:center;
    }
    .filter-badge.vis { display:flex; }
    .sheet-handle { width:38px; height:4px; background:var(--border); border-radius:4px; margin:0 auto 16px; }
    .puer-sheet { background:var(--white); border-radius:20px 20px 0 0; padding:16px 16px 36px; width:100%; }
    .puer-sheet-title { font-size:16px; font-weight:700; margin-bottom:14px; text-align:center; }
    .puer-sheet-subtitle { font-size:12px; font-weight:700; color:var(--text-sub); text-transform:uppercase; letter-spacing:.5px; margin:16px 2px 8px; }
    .puer-sheet-subtitle:first-of-type { margin-top:0; }
    .puer-sheet-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
    .puer-sheet-card {
      border-radius:12px; padding:18px 12px;
      font-size:14px; font-weight:700; text-align:center;
      border:2.5px solid transparent; cursor:pointer;
    }
    .puer-sheet-card.ativo { border-color:currentColor; }
    .puer-sheet-limpar { background:var(--bg)!important; color:var(--text-sub)!important; }
    .puer-status { display:inline-block; border-radius:8px; padding:3px 9px; font-size:12px; font-weight:700; }
    /* Colunas de largura fixa: sem isso cada badge nasce do tamanho do seu
       próprio texto e a lista fica com uma serrilhada em vez de alinhada —
       o "% fiel" de uma linha começa num x, o da linha de baixo em outro. */
    .pac-badges { display:flex; align-items:center; flex-shrink:0; margin-left:6px; }
    .pac-badges-col { display:flex; justify-content:center; width:74px; flex-shrink:0; }
    /* Celular: as etiquetas descem para baixo do nome, em vez de tirar a largura
       dele (o nome aparecia cortado). No computador seguem em colunas à direita. */
    @media (max-width: 599px) {
      #lista-pacientes .list-item {
        display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 11px;
      }
      #lista-pacientes .avatar { grid-row: 1 / span 3; margin-right: 0; }
      #lista-pacientes .item-body { grid-column: 2; }
      #lista-pacientes .item-title { white-space: normal; overflow-wrap: anywhere; }
      #lista-pacientes .pac-badges { grid-column: 2; margin: 6px 0 0; gap: 6px; flex-wrap: wrap; }
      #lista-pacientes .pac-badges-col { width: auto; }
      #lista-pacientes .chevron { grid-column: 3; grid-row: 1 / span 3; margin-left: 0; }
    }
    .puer-em-dia    { background:#d1fae5; color:#065f46; }
    .puer-em-breve  { background:#fef3c7; color:#92400e; }
    .puer-atrasada  { background:var(--red-light); color:#991b1b; }
    .puer-notificado{ background:#dbeafe; color:#1d4ed8; }
    .puer-inativo   { background:#f3f4f6; color:var(--text-sub); }

    /* ─── NF TOGGLE ─── */
    .nf-toggle {
      border: none; border-radius: 10px; padding: 4px 9px;
      font-size: 12px; font-weight: 700; cursor: pointer;
      transition: all .15s; flex-shrink: 0;
    }
    .nf-toggle.sim  { background: var(--green-light); color: var(--green); }
    .nf-toggle.nao  { background: var(--red-light);   color: var(--danger-text); }
    .nf-toggle:active { opacity: .7; }

    /* ─── PACIENTE STATS ─── */
    .pac-stats { display: flex; gap: 4px 14px; margin-top: 3px; flex-wrap: wrap; align-items: center; }
    .pac-chip {
      font-size: 12px; color: var(--text-sub);
      display: flex; align-items: center; gap: 3px;
    }
    .pac-chip svg { width: 11px; height: 11px; }

    /* ─── ANO NAV (Resultados) ─── */
    .ano-nav {
      display: flex; align-items: center; justify-content: center;
      gap: 16px; padding: 10px 12px 2px;
    }
    .ano-btn {
      background: none; border: none; cursor: pointer;
      color: var(--primary-dark); font-size: 24px; line-height: 1;
      padding: 4px 8px; border-radius: 8px;
    }
    .ano-btn:active { background: var(--red-light); }
    .ano-label { font-size: 18px; font-weight: 800; color: var(--text); }

    /* ─── LOADING / EMPTY ─── */
    .loading, .empty {
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      padding: 56px 20px; color: var(--text-sub);
      text-align: center;
    }
    .spinner {
      width: 34px; height: 34px;
      border: 3px solid var(--border);
      border-top-color: var(--primary);
      border-radius: 50%;
      animation: spin .75s linear infinite;
      margin-bottom: 12px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    /* Depois de 6 s sem resposta, o "Carregando…" ganha uma segunda linha. Só CSS:
       fica escondida (visibility, que também esconde de leitor de tela) e aparece
       sozinha — sem timer no JavaScript. */
    .loading-demora { visibility: hidden; opacity: 0; margin-top: 8px; font-size: 12px; max-width: 260px; color: var(--text-sub);
      animation: demora-aparece .3s ease 6s forwards; }
    @keyframes demora-aparece { to { visibility: visible; opacity: 1; } }
    .empty-icon { margin-bottom: 10px; color: var(--text-sub); opacity: .55; line-height: 0; }
    .empty-icon svg { width: 44px; height: 44px; }
    .empty .btn { margin-top: 14px; }
    .empty-txt  { font-size: 14px; }

    /* ─── SPLASH LOADING ─── */
    #splash-overlay {
      position: fixed; inset: 0; z-index: 9999;
      background: var(--primary);
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 32px;
      transition: opacity .35s ease;
    }
    #splash-overlay.hide {
      opacity: 0; pointer-events: none;
    }
    #splash-logo {
      height: 72px; object-fit: contain;
    }
    .splash-spinner {
      width: 28px; height: 28px; border-radius: 50%;
      border: 3px solid rgba(255,255,255,.3);
      border-top-color: var(--white);
      animation: spin .8s linear infinite;
    }

    /* ─── TOAST ─── */
    .toast {
      position: fixed;
      bottom: calc(var(--nav-h) + 72px);
      left: 50%; transform: translateX(-50%) translateY(10px);
      background: #323232; color: var(--white);
      padding: 11px 20px; border-radius: 8px;
      font-size: 13px; font-weight: 500;
      opacity: 0; transition: all .25s;
      /* Acima de .overlay (600) e .age-overlay (500): o toast e quase sempre o
         resultado de uma acao feita DENTRO de um modal, e em 500 ele aparecia
         atras do proprio dialogo que o disparou -- a recusa existia e ninguem
         via, que e como um "nada acontece" nasce. */
      z-index: 700; white-space: nowrap;
      pointer-events: none;
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    .toast.ok  { background: #2E7D32; }
    #offline-banner {
      position: fixed;
      top: calc(var(--header-offset, 56px) + 8px);
      left: 50%; transform: translateX(-50%);
      display: none; align-items: center; gap: 8px;
      background: #B45309; color: var(--white);
      padding: 9px 16px; border-radius: 8px;
      font-size: 13px; font-weight: 600;
      z-index: 480; max-width: calc(100vw - 24px);
      box-shadow: 0 2px 10px rgba(0,0,0,.25);
    }
    #offline-banner.show { display: flex; }
    .toast.err { background: #B71C1C; }

    /* ─── CONFIRM SHEET ─── */
    .overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.48);
      z-index: 600; display: none;
      align-items: flex-end; justify-content: center;
    }
    .overlay.open { display: flex; }

    /* ─── Receituário Memed — painel sobre o VictaPro (modo Incorporado) ───
       Fechado, o painel fica FORA da vista, mas com layout: a Memed mede o
       contêiner quando carrega, e em display:none ele mede zero. */
    .rx-overlay {
      position: fixed; inset: 0;
      background: rgba(21,48,47,.35);
      z-index: 500; display: flex;
      align-items: center; justify-content: center;
      padding: 0;
      visibility: hidden; opacity: 0; pointer-events: none;
      transition: opacity .15s;
    }
    .rx-overlay.open { visibility: visible; opacity: 1; pointer-events: auto; }
    /* Fechado, NADA do painel pode receber clique — nem o que a Memed desenhar
       lá dentro, com position:fixed, visibility:visible ou pointer-events:auto
       próprios. Fora da vista (a transformação também prende os fixed dela) e
       forçado em todos os descendentes. Foi isto que travou o app depois de
       fechar o receituário: um elemento invisível cobrindo a tela. */
    .rx-overlay:not(.open) { transform: translateX(-150vw); }
    .rx-overlay:not(.open), .rx-overlay:not(.open) * { pointer-events: none !important; visibility: hidden !important; }
    .rx-modal {
      background: var(--white);
      width: 100%; height: 100%;
      display: flex; flex-direction: column;
      overflow: hidden;
    }
    #memed-prescricao { min-width: 820px; min-height: 700px; }
    @media (prefers-reduced-motion: reduce) { .rx-overlay { transition: none; } }
    .rx-head {
      display: flex; align-items: center; gap: 10px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      flex: 0 0 auto;
    }
    .rx-title { font-weight: 700; font-size: 16px; color: var(--text); }
    .rx-env {
      font-size: 11px; font-weight: 700; text-transform: uppercase;
      letter-spacing: .04em; color: var(--gold);
      border: 1px solid var(--gold); border-radius: 999px; padding: 1px 8px;
    }
    .rx-close {
      margin-left: auto; border: none; background: transparent;
      font-size: 24px; line-height: 1; color: var(--text-sub);
      cursor: pointer; padding: 4px 8px; border-radius: 8px;
    }
    .rx-close:hover { background: var(--bg); }
    .rx-host { flex: 1 1 auto; position: relative; overflow: auto; }
    .rx-host iframe { width: 100%; height: 100%; border: 0; display: block; }
    .rx-msg[hidden] { display: none; }   /* sem isto o display:flex abaixo vence o hidden e a camada vazia cobre a Memed */
    .rx-msg {
      position: absolute; inset: 0; display: flex; flex-direction: column;
      align-items: center; justify-content: center; text-align: center;
      padding: 28px; color: var(--text-sub); font-size: 14px; line-height: 1.6;
    }
    @media (min-width: 700px) {
      .rx-overlay { padding: 24px; }
      .rx-modal { max-width: min(980px, 96vw); max-height: min(92vh, 860px); border-radius: 16px; box-shadow: 0 18px 50px rgba(21,48,47,.28); }
    }

    /* ─── Teleconsulta ─── */
    :root { --tele-w: clamp(320px, 30vw, 420px); }
    .tele-dock {
      position: fixed; z-index: 450;
      top: calc(var(--header-offset) + 14px); right: 16px;
      width: var(--tele-w);
      background: #0F2A2B; color: #E6F2F2;
      border-radius: 16px; overflow: hidden;
      box-shadow: 0 18px 50px rgba(21,48,47,.25);
      display: flex; flex-direction: column;
    }
    .tele-dock[hidden] { display: none; }
    /* O vídeo flutua acima de tudo (Memed, Medidas…) — mesmo elemento, só CSS:
       mover o iframe no DOM o recarregaria e derrubaria a chamada. */
    .tele-dock.flutuante { top: auto; bottom: 16px; width: 320px; z-index: 2147483000; outline: 2px solid rgba(255,255,255,.3); }
    body.tele-on.tele-ao-lado .content { padding-right: calc(var(--tele-w) + 28px); }
    .tele-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
    .tele-dock.flutuante .tele-bar { cursor: move; user-select: none; }
    .tele-live { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .tele-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
    .tele-live.ao-vivo .tele-dot { background: #FF5A5F; }
    .tele-tools { display: inline-flex; align-items: center; gap: 6px; }
    .tele-chip {
      display: inline-flex; align-items: center; gap: 5px; border: none; cursor: default;
      background: rgba(255,255,255,.12); color: #E6F2F2; border-radius: 999px;
      padding: 4px 10px; font: 600 11px 'Hanken Grotesk', sans-serif; white-space: nowrap;
    }
    button.tele-chip { cursor: pointer; }
    button.tele-chip:hover { background: rgba(255,255,255,.2); }
    .tele-chip[hidden] { display: none; }
    body.tele-on .dk-float-nav { display: none !important; }
    .tele-chip svg { width: 13px; height: 13px; }
    .tele-redock { display: none; padding: 4px 7px; }
    .tele-dock.flutuante .tele-redock { display: inline-flex; }
    .tele-dock.flutuante .tele-norec { display: none; }
    .tele-stage { position: relative; height: calc(var(--tele-w) * .92); background: #0B2122; }
    .tele-dock.flutuante .tele-stage { height: 250px; }
    .tele-frame-host { position: absolute; inset: 0; }
    .tele-frame-host iframe { width: 100%; height: 100%; border: 0; display: block; }
    .tele-ov {
      position: absolute; left: 10px; right: 10px; bottom: 64px;
      background: rgba(15,42,43,.94); border: 1px solid rgba(255,255,255,.12);
      border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px;
    }
    .tele-ov[hidden] { display: none; }
    .tele-ov-t { font-size: 14px; font-weight: 700; color: var(--white); line-height: 1.35; }
    .tele-ov-s { font-size: 12px; opacity: .85; }
    .tele-ov-b { width: 100%; }
    .tele-ov-row { display: flex; gap: 8px; flex-wrap: wrap; }
    .tele-ov-l { background: rgba(255,255,255,.12); color: var(--white); border: none; border-radius: 8px; padding: 7px 10px; font: 600 12px 'Hanken Grotesk', sans-serif; cursor: pointer; }
    .tele-ov-l:hover { background: rgba(255,255,255,.2); }
    .tele-foot { background: var(--white); color: var(--text); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
    .tele-dock.flutuante .tele-info { display: none; }
    .tele-info { font-size: 12px; color: var(--text-sub); line-height: 1.45; display: flex; flex-direction: column; gap: 3px; }
    .tele-info b { color: var(--text); font-weight: 600; }
    .tele-ok { color: var(--green); font-weight: 700; }
    .tele-end { border: none; border-radius: 10px; background: #E5484D; color: var(--white); padding: 9px; font: 700 13px 'Hanken Grotesk', sans-serif; cursor: pointer; }
    .tele-end:hover { filter: brightness(.95); }
    .tele-fundo {
      position: absolute; right: 10px; top: 42px; z-index: 3; width: 286px;
      background: var(--white); color: var(--text); border-radius: 12px;
      box-shadow: 0 18px 50px rgba(21,48,47,.25); padding: 12px;
      display: flex; flex-direction: column; gap: 10px;
    }
    .tele-fundo[hidden] { display: none; }
    .tele-fundo-t { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-sub); }
    .tele-fundo-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .tele-fundo-opt {
      height: 52px; border: 2px solid #E1EAEA; border-radius: 10px; background: var(--bg);
      font: 700 10.5px 'Hanken Grotesk', sans-serif; color: var(--text-sub); cursor: pointer;
      display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; text-align: center;
    }
    .tele-fundo-opt.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
    .tele-fundo-opt.f-nenhum, .tele-fundo-opt.f-propria { align-items: center; padding-bottom: 0; }
    .tele-fundo-opt.f-desfocar { background: linear-gradient(135deg, #9FC3C1, #5E8C8B); color: var(--white); align-items: center; padding-bottom: 0; }
    .tele-fundo-opt.f-consultorio { background: linear-gradient(180deg, #F3EEE6 0 62%, #D9CFC0 62%); color: #6B5E4B; }
    .tele-fundo-opt.f-verde { background: linear-gradient(180deg, #CFE9E7 0 70%, #A9D3D0 70%); color: var(--primary-dark); }
    .tele-fundo-opt.f-neutro { background: linear-gradient(180deg, #EEF1F1 0 65%, #CDD5D5 65%); }
    .tele-fundo-opt.f-propria { border-style: dashed; color: var(--primary-dark); }
    .tele-fundo-n { font-size: 12px; color: var(--text-sub); line-height: 1.4; }
    .tele-fundo-trocar { background: none; border: none; color: var(--primary-dark); font: 600 12px 'Hanken Grotesk', sans-serif; cursor: pointer; padding: 0; text-align: left; }
    /* Agenda */
    .age-tipo-tele { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--primary-dark); }
    .age-tele-espera { display: inline-flex; align-items: center; gap: 6px; background: var(--green-light); color: var(--green-ink); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 3px 9px; white-space: nowrap; }
    .age-tele-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: agePulse 1.8s infinite; }
    @keyframes agePulse { 0% { box-shadow: 0 0 0 0 rgba(76,183,130,.55); } 70% { box-shadow: 0 0 0 7px rgba(76,183,130,0); } 100% { box-shadow: 0 0 0 0 rgba(76,183,130,0); } }
    .age-tele-btn { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--primary); background: var(--primary); color: var(--white); font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-family: inherit; white-space: nowrap; }
    .age-tele-btn.out { background: none; color: var(--primary-ink); }
    .age-tele-pc { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
    .age-tele-box { background: var(--primary-light); border-radius: 12px; padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
    .age-tele-box[hidden] { display: none; }
    .age-tele-box-t { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--primary-dark); }
    .age-tele-box-s { font-size: 12px; color: var(--text-sub); line-height: 1.45; }
    .age-tele-box-acts { display: flex; gap: 8px; flex-wrap: wrap; }
    .age-tele-box-acts[hidden] { display: none; }
    .age-tele-box-acts .btn { padding: 7px 12px; font-size: 13px; }
    /* Registro na consulta */
    .tl-badge-tele { background: var(--primary-light); color: var(--primary-ink); }
    .tele-reg dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; background: var(--primary-light); border-radius: 10px; padding: 10px 12px; }
    .tele-reg dt { color: var(--text-sub); }
    .tele-reg dd { margin: 0; font-weight: 500; }
    @media (max-width: 599px) { .tele-reg dl { grid-template-columns: 1fr; gap: 2px; } .tele-reg dd { margin-bottom: 6px; } }
    @media (prefers-reduced-motion: reduce) { .age-tele-pulse { animation: none; } }

    /* ─── Crescimento e Desenvolvimento — modal iframe ─── */
    .cresc-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,.55);
      z-index: 500; display: none;
      align-items: center; justify-content: center;
      padding: 0;
    }
    .cresc-overlay.open { display: flex; }
    .cresc-modal {
      background: var(--white);
      width: 100%; height: 100%;
      display: flex; flex-direction: column;
      overflow: hidden;
    }
    .cresc-head {
      display: flex; align-items: center;
      padding: 0 12px 0 16px; gap: 10px;
      height: 52px; flex-shrink: 0;
      background: var(--primary); color: var(--white);
    }
    .cresc-title { font-size: 15px; font-weight: 700; flex: 1; }
    .cresc-close {
      background: none; border: none; color: rgba(255,255,255,.85);
      font-size: 24px; line-height: 1; cursor: pointer;
      padding: 6px; border-radius: 6px;
    }
    .cresc-close:hover { background: rgba(255,255,255,.15); }
    @media (min-width: 700px) {
      .cresc-overlay { padding: 24px; }
      .cresc-modal { max-width: 960px; max-height: 92vh; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.25); }
    }

    .sheet {
      background: var(--white);
      border-radius: 20px 20px 0 0;
      padding: 22px 18px 36px;
      width: 100%;
    }
    .sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
    .sheet-msg   { font-size: 14px; color: var(--text-sub); margin-bottom: 20px; }
    .sheet-btns  { display: flex; flex-direction: column; gap: 10px; }

    /* ─── LOGIN ─── */
    #login-screen {
      position: fixed; inset: 0; z-index: 1000;
      background: var(--bg);
      display: flex; flex-direction: row;
    }
    .login-side {
      flex: 1; min-width: 0; overflow-y: auto;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      padding: 24px;
    }
    .login-forgot { text-align: right; margin: -6px 0 12px; }
    .login-forgot button {
      background: none; border: none; cursor: pointer; font-family: inherit;
      color: var(--primary-ink); font-size: 12.5px; font-weight: 600; padding: 6px 0;
    }
    .login-foot {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      margin-top: 18px; font-size: 12px; color: var(--text-muted);
    }
    /* painel de marca: no celular é só o fundo (degradê + marca d'água);
       em tela larga vira a metade esquerda */
    .login-pane {
      position: absolute; inset: 0; overflow: hidden; pointer-events: none;
      background: linear-gradient(155deg, #0B8484 0%, #0EA5A5 55%, #4CB782 130%);
    }
    .login-pane-brand { display: none; }
    .login-pane .login-pane-wm {
      position: absolute; right: -80px; bottom: -70px; width: 320px; height: 320px;
      opacity: .1; transform: rotate(-8deg);
    }
    .login-side { position: relative; z-index: 1; }
    /* logo e textos sobre o degradê: ícone branco, nome branco */
    .login-brand svg circle { fill: #fff; }
    .login-brand svg path:nth-of-type(1) { stroke: #0EA5A5; }
    .login-brand svg path:nth-of-type(2) { fill: #0EA5A5; }
    .login-brand div, .login-brand span, .login-sub, .login-foot { color: #fff !important; }
    .login-brand span { color: #F4C04E !important; }
    .login-sub, .login-foot { opacity: .9; }
    .login-box { box-shadow: 0 8px 28px rgba(8,60,60,.28); }
    @media (min-width: 900px) {
      .login-pane {
        display: flex; flex-direction: column; justify-content: center;
        flex: 1.05; position: relative; overflow: hidden; color: #fff;
        padding: 48px 56px;
        background: linear-gradient(155deg, #0B8484 0%, #0EA5A5 55%, #4CB782 130%);
      }
      .login-pane > * { position: relative; z-index: 1; }
      .login-brand { display: none !important; }
      .login-pane { position: relative; inset: auto; pointer-events: auto; }
      .login-pane-brand { display: flex; }
      .login-pane .login-pane-wm { width: 420px; height: 420px; right: -70px; bottom: -60px; }
      .login-side { background: var(--bg); }
      .login-sub, .login-foot { color: var(--text-muted) !important; opacity: 1; }
      .login-box { box-shadow: 0 4px 20px rgba(14,165,165,0.15); }
      .login-pane { align-items: center; text-align: center; }
      .login-pane-brand { display: flex; flex-direction: column; align-items: center; gap: 20px; }
      .login-pane-name { font-family: 'Spectral', serif; font-size: 64px; font-weight: 500; letter-spacing: -1px; line-height: 1; }
      .login-pane-name b { font-weight: 500; color: #F4C04E; }
      .login-pane-tag { font-size: 14px; font-weight: 600; letter-spacing: 5px; text-transform: uppercase; opacity: .85; margin-top: -4px; }
      .login-pane .login-pane-wm {
        position: absolute; z-index: 0; right: -70px; bottom: -60px;
        opacity: .1; transform: rotate(-8deg); pointer-events: none;
      }
    }
    .login-sub {
      font-size: 13px; color: var(--text-sub);
      margin-bottom: 20px; text-align: center;
    }
    .login-box {
      background: var(--white);
      border-radius: 16px;
      box-shadow: 0 4px 20px rgba(14,165,165,0.15);
      padding: 24px 20px;
      width: 100%; max-width: 360px;
    }
    .login-field {
      margin-bottom: 16px;
    }
    .login-field label {
      display: block;
      font-size: 11px; font-weight: 700;
      color: var(--primary-ink);
      text-transform: uppercase; letter-spacing: .7px;
      margin-bottom: 6px;
    }
    .login-input {
      width: 100%;
      padding: 13px 14px;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      font-size: 16px;
      color: var(--text);
      background: var(--bg);
      outline: none;
      transition: border-color .2s;
    }
    .login-input:focus { border-color: var(--primary); }
    .login-input:-webkit-autofill,
    .login-input:-webkit-autofill:hover,
    .login-input:-webkit-autofill:focus {
      -webkit-box-shadow: 0 0 0 1000px var(--white) inset;
      -webkit-text-fill-color: var(--text);
      transition: background-color 5000s ease-in-out 0s;
    }
    .login-btn {
      width: 100%; padding: 14px;
      background: var(--primary); color: var(--white);
      border: none; border-radius: 10px;
      font-size: 16px; font-weight: 700;
      cursor: pointer;
      transition: opacity .15s;
      margin-top: 4px;
    }
    .login-btn:active { opacity: .8; }
    .login-btn:disabled { opacity: .6; cursor: not-allowed; }
    .login-divider {
      display: flex; align-items: center; gap: 10px;
      margin: 16px 0;
      color: var(--text-sub); font-size: 12px;
    }
    .login-divider::before, .login-divider::after {
      content: ''; flex: 1; height: 1px; background: var(--border);
    }
    .clinica-opcao {
      width: 100%; padding: 14px 16px; text-align: left;
      background: var(--white); color: var(--text);
      border: 1.5px solid var(--border); border-radius: 12px;
      font-family: inherit; font-size: 15px; font-weight: 600;
      cursor: pointer; transition: border-color .15s, box-shadow .15s;
      display: flex; align-items: center; gap: 12px;
    }
    .clinica-opcao:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(14,165,165,.15); }
    .clinica-opcao.atual { border-color: var(--primary); background: #F4FBFB; }
    .clinica-opcao:disabled { opacity: .55; cursor: wait; }
    .clinica-opcao .sub {
      display: block; font-size: 12px; font-weight: 500; color: var(--text-sub); margin-top: 2px;
    }
    .clinica-opcao .marca-atual {
      margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .8px;
      text-transform: uppercase; color: var(--primary-ink);
    }
    .login-btn-google {
      width: 100%; padding: 13px 14px;
      background: var(--white); color: var(--text);
      border: 1.5px solid var(--border); border-radius: 10px;
      font-size: 15px; font-weight: 600;
      cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
      transition: border-color .2s, box-shadow .2s;
    }
    .login-btn-google:hover { border-color: #4285F4; box-shadow: 0 2px 8px rgba(66,133,244,0.15); }
    .login-btn-google:active { opacity: .8; }
    .login-btn-google:disabled { opacity: .6; cursor: not-allowed; }
    .login-erro {
      color: var(--danger-text); font-size: 13px; font-weight: 500;
      text-align: center; margin-top: 12px; min-height: 18px;
    }
    /* ===== Navegação: lateral no computador, rodapé no celular ===== */
    @media (min-width: 600px) {
      /* ── Nav lateral esquerda ── */
      :root { --nav-w: 88px; }

      .bottom-nav {
        top: var(--header-offset); bottom: 0;
        left: 0; right: auto;
        width: var(--nav-w); height: auto;
        flex-direction: column;
        border-top: none;
        border-right: 1px solid var(--border);
      }
      .nav-tab {
        flex: 0 0 88px;
        width: 100%;
      }
      .nav-tab.active::after {
        top: 20%; bottom: 20%;
        left: auto; right: 0;
        width: 3px; height: auto;
        border-radius: 4px 0 0 4px;
      }
      .content {
        padding-bottom: 4px;
        padding-left: var(--nav-w);
      }
      .toast {
        bottom: 72px;
      }
    }
    /* ── Botões flutuantes de navegação (desktop) ── */
    .dk-float-nav {
      position: fixed;
      top: calc(var(--header-offset) + (100vh - var(--header-offset)) / 2);
      transform: translateY(-50%);
      z-index: 150;
      width: 48px; height: 48px;
      border-radius: 50%;
      border: 1px solid var(--border);
      background: var(--white);
      color: var(--primary);
      box-shadow: 0 2px 12px rgba(0,0,0,0.12);
      cursor: pointer;
      display: none;
      align-items: center;
      justify-content: center;
      transition: box-shadow .15s, background .15s, opacity .15s;
    }
    .dk-float-nav:hover:not(:disabled) {
      background: var(--primary-light);
      box-shadow: 0 4px 18px rgba(0,0,0,0.18);
    }
    .dk-float-nav:disabled { opacity: .2; cursor: default; pointer-events: none; }
    .dk-float-prev { left: calc(var(--nav-w, 0px) + 10px); }
    .dk-float-next { right: 10px; }
    @media (min-width: 600px) {
      .dk-float-prev { left: calc(var(--nav-w) + 10px); }
    }

    .dk-wrap { max-width: 1080px; margin: 0 auto; padding: 22px 24px 64px; }
    /* Os cartões da ficha alinham com o cabeçalho (sem a margem lateral do cartão de lista). */
    .dk-wrap .section-card { margin: 0 0 18px; }
    .dk-head { background: var(--white); border: 1px solid var(--border); border-radius: 16px;
      padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); margin-bottom: 24px; }
    .dk-head-top { display: flex; align-items: center; gap: 20px; }
    .dk-avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--gold);
      color: var(--white); display: flex; align-items: center; justify-content: center;
      font-size: 28px; font-weight: 700; flex: none; }
    .dk-head h2 { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.15; }
    .dk-head h2[onclick]:hover { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 3px; }
    .dk-avatar[onclick]:hover { background: var(--gold-dark); color: var(--white); }
    .dk-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 14px; color: var(--text-sub); }
    .dk-meta b { color: var(--text); font-weight: 600; }
    /* + Nova: um botão, um menu (computador) ou uma folha inferior (celular) */
    .nova-wrap { position: relative; display: flex; }
    .nova-wrap .nova-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 16px 6px 8px; box-shadow: 0 2px 6px rgba(208,109,48,.28); }
    .nova-disco { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; flex-shrink: 0; }
    .nova-caret { transition: transform .15s; }
    .nova-wrap.aberto .nova-caret { transform: rotate(180deg); }
    .nova-fundo, .nova-puxador, .nova-tit { display: none; }
    .nova-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; min-width: 300px;
      background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 6px;
      box-shadow: 0 10px 30px rgba(21,48,47,.16); display: none; }
    .nova-wrap.aberto .nova-menu { display: block; }
    .nova-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0;
      font: inherit; font-size: 14px; font-weight: 600; color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer; min-height: 44px; }
    .nova-item:hover, .nova-item:focus-visible { background: var(--primary-light); }
    .nova-item small { display: block; font-weight: 400; font-size: 12px; color: var(--text-sub); }
    .nova-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
      background: var(--primary-light); color: var(--primary-ink); }
    .nova-ic-receita { background: var(--blue-light); color: var(--blue-dark); }
    @media (max-width: 599px) {
      .nova-wrap.aberto .nova-fundo { display: block; position: fixed; inset: 0; z-index: 300; background: rgba(21,48,47,.35); }
      .nova-menu { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 301; min-width: 0;
        border-radius: 16px 16px 0 0; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); }
      .nova-puxador { display: block; width: 38px; height: 4px; background: var(--line); border-radius: 4px; margin: 2px auto 8px; }
      .nova-tit { display: block; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
        color: var(--primary-ink); padding: 4px 12px 6px; }
    }
    .dk-actions {
      display: inline-grid;
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      gap: 10px;
      align-self: flex-end;
    }
    .dk-section-title { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
      color: var(--primary-dark); margin: 0 0 16px; }
    .dk-icon-btn { background: none; border: 1.5px solid var(--border); border-radius: 8px; padding: 7px;
      cursor: pointer; color: var(--text-sub); display: inline-flex; align-items: center; justify-content: center;
      transition: border-color .15s, color .15s, background .15s; }
    .dk-icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
    .dk-icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--red-light); }
    .tl-act { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
    .tl-cardhead { display: flex; align-items: center; gap: 10px; padding: 11px 18px;
      background: var(--neutro-d); border-bottom: 1px solid var(--border); }
    .priv-val { white-space: nowrap; }

    /* ── Tela estreita (celular): a MESMA ficha do computador, mais compacta.
       Até 23/10/2026 o celular tinha telas próprias; agora só o CSS muda. ── */
    @media (max-width: 599px) {
      .dk-wrap { padding: 12px 10px 24px; }
      .dk-head { padding: 16px 14px; gap: 12px; border-radius: 12px; margin-bottom: 18px; }
      /* Botões (imprimir, editar, excluir) no canto superior direito, numa linha
         própria; o nome do paciente vem embaixo, com a largura toda. */
      .dk-head-top { display: grid; grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "acoes acoes" "avatar nome"; column-gap: 12px; row-gap: 8px; align-items: center; }
      .dk-head-acoes { grid-area: acoes; justify-self: end; margin-left: 0 !important; }
      .dk-avatar { grid-area: avatar; }
      .dk-head-nome { grid-area: nome; }
      .dk-avatar { width: 48px; height: 48px; font-size: 20px; }
      .dk-head h2 { font-size: 18px; }
      .dk-meta { gap: 4px 14px; font-size: 13px; }
      .dk-actions { display: flex; flex-wrap: wrap; align-self: stretch; }
      .dk-actions > * { flex: 1 1 140px; }
      .tl { padding-left: 42px; }
      .tl-mk { left: -42px; }
      /* Cartão da consulta: ações no canto superior direito (linha própria);
         depois data e hora à esquerda com valor e NF à direita; depois o
         profissional; depois as etiquetas. */
      .tl-cardhead {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; column-gap: 10px; padding: 10px 12px;
        grid-template-areas: "acoes acoes" "data fin" "autor autor" "badges badges";
        align-items: center;
      }
      .tl-cardhead .tl-act   { grid-area: acoes; justify-self: end; margin-left: 0; }
      .tl-cardhead .tl-date  { grid-area: data; }
      .tl-cardhead .tl-fin   { grid-area: fin; margin-left: 0 !important; justify-self: end; }
      .tl-cardhead .tl-autor { grid-area: autor; justify-self: start; max-width: 100%; }
      .tl-cardhead .tl-badges { grid-area: badges; }
      .tl-body { padding: 12px; }
      .tl-autor { max-width: 100%; }
      /* Setas de anterior/próximo: juntas no canto de baixo, à esquerda —
         no meio da tela cobriam os botões, e à direita fica o "+". */
      .dk-float-nav { top: auto; transform: none; width: 44px; height: 44px;
        bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
      .dk-float-prev { left: 12px; }
      .dk-float-next { left: 64px; right: auto; }
    }
    .tl { position: relative; padding-left: 46px; }
    .tl::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
    .tl-item { position: relative; margin-bottom: 22px; }
    /* ícone do tipo de registro, no fio da linha do tempo */
    .tl-mk { position: absolute; left: -46px; top: 5px; width: 32px; height: 32px; border-radius: 10px;
      display: grid; place-items: center; background: var(--primary-light); color: var(--primary-ink);
      box-shadow: 0 0 0 4px var(--bg); }
    .tl-mk-receita { background: var(--blue-light); color: var(--blue-dark); }
    .tl-mk-adendo, .nova-ic-adendo { background: var(--orange-light); color: var(--orange-dark); }
    .tl-mk-atestado, .nova-ic-atestado { background: var(--green-light); color: var(--green-ink); }
    .tl-badge-adendo { background: var(--orange-light); color: var(--orange-dark); }
    .tl-badge-atestado { background: var(--green-light); color: var(--green-ink); }
    .tl-badge-origem { background: var(--bg); color: var(--text-sub); border: 1px solid var(--border); }
    .tl-citacao { border-left: 3px solid var(--orange); padding-left: 12px; white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
    .tl-editado { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
    .tl-item[data-tipo="adendo"] .tl-card, .tl-item[data-tipo="atestado"] .tl-card { box-shadow: none; }
    .tl-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px;
      box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .15s, border-color .15s; }
    .tl-card.clik { cursor: pointer; }
    .tl-card.clik:hover { border-color: var(--primary); box-shadow: 0 4px 18px rgba(14,165,165,.16); }
    .tl-card.atual { border-color: var(--primary); }
    .tl-date { font-weight: 700; color: var(--text); font-size: 14px; display: inline-flex; flex-direction: column; align-items: flex-start; }
    .tl-time { font-weight: 400; color: var(--text-sub); font-size: 12px; }
    .tl-badges { display: flex; gap: 4px; flex-wrap: wrap; }
    .tl-badge { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; letter-spacing: .3px; }
    .tl-badge-pront { background: var(--primary-light); color: var(--primary-ink); }
    .tl-badge-exam  { background: var(--orange-light); color: var(--orange-dark); }
    .tl-badge-rx    { background: var(--blue-light); color: var(--blue-dark); }
    .tl-item[data-tipo="receita"] .tl-card { box-shadow: none; }
    .tl-item[data-tipo="receita"] .tl-cardhead { border-bottom: 0; }
    .tl-filtros { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
    .tl-filtro { font: inherit; font-size: 13px; font-weight: 600; color: var(--text-sub); background: var(--white);
      border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; cursor: pointer; min-height: 36px; }
    .tl-filtro span { font-weight: 500; opacity: .8; margin-left: 2px; }
    .tl-filtro:hover { border-color: var(--primary); color: var(--text); }
    .tl-filtro.on { background: var(--primary-light); border-color: var(--primary); color: var(--primary-ink); }
    .tl-body { padding: 16px 18px; }
    .tl-block { margin-bottom: 14px; }
    .tl-block:last-child { margin-bottom: 0; }
    .tl-block h4 { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
      color: var(--primary-ink); margin-bottom: 8px;
      border-left: 3px solid var(--primary); padding-left: 8px; }
    .tl-text { font-size: 14px; white-space: pre-wrap; line-height: 1.55; }
    .dk-hist { margin-top: 8px; }
    .dk-hist > summary { cursor: pointer; user-select: none; }
    .dk-hist > summary::-webkit-details-marker { display: none; }
    /* Toggle "ver/ocultar" dos itens do histórico (mobile) */
    details .ht-aberto { display: none; }
    details[open] .ht-aberto { display: inline; }
    details[open] .ht-fechado { display: none; }

    /* ─── AGENDA ─── */
    .age-header { padding: 12px 16px 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
    .age-nav-btn { background: none; border: 1.5px solid var(--border); border-radius: 8px; padding: 6px 14px; cursor: pointer; color: var(--text); font-size: 18px; line-height: 1; }
    .age-date-label { text-align: center; font-size: 15px; font-weight: 600; color: var(--text); min-width: 180px; cursor: pointer; border-radius: 6px; }
    .age-date-label:hover { background: var(--primary-light); }
    .age-view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; margin: 0 16px 12px; }
    .age-view-btn { flex: 1; padding: 7px 0; background: none; border: none; border-right: 1.5px solid var(--border); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-sub); font-family: inherit; }
    .age-view-btn:last-child { border-right: none; }
    .age-view-btn.ativo { background: var(--primary); color: var(--white); }
    .age-lista { padding: 0 16px 80px; }
    .age-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--primary-ink); padding: 14px 0 6px; border-bottom: 1.5px solid var(--border); margin-bottom: 8px; }
    .age-card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; border-left: 6px solid var(--gold); }
    .age-card.status-confirmado { border-left-color: var(--green); }
    .age-card.status-cancelado  { border-left-color: var(--line); opacity: .65; }
    .age-card.status-realizado,
    .age-card.status-atendido   { border-left-color: var(--blue); }
    .age-card.status-faltou     { border-left-color: var(--danger); }
    .age-card.status-paciente-no-local { border-left-color: #2EA9DF; }
    .age-card.status-em-atendimento    { border-left-color: #8B5CF6; }
    .age-card-top { display: grid; grid-template-columns: 52px auto 28px 1fr auto; align-items: center; gap: 8px; }
    .age-hora { font-size: 13px; font-weight: 700; color: var(--primary-ink); line-height: 1.3; cursor: pointer; flex-shrink: 0; }
    .age-hora small { display: block; font-size: 11px; font-weight: 500; color: var(--text-sub); }
    .age-nome-col { min-width: 0; overflow: hidden; }
    .age-nome { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
    .age-tipo-sub { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
    .age-badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: #FEF3D0; color: #916800; white-space: nowrap; flex-shrink: 0; }
    .age-badge.status-confirmado { background: var(--green-light); color: #2F7653; }
    .age-badge.status-cancelado  { background: var(--border); color: var(--text-sub); }
    .age-badge.status-realizado,
    .age-badge.status-atendido   { background: #E8EDFC; color: #3E61DD; }
    .age-badge.status-faltou     { background: var(--red-light); color: var(--danger-text); }
    .age-badge.status-paciente-no-local { background: #E3F6FC; color: #1877A0; }
    .age-badge.status-em-atendimento    { background: #F0EBFD; color: #7A45F5; }
    .age-card-sub { display: none; }
    .age-card-actions { display: flex; gap: 8px; }
    .age-dia { padding: 0 16px 80px; }
    .age-slot { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; }
    .age-slot-hora { font-size: 12px; color: var(--text-sub); min-width: 44px; font-weight: 500; padding-top: 18px; }
    .age-semana-wrap { overflow-x: auto; padding-bottom: 80px; }
    .age-semana-head { font-size: 11px; font-weight: 700; text-align: center; height: 45px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px; background: var(--primary-light); color: var(--primary-ink); border: 1px solid var(--border); box-sizing: border-box; }
    .age-semana-head.hoje { background: var(--primary); color: var(--white); }
    /* ── layout posicionamento absoluto ── */
    .age-cal-layout { display: flex; min-width: 520px; }
    .age-cal-horas { width: 44px; flex-shrink: 0; }
    .age-cal-hora  { height: 48px; font-size: 11px; color: var(--text-sub); text-align: right; padding: 3px 4px 0 0; border-top: 1px solid var(--border); box-sizing: border-box; }
    .age-cal-day   { flex: 1; min-width: 0; border-left: 1px solid var(--border); }
    .age-cal-body  { position: relative; }
    .age-cal-line  { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); cursor: pointer; box-sizing: border-box; }
    .age-cal-line:hover { background: var(--primary-light); }
    .age-cal-line.inativo { background: var(--border); cursor: default; }
    .age-cal-line.inativo:hover { background: var(--border); }
    .age-cal-evt   { position: absolute; background: var(--white); color: var(--text); border-radius: 4px; padding: 3px 5px 3px 7px; overflow: hidden; cursor: pointer; box-sizing: border-box; z-index: 1; line-height: 1.3; border-left: 6px solid var(--gold); box-shadow: 0 1px 4px rgba(0,0,0,.10); }
    .age-cal-evt.status-confirmado { border-left-color: var(--green); }
    .age-cal-evt.status-cancelado  { border-left-color: var(--line); opacity: .65; }
    .age-cal-evt.status-realizado,
    .age-cal-evt.status-atendido   { border-left-color: var(--blue); }
    .age-cal-evt.status-faltou     { border-left-color: var(--danger); }
    .age-cal-evt.status-paciente-no-local { border-left-color: #2EA9DF; }
    .age-cal-evt.status-em-atendimento    { border-left-color: #8B5CF6; }
    .age-cal-evt.bloqueio { background: repeating-linear-gradient(45deg,var(--line),var(--line) 4px,var(--border) 4px,var(--border) 10px); color: var(--text-sub); border: 1px solid var(--line); border-left: 6px solid var(--line); }
    .age-cal-evt:hover { filter: brightness(.97); box-shadow: 0 2px 8px rgba(0,0,0,.14); }
    .age-cal-evt-nome { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .age-cal-evt-tipo { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    /* Celular: o calendário cabe na largura (o mínimo de 520 px pedia rolagem
       horizontal). O Dia é uma coluna e sobra espaço; a Semana tem 7 colunas
       estreitas, e o cartão mostra só o nome — tocar nele abre o agendamento. */
    @media (max-width: 599px) {
      .age-semana-wrap { overflow-x: hidden; }
      .age-cal-layout { min-width: 0; }
      .age-cal-horas { width: 36px; }
      .age-cal-hora { font-size: 11px; padding-right: 3px; }
      .age-semana-head { font-size: 11px; }
      .age-cal-layout:has(.age-cal-day + .age-cal-day) .age-cal-evt { padding: 2px 2px 2px 3px; border-left-width: 4px; }
      .age-cal-layout:has(.age-cal-day + .age-cal-day) .age-cal-evt-nome { font-size: 11px; }
      .age-cal-layout:has(.age-cal-day + .age-cal-day) .age-cal-evt-tipo { display: none; }
    }
    .age-mes { padding: 0 16px; }
    .age-mes-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 16px; }
    .age-mes-head { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-sub); padding: 6px 0; }
    .age-mes-day { min-height: 50px; border: 1.5px solid var(--border); border-radius: 8px; padding: 4px; cursor: pointer; }
    .age-mes-day:hover { border-color: var(--primary); }
    /* Hoje e REFERENCIA: contorno, sem preenchimento. */
    .age-mes-day.hoje { border-color: var(--primary); }
    .age-mes-day.hoje .age-mes-num { color: var(--primary-ink); font-weight: 800; }
    .age-mes-day.outro-mes { opacity: .3; }
    .age-mes-day.indisponivel { background: var(--border); }
    /* Selecionado e o dia que esta sendo LIDO: preenchido, e por isso vem
       depois de .indisponivel, que tambem pinta o fundo. */
    .age-mes-day.selecionado {
      border-color: var(--primary); background: var(--primary);
      box-shadow: 0 0 0 3px var(--primary-light);
    }
    .age-mes-day.selecionado .age-mes-num { color: var(--white); font-weight: 800; }
    /* Os pontinhos de status ficam sobre fundo escuro: sem o anel branco os
       de cor proxima do primario somem justamente no dia em foco. */
    .age-mes-day.selecionado .age-mes-dot { box-shadow: 0 0 0 1.5px var(--white); }
    .age-mes-day.selecionado.outro-mes { opacity: 1; }
    .age-mes-num { font-size: 12px; font-weight: 600; color: var(--text); }
    .age-mes-dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; }
    .age-mes-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
    .age-mes-dot.status-confirmado { background: var(--green); }
    .age-mes-dot.status-cancelado  { background: var(--line); }
    .age-mes-dot.status-realizado,
    .age-mes-dot.status-atendido   { background: var(--blue); }
    .age-mes-dot.status-faltou     { background: var(--danger); }
    .age-mes-dot.status-paciente-no-local { background: #2EA9DF; }
    .age-mes-dot.status-em-atendimento    { background: #8B5CF6; }
    .age-mes-dot.bloqueio { background: repeating-linear-gradient(45deg,var(--line),var(--line) 2px,var(--border) 2px,var(--border) 5px); border-radius: 4px; width: 8px; height: 8px; }
    /* ── Lista (tabela do dia) ── */
    .age-tabela-wrap { padding: 0 16px 80px; overflow-x: auto; }
    .age-tabela { width: 100%; min-width: 880px; border-collapse: separate; border-spacing: 0 8px; }
    .age-tabela th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-sub); padding: 0 10px 6px; white-space: nowrap; }
    .age-tabela td { background: var(--white); padding: 12px 10px; font-size: 13px; color: var(--text); vertical-align: middle; white-space: nowrap; border-right: 1px solid var(--border); }
    .age-tabela tr.age-trow td:first-child { border-left: 6px solid var(--gold); border-radius: 10px 0 0 10px; }
    .age-tabela tr.age-trow td:last-child { border-radius: 0 10px 10px 0; border-right: none; }
    .age-tabela tr.age-trow.status-confirmado td:first-child { border-left-color: var(--green); }
    .age-tabela tr.age-trow.status-cancelado td:first-child { border-left-color: var(--line); opacity: .65; }
    .age-tabela tr.age-trow.status-realizado td:first-child,
    .age-tabela tr.age-trow.status-atendido td:first-child   { border-left-color: var(--blue); }
    .age-tabela tr.age-trow.status-faltou td:first-child     { border-left-color: var(--danger); }
    .age-tabela tr.age-trow.status-paciente-no-local td:first-child { border-left-color: #2EA9DF; }
    .age-tabela tr.age-trow.status-em-atendimento td:first-child    { border-left-color: #8B5CF6; }
    .age-trow-hora { font-weight: 700; color: var(--primary-ink); font-size: 13px; }
    .age-trow-hora small { display: block; font-weight: 500; color: var(--text-sub); font-size: 11px; }
    .age-trow-pac { display: flex; align-items: center; gap: 6px; font-weight: 600; }
    .age-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--gold); }
    .age-status-dot.status-confirmado { background: var(--green); }
    .age-status-dot.status-cancelado  { background: var(--line); }
    .age-status-dot.status-realizado,
    .age-status-dot.status-atendido   { background: var(--blue); }
    .age-status-dot.status-faltou     { background: var(--danger); }
    .age-status-dot.status-paciente-no-local { background: #2EA9DF; }
    .age-status-dot.status-em-atendimento    { background: #8B5CF6; }
    .age-status-select { border: none; background: none; font-size: 13px; font-weight: 600; color: var(--text); font-family: inherit; cursor: pointer; padding: 2px 4px; }
    .age-trow-tipo { font-weight: 600; }
    .age-trow-obs { color: var(--text-sub); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; display: inline-block; }
    .age-chip-btn { border: none; background: var(--primary-light); color: var(--primary-ink); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px; cursor: pointer; font-family: inherit; white-space: nowrap; }
    .age-chip-btn:hover { filter: brightness(.96); }
    .age-prontuario { font-size: 13px; font-weight: 600; }
    .age-prontuario.incluso  { color: var(--green); }
    .age-prontuario.pendente { color: var(--danger-text); }
    /* Autor da consulta: presente mas discreto -- e contexto, nao titulo. */
    .tl-autor {
      font-size: 12px; font-weight: 600; color: var(--text-sub);
      background: var(--bg); border-radius: 6px; padding: 2px 8px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
    }
    .age-pag-btn { border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px; color: var(--line); }
    .age-pag-btn.pago     { color: var(--green); }
    .age-pag-btn.pendente { color: var(--danger-text); }
    .age-atender-btn { border: 1.5px solid var(--primary); background: none; color: var(--primary-ink); font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 20px; cursor: pointer; font-family: inherit; white-space: nowrap; }
    .age-atender-btn:hover { background: var(--primary-light); }
    /* ── Lista da agenda no celular ────────────────────────────────────
       A MESMA linha da tabela, com as mesmas células e ações — só arrumada
       em blocos, porque 9 colunas não cabem em 390 px:
         hora | paciente (+WhatsApp, chip)   | pagamento
              | status                       | ação
              | atendimento
              | observação
              | prontuário                  | chegada
       Alvos de toque de 44 px. */
    @media (max-width: 899px) {
      .age-tabela-wrap { padding: 0 12px 24px; overflow-x: visible; }
      .age-tabela, .age-tabela tbody { display: block; min-width: 0; }
      .age-tabela thead { display: none; }
      .age-tabela tr.age-trow {
        display: grid; column-gap: 12px; row-gap: 0;
        grid-template-columns: 52px minmax(0, 1fr) auto;
        grid-template-areas:
          "hora  pac    pag"
          "hora  status acao"
          "tipo  tipo   tipo"
          "obs   obs    obs"
          "pront pront  cheg";
        align-items: center;
        background: var(--white); border-radius: 12px; margin: 0 0 8px;
        padding: 8px 10px 8px 12px; border-left: 6px solid var(--gold);
        box-shadow: 0 1px 4px rgba(0,0,0,.07);
      }
      .age-tabela tr.age-trow td { display: block; background: none; padding: 0; border: none; white-space: normal; font-size: 13px; }
      .age-tabela tr.age-trow td:first-child, .age-tabela tr.age-trow td:last-child { border: none; border-radius: 0; }
      .age-tabela tr.age-trow.status-confirmado { border-left-color: var(--green); }
      .age-tabela tr.age-trow.status-cancelado  { border-left-color: var(--line); opacity: .65; }
      .age-tabela tr.age-trow.status-realizado,
      .age-tabela tr.age-trow.status-atendido   { border-left-color: var(--blue); }
      .age-tabela tr.age-trow.status-faltou     { border-left-color: var(--danger); }
      .age-tabela tr.age-trow.status-paciente-no-local { border-left-color: #2EA9DF; }
      .age-tabela tr.age-trow.status-em-atendimento    { border-left-color: #8B5CF6; }
      .age-trow td.c-hora   { grid-area: hora; align-self: start; }
      .age-trow td.c-pac    { grid-area: pac; min-width: 0; }
      .age-trow td.c-pag    { grid-area: pag; justify-self: end; }
      .age-trow td.c-status { grid-area: status; min-width: 0; }
      .age-trow td.c-acao   { grid-area: acao; justify-self: end; }
      .age-trow td.c-tipo   { grid-area: tipo; padding-top: 4px; }
      .age-trow td.c-obs    { grid-area: obs; }
      .age-trow td.c-pront  { grid-area: pront; }
      .age-trow td.c-cheg   { grid-area: cheg; justify-self: end; color: var(--text-sub); font-size: 12px; }
      .age-trow td.c-cheg::before { content: 'Chegada '; }
      .age-trow td.c-cheg.vazio, .age-trow td.c-obs:has(.age-trow-obs:empty), .age-trow td.c-acao:empty { display: none; }
      .age-trow td.c-pront::before { content: 'Prontuário: '; color: var(--text-sub); font-weight: 400; font-size: 12px; }
      .age-trow-hora { font-size: 14px; }
      .age-trow-pac { flex-wrap: nowrap; font-size: 14px; }
      .age-trow-pac > span:first-child { min-width: 0; overflow-wrap: anywhere; }
      .age-trow-obs { max-width: none; white-space: normal; }
      .age-status-select { font-size: 13px; min-height: 32px; max-width: 100%; }
      /* O título do grupo de canceladas é uma linha de texto, e não uma célula. */
      .age-canc-titulo, .age-canc-titulo td { display: block; }
    }
    /* Toque: alvo de 44 px (pointer: coarse = dedo, mesmo em tela larga). */
    @media (pointer: coarse), (max-width: 899px) {
      .age-pag-btn { min-width: 44px; min-height: 40px; font-size: 20px; }
      .age-atender-btn { min-height: 40px; padding: 0 16px; }
      .age-tele-btn { min-height: 44px; }
      .age-trow-pac button { min-width: 44px; min-height: 44px; justify-content: center; }
      .age-canceladas-btn { min-height: 44px; }
    }
    /* ── Privacidade ── */
    /* Valores viram R$ ***** (sempre do mesmo tamanho); o gráfico, as barras por categoria,
       a variação e as cores de lucro/prejuízo somem: tudo isso diria a grandeza ou o sinal. */
    .priv-mask { display: none; }
    body.priv-mode .priv-real { display: none; }
    body.priv-mode .priv-mask { display: inline; white-space: nowrap; letter-spacing: .5px; }
    body.priv-mode .fin-kpi-val { color: var(--text); }
    body.priv-mode .var-sobe, body.priv-mode .var-desce { color: var(--text-sub); }
    body.priv-mode .rec-cat-barra, body.priv-mode .desp-cat-barra { display: none; }
    .fin-grafico-priv { display: none; }
    body.priv-mode .fin-grafico-real { display: none; }
    body.priv-mode .fin-grafico-priv { display: flex; align-items: center; justify-content: center; gap: 8px; height: 170px;
      border: 1.5px dashed var(--line); border-radius: 10px; color: var(--text-muted); font-size: 13px; }
    /* Campo de digitar valor: caracteres ocultos (Chrome, Edge, Safari); no Firefox, desfoque. Ao focar, mostra para editar. */
    body.priv-mode input.priv-input { -webkit-text-security: disc; }
    @supports not (-webkit-text-security: disc) { body.priv-mode input.priv-input { filter: blur(5px); } }
    body.priv-mode input.priv-input:focus { -webkit-text-security: none; filter: none; }
    .age-overlay { position: fixed; inset: 0; background: rgba(21,48,47,.45); z-index: 500; display: none; align-items: flex-end; justify-content: center; }
    .age-overlay.open { display: flex; }
    @media (min-width: 600px) { .age-overlay { align-items: center; } }
    .age-sheet { background: var(--white); border-radius: 20px 20px 0 0; width: 100%; max-width: 560px; padding: 24px 20px 32px; max-height: 92vh; overflow-y: auto; }
    @media (min-width: 600px) { .age-sheet { border-radius: 16px; } }
    .age-sheet-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 18px; }
    .age-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
    .age-label { font-size: 12px; font-weight: 600; color: var(--text-sub); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; display: block; }
    .age-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--bg); }
    .age-input:focus { outline: none; border-color: var(--primary); }
    .age-pac-wrap { position: relative; }
    .age-pac-drop { position: absolute; top: 100%; left: 0; right: 0; background: var(--white); border: 1.5px solid var(--border); border-radius: 10px; max-height: 180px; overflow-y: auto; z-index: 10; box-shadow: var(--shadow); margin-top: 2px; }
    .age-pac-opt { padding: 10px 12px; font-size: 13px; cursor: pointer; }
    .age-pac-opt:hover { background: var(--primary-light); }
    .age-pac-opt.atual { background: var(--primary-light); font-weight: 700; }
    .age-combo { position: relative; }
    .age-combo .age-input { padding-right: 30px; }
    .age-combo-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: 11px; color: var(--text-sub); }
    .age-hora-nota { padding: 8px 12px; font-size: 12px; line-height: 1.4; color: var(--text-sub); background: var(--bg); border-bottom: 1px solid var(--border); }
    .age-form-actions { display: flex; gap: 10px; margin-top: 20px; }
  
    /* ─── Acessibilidade (polish) ─────────────────────────────────────────
       Foco por teclado SEMPRE visível: vários campos tinham outline:none com
       só a cor da borda mudando, e botões não mostravam nada. */
    :focus-visible { outline: 3px solid var(--primary-dark) !important; outline-offset: 2px; }
    .header :focus-visible, .bottom-nav :focus-visible { outline-color: var(--gold) !important; }
    .header .header-menu :focus-visible { outline-color: var(--primary-dark) !important; outline-offset: -3px; }
    input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
    /* Cartões cortam (overflow:hidden) o que passa da borda: nos itens deles o contorno vai para dentro. */
    .list-card :focus-visible, .tl-card:focus-visible, .age-tabela tr :focus-visible { outline-offset: -3px; }
    /* Alvos de toque de 44 px no celular (dedo) — o que estava abaixo disso. */
    @media (pointer: coarse), (max-width: 899px) {
      .header-icon-btn, .btn-back, .header-user, .header-menu-item { min-width: 44px; min-height: 44px; }
      .age-nav-btn, .ano-btn, .fin-mes-arrow { min-width: 44px; min-height: 44px; }
      .age-view-btn, .cfg-tab, .fin-ano-chip, .section-action, .btn { min-height: 44px; }
      .filter-fab { min-width: 44px; min-height: 44px; }
      .search-input, .filtro-select, .cfg-input { min-height: 44px; }
    }


    /* ─── Adendo e atestado: formulários em folha ─── */
    .adendo-origens { display: flex; gap: 8px; flex-wrap: wrap; }
    .adendo-aviso { font-size: 12px; color: var(--text-muted); }
    .at-sheet { max-width: 1020px; width: 100%; max-height: 92vh; overflow: auto; }
    .at-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-bottom: 18px; }
    .at-form { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
    .at-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .at-cid-ok { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-sub); cursor: pointer; }
    .at-cid-ok input { width: 18px; height: 18px; }
    .at-prev { min-width: 0; }
    .at-prev-rot { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
    @media (max-width: 760px) { .at-grid { grid-template-columns: 1fr; } }

    /* Adendo e atestado: no computador a folha abre no centro (no celular sobe do rodapé) */
    @media (min-width: 600px) {
      #adendo-overlay, #at-overlay { align-items: center; }
      #adendo-overlay .sheet, #at-overlay .sheet { border-radius: 20px; padding-bottom: 22px; }
    }
