/* =========================================================
   Demandas TI · visual "painel"
   Celular: barra de abas embaixo · PC (>= 960px): menu lateral
   ========================================================= */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f0f3f2;
  --surface-3: #e7ecea;
  --text: #121a16;
  --muted: #5f6c66;
  --border: #e2e7e5;
  --border-forte: #cfd7d3;
  --accent: #0f7a4a;
  --accent-hover: #0b673d;
  --accent-text: #ffffff;
  --accent-soft: #e3f3ea;
  --alta: #c62828;
  --alta-soft: #fdeaea;
  --media: #a35f00;
  --media-soft: #fff2dd;
  --baixa: #46647d;
  --baixa-soft: #e8eff5;
  --and: #1d5fb8;
  --and-soft: #e5eefb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 28, 22, .04), 0 4px 14px rgba(16, 28, 22, .05);
  --shadow-alto: 0 10px 40px rgba(16, 28, 22, .18);
  --lateral: 248px;
  color-scheme: light;
}

/* Tema escuro: tema.js põe data-tema="escuro" (escolha do usuário ou do aparelho) */
:root[data-tema="escuro"] {
  --bg: #0c110f;
  --surface: #141b18;
  --surface-2: #1b2420;
  --surface-3: #232e29;
  --text: #e6ede9;
  --muted: #95a39c;
  --border: #25302b;
  --border-forte: #34413b;
  --accent: #3cbf7e;
  --accent-hover: #55cf92;
  --accent-text: #05120b;
  --accent-soft: #15301f;
  --alta: #ff8a8a;
  --alta-soft: #3a1b1b;
  --media: #f2b75c;
  --media-soft: #352816;
  --baixa: #a3bdd3;
  --baixa-soft: #1b2733;
  --and: #8ab4f8;
  --and-soft: #18253c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-alto: 0 10px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent); }
.ico { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border-forte); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primario { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(15, 122, 74, .25); }
.btn.primario:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--muted); }
.btn.fantasma:hover { background: var(--surface-2); color: var(--text); }
.btn.perigo:hover { color: var(--alta); background: var(--alta-soft); }
.btn.pequeno { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.largo { width: 100%; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-forte); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* evita zoom no iPhone */
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Login ---------- */
.tela-login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.cartao-login {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow-alto);
}
.cartao-login h1 { text-align: center; font-size: 21px; margin-bottom: 6px; }
.cartao-login .btn { min-height: 46px; margin-top: 4px; }

/* Logo (fundo transparente): no modo escuro ganha uma placa branca para manter as cores legíveis */
.logo { display: block; height: auto; }
.logo-login { width: 100%; max-width: 240px; align-self: center; }
.logo-topo { width: auto; height: 34px; }
[data-tema="escuro"] .logo { background: #fff; border-radius: 10px; padding: 6px 10px; box-sizing: content-box; }
[data-tema="escuro"] .logo-topo { padding: 3px 6px; border-radius: 7px; }

/* ---------- Estrutura ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca div { display: flex; flex-direction: column; line-height: 1.15; padding-left: 10px; border-left: 1px solid var(--border); }
.marca span { font-size: 12px; color: var(--muted); }
.titulo-pagina { display: none; font-size: 20px; }
.topo-acoes { display: flex; align-items: center; gap: 4px; }
.so-desktop { display: none; }
.btn-tema { width: 40px; padding: 0; }
.btn-tema svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Botão de busca: no celular só a lupa, no PC parece um campo */
.campo-busca {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; width: 40px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer;
}
.campo-busca:hover { background: var(--surface-2); color: var(--text); }
.campo-busca svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.campo-busca span { display: none; }

/* Abas: barra fixa embaixo no celular */
.abas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 18px rgba(16, 28, 22, .05);
}
.abas-marca, .abas-grupo { display: none; }
.abas button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer; min-width: 0;
}
.abas button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.abas svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.abas button.ativo { color: var(--accent); }
.abas button.ativo::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.abas .extra { display: none; }
.contador {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--alta); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 100px; }

.aviso-demo {
  max-width: 1120px; margin: 12px auto 0; padding: 10px 14px;
  background: var(--media-soft); color: var(--media); border-radius: var(--radius-sm); font-size: 13px;
  width: calc(100% - 32px);
}

/* ---------- PC: menu lateral ---------- */
@media (min-width: 960px) {
  #app {
    display: grid; min-height: 100vh;
    grid-template-columns: var(--lateral) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "nav topo" "nav aviso" "nav main";
  }
  .topo { grid-area: topo; padding: 14px 28px; }
  .aviso-demo { grid-area: aviso; width: auto; margin: 14px 28px 0; max-width: none; }
  main { grid-area: main; width: 100%; padding: 24px 28px 48px; margin: 0; max-width: 1240px; }
  .marca { display: none; }
  .titulo-pagina { display: block; }
  .so-desktop { display: inline-flex; }
  .so-celular { display: none; }
  .topo-acoes { gap: 8px; }
  .campo-busca {
    width: 260px; justify-content: flex-start; padding: 0 12px;
    background: var(--surface-2); border-color: var(--border);
  }
  .campo-busca span { display: inline; }
  .campo-busca:hover { border-color: var(--border-forte); }

  .abas {
    grid-area: nav; position: sticky; top: 0; bottom: auto; height: 100vh;
    display: flex; flex-direction: column; gap: 2px; padding: 18px 14px;
    border-top: 0; border-right: 1px solid var(--border); box-shadow: none; overflow-y: auto;
  }
  .abas-marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
  .abas-marca .logo { height: 30px; width: auto; flex-shrink: 0; }
  .abas-marca strong { white-space: nowrap; }
  .abas-marca div { display: flex; flex-direction: column; line-height: 1.15; }
  .abas-marca strong { font-size: 15px; }
  .abas-marca span { font-size: 12px; color: var(--muted); }
  .abas-grupo { display: block; margin: 14px 10px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .abas .extra { display: flex; }
  .abas .mais { display: none; }
  .abas button {
    flex-direction: row; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 14.5px; font-weight: 600; text-align: left;
  }
  .abas button span { flex: 1; }
  .abas button:hover { background: var(--surface-2); color: var(--text); }
  .abas button.ativo { background: var(--accent-soft); color: var(--accent); }
  .abas button.ativo::before { top: 9px; bottom: 9px; left: -14px; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .abas svg { width: 20px; height: 20px; }
  .contador { position: static; flex: 0 0 auto; }
  #toasts { bottom: 24px; left: calc(50% + var(--lateral) / 2); }

  /* Modelo B: lateral verde escura (cor da Ramos) */
  .abas {
    --lat-bg: #0b4a31; --lat-txt: rgba(255, 255, 255, .78); --lat-fraco: rgba(255, 255, 255, .5);
    --lat-hover: rgba(255, 255, 255, .08); --lat-ativo: rgba(255, 255, 255, .15); --lat-linha: rgba(255, 255, 255, .12);
    background: var(--lat-bg); border-right: 0; color: var(--lat-txt);
  }
  [data-tema="escuro"] .abas { --lat-bg: #082b1e; border-right: 1px solid var(--border); }
  .abas-marca { border-bottom-color: var(--lat-linha); }
  .abas-marca strong { color: #fff; }
  .abas-marca span, .abas-grupo { color: var(--lat-fraco); }
  .abas-marca .logo { background: #fff; border-radius: 8px; padding: 4px 7px; box-sizing: content-box; height: 26px; }
  .abas button { color: var(--lat-txt); }
  .abas button:hover { background: var(--lat-hover); color: #fff; }
  .abas button.ativo { background: var(--lat-ativo); color: #fff; }
  .abas button.ativo::before { background: #6ee7a8; }
  .abas .contador { background: #fff; color: #0b4a31; }
  .topo { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Modelo B: cards de números coloridos */
.stat.clicavel.tom-acc, .stat.clicavel.tom-alta, .stat.clicavel.tom-media, .stat.clicavel.tom-and { border-color: transparent; color: #fff; }
.stat.clicavel.tom-acc { background: #0f7a4a; }
.stat.clicavel.tom-alta { background: #c62828; }
.stat.clicavel.tom-media { background: #b86a00; }
.stat.clicavel.tom-and { background: #1d5fb8; }
[data-tema="escuro"] .stat.clicavel.tom-acc { background: #136b43; }
[data-tema="escuro"] .stat.clicavel.tom-alta { background: #9e2626; }
[data-tema="escuro"] .stat.clicavel.tom-media { background: #8f5507; }
[data-tema="escuro"] .stat.clicavel.tom-and { background: #1f4f93; }
.stat.clicavel[class*="tom-"]:not(.tom-zero) b { color: #fff; }
.stat.clicavel[class*="tom-"]:not(.tom-zero) span { color: rgba(255, 255, 255, .85); }
.stat.clicavel[class*="tom-"]:not(.tom-zero) .stat-ico { background: rgba(255, 255, 255, .18); color: #fff; }
.stat.clicavel[class*="tom-"]:not(.tom-zero):hover { filter: brightness(1.08); border-color: transparent; }

/* ---------- Barras de ferramentas ---------- */
.barra { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.barra .busca { flex: 1 1 240px; }
.barra select { flex: 0 1 200px; width: auto; }
.barra .direita { margin-left: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.chip {
  padding: 7px 13px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--border-forte); color: var(--text); }
.chip.ativo { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip b { margin-left: 3px; opacity: .7; }
.chips.lojas {
  flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px;
  scrollbar-width: none;
}
.chips.lojas::-webkit-scrollbar { display: none; }
.chips.lojas .chip { flex-shrink: 0; }
.badge.loja { background: var(--and-soft); color: var(--and); }
@media (max-width: 600px) {
  .barra > .chips { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
  .barra > .chips::-webkit-scrollbar { display: none; }
  .barra > .chips .chip { flex-shrink: 0; }
  .barra > .btn { flex: 1; }
}

/* ---------- Menu "Mais" ---------- */
.grade-mais { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.item-mais {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center;
}
.item-mais svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.item-mais.ativo { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Início (painel) ---------- */
.hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px;
  margin-bottom: 16px;
}
.saudacao { font-size: 24px; }
.hero-data { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.hero-data::first-letter { text-transform: uppercase; }
.hero-data strong { color: var(--accent); }
.hero-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-whats .ico { color: #1fa855; }
@media (max-width: 600px) {
  .hero-acoes { width: 100%; }
  .hero-acoes .btn { flex: 1; }
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.clicavel {
  display: flex; align-items: center; gap: 14px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat.clicavel:hover { border-color: var(--border-forte); transform: translateY(-1px); }
.stat-txt { display: flex; flex-direction: column; min-width: 0; }
.stat-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); color: var(--muted);
}
.stat-ico .ico { width: 22px; height: 22px; }
.tom-acc .stat-ico { background: var(--accent-soft); color: var(--accent); }
.tom-alta .stat-ico { background: var(--alta-soft); color: var(--alta); }
.tom-alta b { color: var(--alta); }
.tom-media .stat-ico { background: var(--media-soft); color: var(--media); }
.tom-media b { color: var(--media); }
.tom-and .stat-ico { background: var(--and-soft); color: var(--and); }
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat.clicavel { gap: 10px; padding: 12px; }
  .stat b { font-size: 24px; }
  .stat-ico { width: 36px; height: 36px; border-radius: 10px; }
  .stat-ico .ico { width: 19px; height: 19px; }
}

.grade-inicio { display: grid; gap: 14px; margin-bottom: 14px; }
.grade-inicio .painel { margin-bottom: 0; }
@media (min-width: 900px) { .grade-inicio { grid-template-columns: 1fr 1fr; align-items: start; } }

.painel-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.painel-cab h3 { margin: 0; }
.painel-num {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 99px; background: var(--surface-2);
  color: var(--muted); font-size: 12px; font-weight: 700; line-height: 24px; text-align: center;
}
.vazio-mini { margin: 4px 0; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }

.lojas-barras { display: flex; flex-direction: column; gap: 2px; }
.loja-barra {
  display: grid; grid-template-columns: minmax(96px, 130px) 1fr 28px; align-items: center; gap: 12px;
  padding: 8px 6px; border: 0; border-radius: 8px; background: none; color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.loja-barra:hover { background: var(--surface-2); }
.loja-barra.zerado { color: var(--muted); }
.loja-barra .rot { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loja-barra .num { text-align: right; font-variant-numeric: tabular-nums; }

.chip.zerado { opacity: .55; }
.linha-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px;
  border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: inherit; text-align: left;
}
.painel h3 + .linha-item, .painel-cab + .linha-item { border-top: 0; }
button.linha-item { cursor: pointer; border-radius: 0; }
button.linha-item:hover strong { color: var(--accent); }
.li-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-texto strong { overflow-wrap: anywhere; font-weight: 600; }
.li-texto small { color: var(--muted); font-size: 12.5px; }
.ponto { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ponto.pri-alta { background: var(--alta); box-shadow: 0 0 0 3px var(--alta-soft); }
.ponto.pri-media { background: var(--media); box-shadow: 0 0 0 3px var(--media-soft); }
.ponto.pri-baixa { background: var(--baixa); box-shadow: 0 0 0 3px var(--baixa-soft); }
.ativ { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.painel h3 + .ativ, .painel-cab + .ativ { border-top: 0; }
.ativ time { color: var(--muted); flex: 0 0 84px; font-size: 12.5px; }
.card.destaque, .dem.destaque { animation: destaque 1.6s ease-out; }
@keyframes destaque { 0%, 30% { box-shadow: inset 0 0 0 2px var(--accent); } 100% { box-shadow: none; } }

/* ---------- Demandas: lista compacta ---------- */
.lista-dem {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.lista-dem > .vazio { border: 0; border-radius: 0; }
.dem { position: relative; border-top: 1px solid var(--border); }
.dem:first-child { border-top: 0; }
.dem::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--baixa); }
.dem.p-alta::before { background: var(--alta); }
.dem.p-media::before { background: var(--media); }
.dem.aberta { background: var(--surface-2); }
.dem-linha { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; }
.dem-abrir {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 10px 6px 10px 14px;
  border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.dem-abrir:hover .dem-titulo { color: var(--accent); }
.dem-titulo { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.selo-urg {
  display: inline-block; margin-right: 7px; padding: 1px 7px; border-radius: 99px; vertical-align: 1px;
  background: var(--alta-soft); color: var(--alta); font-style: normal; font-size: 11px; font-weight: 700;
}
.dem-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.dem-sub .badge { padding: 1px 7px; }
.tag-loja { font-weight: 700; font-size: 11.5px; letter-spacing: .02em; color: var(--and); }
.sub-and {
  flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 8px; border-left: 2px solid var(--and-soft);
}
.dem.p-ok::before { background: var(--accent); }
.sub-sol { flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dem-seta { flex-shrink: 0; display: grid; place-items: center; width: 28px; color: var(--muted); transition: transform .15s; }
.dem.aberta .dem-seta { transform: rotate(90deg); }
.dem.aberta .sub-sol, .dem.aberta .sub-and { display: none; }
.txt-alta { color: var(--alta); font-weight: 700; }

/* ---------- Acessos remotos (AnyDesk) ---------- */
.dem.acesso::before { display: none; }
.dem.acesso .dem-linha { padding: 8px 12px; gap: 12px; }
.dem.acesso .dem-abrir { padding: 4px 0; cursor: default; }
.dem.acesso .dem-abrir:hover .dem-titulo { color: inherit; }
.acesso-ico {
  width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.id-anydesk { font-family: ui-monospace, Consolas, monospace; font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: .02em; }
.acesso-acoes { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
a.btn { text-decoration: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-anydesk { color: #ef443b; }
.link-li { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.id-anydesk + .id-anydesk { margin-left: 10px; font-weight: 500; color: var(--muted); }

/* Tela remota: ocupa a janela toda, sempre escura */
.tela-remota { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #0b0f0d; color: #e6ede9; }
.tela-remota[hidden] { display: none; }
.tr-barra { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: #0b4a31; flex-shrink: 0; }
.tr-titulo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tr-titulo strong { font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-titulo span { font-size: 12px; color: rgba(255, 255, 255, .65); font-family: ui-monospace, Consolas, monospace; }
.tr-estado { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, .12); color: #fff; }
.tr-estado:empty { display: none; }
.tr-estado.ok { background: #1f8a55; }
.tr-estado.erro { background: #c62828; }
.tr-acoes { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.tr-acoes .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.tr-acoes .btn:hover { background: rgba(255, 255, 255, .2); }
.tr-acoes .tr-sair { background: #c62828; border-color: #c62828; }
.tr-acoes .tr-sair:hover { background: #a82020; }
.tr-area { flex: 1; min-height: 0; overflow: hidden; }
.tr-area.real { overflow: auto; }
@media (max-width: 600px) {
  .dem.acesso .dem-linha { flex-wrap: wrap; }
  .dem.acesso .dem-abrir { flex: 1 1 calc(100% - 50px); }
  .acesso-acoes { flex: 1 1 100%; padding-left: 50px; }
  .acesso-acoes .btn.primario { flex: 1; }
}
.txt-media { color: var(--media); font-weight: 700; }
.dem-status { flex-shrink: 0; }
.btn-check {
  flex-shrink: 0; width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border-forte); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-check:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-check .ico { width: 18px; height: 18px; stroke-width: 2.4; }
.dem-detalhe { padding: 0 16px 14px 20px; }
.dem-detalhe .meta { margin-top: 0; }
.dem-detalhe .acoes { margin-top: 12px; }
@media (max-width: 600px) {
  .dem-status { display: none; }
  .dem-titulo { font-size: 14.5px; }
  .dem-detalhe .acoes .btn { flex: 1 1 auto; }
}

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 12px; display: flex; flex-direction: column; }
.timeline li::before {
  content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
.timeline time { font-size: 12px; color: var(--muted); }
.timeline li.coment span { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.timeline li.coment::before { background: var(--and); }
.timeline li.coment .btn { align-self: flex-start; margin-top: 2px; min-height: 28px; }

/* ---------- Andamento (comentários) ---------- */
.ultimo-andamento {
  display: flex; flex-direction: column; gap: 2px; width: 100%; margin-top: 10px; padding: 9px 12px;
  border: 0; border-left: 3px solid var(--and); border-radius: 8px; background: var(--and-soft);
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.ultimo-andamento strong { font-size: 12px; color: var(--and); }
.ultimo-andamento span { white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.andamento-resolver { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--and-soft); font-size: 14px; }
.andamento-resolver ul { margin: 6px 0 8px; padding-left: 18px; }
.andamento-resolver li { white-space: pre-wrap; overflow-wrap: anywhere; }
.andamento-resolver time { color: var(--muted); font-size: 12px; }

.prog-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prog-topo span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-trilho { height: 8px; margin-top: 8px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.prog-barra { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s; }
.uso-plano {
  margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 14px;
}
.uso-plano:last-child { margin-bottom: 0; }
.uso-plano .prog-topo span { color: var(--muted); }
.uso-plano .prog-trilho { background: var(--surface-3); }
.uso-plano small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.uso-alerta .prog-barra { background: var(--media); }
.uso-critico .prog-barra { background: var(--alta); }
.uso-critico strong { color: var(--alta); }
@media (min-width: 900px) {
  #uso-plano { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  #uso-plano h3 { grid-column: 1 / -1; }
  #uso-plano .uso-plano { margin-bottom: 0; }
}
.grupo-busca { margin-top: 14px; }
.grupo-busca h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.grupo-busca .li-texto small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.linha-item { text-decoration: none; }
#res-busca { min-height: 120px; }
#texto-whats { font-family: inherit; font-size: 14px; }

/* ---------- Rotinas e prazos ---------- */
.badge.rotina { background: var(--accent-soft); color: var(--accent); }
.prazo { margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--media); }
.prazo.atrasada { color: var(--alta); }
.dica { margin: -4px 0 4px; font-size: 12.5px; }

/* ---------- Notas confidenciais (cofre) ---------- */
.badge.nota-cofre { background: var(--media-soft); color: var(--media); }
.nota-segura { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.nota-segura.oculta { color: var(--muted); letter-spacing: 2px; }

/* ---------- Links ---------- */
.grupo-links + .grupo-links { margin-top: 22px; }
.titulo-grupo { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.titulo-grupo span { font-weight: 600; opacity: .7; }
.grade-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.link-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0;
  transition: border-color .15s;
}
.link-card:hover { border-color: var(--border-forte); }
.link-abrir { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-width: 0; }
.link-abrir:hover strong { color: var(--accent); }
.avatar {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 17px;
}
.link-texto { min-width: 0; display: flex; flex-direction: column; }
.link-texto strong, .link-texto small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-texto small { color: var(--muted); font-size: 12px; }
.link-desc { margin: 8px 0 0; font-size: 13px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.acoes-link { display: flex; gap: 2px; margin-top: 8px; margin-left: 46px; }

.contagem { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.titulo-secao { font-size: 19px; margin-bottom: 4px; }
.desc-secao { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* ---------- Cartões (histórico, notas, senhas) ---------- */
.lista { display: flex; flex-direction: column; gap: 10px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px 14px 18px; box-shadow: var(--shadow); overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.card.borda-alta::before { background: var(--alta); }
.card.borda-media::before { background: var(--media); }
.card.borda-baixa::before { background: var(--baixa); }
.card.borda-ok::before { background: var(--accent); }
.card-topo { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 10px; }
.card h3 { font-size: 15.5px; font-weight: 650; overflow-wrap: anywhere; flex: 1 1 180px; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; letter-spacing: .01em; }
.pri-alta { background: var(--alta-soft); color: var(--alta); }
.pri-media { background: var(--media-soft); color: var(--media); }
.pri-baixa { background: var(--baixa-soft); color: var(--baixa); }
.st-aberta { background: var(--surface-3); color: var(--muted); }
.st-andamento { background: var(--and-soft); color: var(--and); }
.st-resolvida { background: var(--accent-soft); color: var(--accent); }
.meta { margin-top: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.texto { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.texto.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.acoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.solucao {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--accent-soft); overflow-wrap: anywhere; font-size: 14px;
}
.solucao div { white-space: pre-wrap; }
.solucao div + div { margin-top: 6px; }
.solucao strong { color: var(--accent); }

.alerta {
  display: block; width: 100%; text-align: left; margin-top: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px dashed var(--media);
  background: var(--media-soft); color: var(--media); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

.sugestoes { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--media-soft); font-size: 14px; }
.sugestoes > strong { color: var(--media); display: block; margin-bottom: 6px; }
.sugestoes details { padding: 6px 0; border-top: 1px solid var(--border); }
.sugestoes summary { cursor: pointer; font-weight: 600; }
.sugestoes summary span { font-weight: 400; color: var(--muted); }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag {
  border: 0; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}

.vazio {
  text-align: center; padding: 44px 16px; color: var(--muted);
  border: 1px dashed var(--border-forte); border-radius: var(--radius); background: var(--surface);
}

/* ---------- Senhas ---------- */
.cofre-form {
  max-width: 400px; margin: 24px auto; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.cofre-form h2 { font-size: 20px; }
.cofre-form p { margin: 0; color: var(--muted); font-size: 14px; }
.cofre-form .atencao { background: var(--alta-soft); color: var(--alta); padding: 10px 12px; border-radius: var(--radius-sm); }
.campo-senha { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.campo-senha code { font-size: 15px; padding: 4px 8px; overflow-wrap: anywhere; }
.campo-senha .rotulo { color: var(--muted); font-size: 13px; min-width: 56px; }
.entrada-senha { display: flex; gap: 6px; }
.entrada-senha input { flex: 1; font-family: ui-monospace, Consolas, monospace; }

/* ---------- Painéis e relatório ---------- */
.painel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.painel h3 { font-size: 15px; font-weight: 650; margin-bottom: 12px; }
.barras { display: flex; flex-direction: column; gap: 9px; }
.barra-item { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.barra-item .rot { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trilho { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.preench { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.barra-item .num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.recorrente {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.recorrente:first-of-type { border-top: 0; }
.recorrente .vezes { font-weight: 800; color: var(--media); white-space: nowrap; }

/* ---------- Janelas (formulários) ---------- */
dialog {
  width: min(580px, calc(100% - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-alto);
}
dialog[open] { animation: abrir .18s ease-out; }
@keyframes abrir { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(8, 14, 11, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-form header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-form header h2 { font-size: 17px; }
.modal-form .x {
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0;
}
.modal-form .x:hover { background: var(--surface-3); color: var(--text); }
.modal-corpo { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-form footer {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px;
  border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px;
}
.linha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#sugestoes:empty { display: none; }
.resumo { margin: 0; }

/* Celular: a janela vira uma folha que sobe de baixo */
@media (max-width: 600px) {
  dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92vh;
    border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  dialog[open] { animation: subir .22s ease-out; }
  @keyframes subir { from { transform: translateY(40px); opacity: .4; } }
  .modal-form { max-height: 92vh; }
  .modal-form header { position: relative; padding-top: 20px; }
  .modal-form header::before {
    content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px;
    border-radius: 4px; background: var(--border-forte);
  }
  .modal-form footer { border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-form footer .btn { flex: 1; min-height: 46px; }
  .linha { grid-template-columns: 1fr; }
}

/* ---------- Toast ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px);
}
.toast {
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-alto); max-width: 100%;
  animation: abrir .2s ease-out;
}
.toast.erro { background: var(--alta); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Relatório mensal (só aparece na impressão / PDF) ---------- */
#impressao { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  html, body { background: #fff !important; color: #111 !important; }
  body > *:not(#impressao) { display: none !important; }
  #impressao { display: block; font-size: 10pt; line-height: 1.4; color: #111; }
  #impressao * { color: #111; }
  .imp-topo { display: flex; align-items: center; gap: 16px; padding-bottom: 10px; border-bottom: 2px solid #2e7b4d; }
  .imp-topo img { height: 52px; width: auto; }
  .imp-topo h1 { font-size: 17pt; margin: 0; }
  .imp-topo p { margin: 2px 0 0; color: #555 !important; text-transform: capitalize; }
  .imp-stats { display: flex; gap: 8px; margin: 14px 0 6px; }
  .imp-stats div { flex: 1; border: 1px solid #ccc; border-radius: 6px; padding: 8px; }
  .imp-stats b { display: block; font-size: 15pt; }
  .imp-stats span { font-size: 8.5pt; color: #555 !important; }
  #impressao h2 { font-size: 11.5pt; margin: 16px 0 6px; color: #2e7b4d !important; break-after: avoid; }
  #impressao table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  #impressao th, #impressao td { border-bottom: 1px solid #ddd; padding: 4px 6px; text-align: left; vertical-align: top; }
  #impressao th { background: #f0f4f1; font-weight: 700; }
  #impressao tr { break-inside: avoid; }
  .imp-vazio { color: #777 !important; font-style: italic; margin: 0; }
  .imp-total { text-align: right; margin: 6px 0 0; }
  .imp-rodape { margin-top: 20px; padding-top: 6px; border-top: 1px solid #ccc; font-size: 8pt; color: #777 !important; }
}
