/* =========================================================
   Cobrança Automática: visual moderno, claro/escuro, responsivo
   Telas: celular (até 760px), tablet (761–1100px), desktop e telas grandes
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --txt: #0f172a;
  --muted: #64748b;
  --borda: #e6eaf2;
  --borda-forte: #d3d9e6;

  --pri: #059669;
  --pri-h: #047857;
  --pri-sua: #d1fae5;
  --pri-txt: #065f46;
  --btn: linear-gradient(135deg, #10b981, #059669);
  --btn-h: linear-gradient(135deg, #059669, #047857);

  --perigo: #dc2626;
  --perigo-sua: #fee2e2;
  --perigo-txt: #991b1b;
  --aviso: #b45309;
  --aviso-sua: #fef3c7;
  --aviso-txt: #92400e;
  --info-sua: #e0f2fe;
  --info-txt: #075985;

  --escuro: #0f172a;
  --zap: #dcf8c6;
  --zap-txt: #111827;
  --codigo-bg: #eef1f7;

  --raio: 16px;
  --raio-sm: 11px;
  --sombra: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px -8px rgba(15, 23, 42, .08);
  --sombra-lg: 0 24px 60px -16px rgba(15, 23, 42, .35);
  --anel: 0 0 0 3px rgba(5, 150, 105, .22);
  --lateral: 264px;
}

/* escuro: automático pelo sistema, ou escolhido no botão do menu */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="light"]) {
    color-scheme: dark;
    --bg: #0a0f1e; --card: #121a30; --card-2: #17213b; --txt: #e8ecf6; --muted: #98a3ba;
    --borda: #222c47; --borda-forte: #33415f;
    --pri: #34d399; --pri-h: #10b981; --pri-sua: rgba(52, 211, 153, .15); --pri-txt: #6ee7b7;
    --perigo: #f87171; --perigo-sua: rgba(248, 113, 113, .15); --perigo-txt: #fca5a5;
    --aviso: #fbbf24; --aviso-sua: rgba(251, 191, 36, .15); --aviso-txt: #fcd34d;
    --info-sua: rgba(56, 189, 248, .15); --info-txt: #7dd3fc;
    --escuro: #060a15; --zap: #1d3b2c; --zap-txt: #e6f4ea; --codigo-bg: #1a2440;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    --sombra-lg: 0 24px 60px -16px rgba(0, 0, 0, .7);
    --anel: 0 0 0 3px rgba(52, 211, 153, .3);
  }
}
:root[data-tema="dark"] {
  color-scheme: dark;
  --bg: #0a0f1e; --card: #121a30; --card-2: #17213b; --txt: #e8ecf6; --muted: #98a3ba;
  --borda: #222c47; --borda-forte: #33415f;
  --pri: #34d399; --pri-h: #10b981; --pri-sua: rgba(52, 211, 153, .15); --pri-txt: #6ee7b7;
  --perigo: #f87171; --perigo-sua: rgba(248, 113, 113, .15); --perigo-txt: #fca5a5;
  --aviso: #fbbf24; --aviso-sua: rgba(251, 191, 36, .15); --aviso-txt: #fcd34d;
  --info-sua: rgba(56, 189, 248, .15); --info-txt: #7dd3fc;
  --escuro: #060a15; --zap: #1d3b2c; --zap-txt: #e6f4ea; --codigo-bg: #1a2440;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  --sombra-lg: 0 24px 60px -16px rgba(0, 0, 0, .7);
  --anel: 0 0 0 3px rgba(52, 211, 153, .3);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: clamp(14px, .875rem + .12vw, 16px); line-height: 1.5;
  background: var(--bg); color: var(--txt);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
a { color: var(--pri-h); }
h1 { font-size: clamp(22px, 1.2rem + 1vw, 30px); font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin: 0; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { letter-spacing: -.01em; }
p { margin: 0 0 12px; }
form { margin: 0; }
small, .muted { color: var(--muted); font-size: .9em; }
code { background: var(--codigo-bg); padding: 2px 7px; border-radius: 6px; font-size: .88em; }
::selection { background: var(--pri-sua); }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 18px; border: 0; border-radius: var(--raio-sm); text-decoration: none;
  background: var(--btn); color: #fff; font-weight: 650; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(5, 150, 105, .25), 0 6px 14px -6px rgba(5, 150, 105, .55);
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--btn-h); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-light { background: var(--card); color: var(--txt); border: 1px solid var(--borda-forte); box-shadow: none; }
.btn-light:hover { background: var(--card-2); border-color: var(--muted); }
.btn-danger { background: var(--perigo); box-shadow: none; }
.btn-danger:hover { background: #b91c1c; }
.btn-link { background: none; color: var(--perigo); padding: 0 10px; font-weight: 550; box-shadow: none; }
.btn-link:hover { background: var(--perigo-sua); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .9em; border-radius: 9px; }
.btn-bloco { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-icone {
  display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 10px; background: none; color: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.btn-icone svg { width: 19px; height: 19px; }

/* ---------- campos ---------- */
.campos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group label { font-size: .93em; font-weight: 600; }
.cheio { grid-column: 1 / -1; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 13px;
  border: 1px solid var(--borda-forte); border-radius: var(--raio-sm); background: var(--card); color: var(--txt);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--pri); box-shadow: var(--anel); }
input:disabled, input[readonly] { background: var(--card-2); color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: .93em; cursor: pointer; }
.check input { width: 19px; height: 19px; accent-color: var(--pri); margin: 0; flex: none; }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 48px !important; min-height: 28px !important; height: 28px; padding: 0 !important; border: 0 !important;
  border-radius: 99px; background: var(--borda-forte); position: relative; transition: background .2s; box-shadow: none !important;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch:checked { background: #10b981; }
.switch:checked::after { left: 23px; }
.linha-switch {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--borda); cursor: pointer;
}
.linha-switch span { display: flex; flex-direction: column; }

/* ---------- avisos ---------- */
.alert { border-radius: var(--raio-sm); padding: 13px 16px; margin-bottom: 16px; font-size: .95em; border: 1px solid transparent; border-left-width: 4px; }
.alert-success { background: var(--pri-sua); color: var(--pri-txt); border-color: var(--pri); }
.alert-danger { background: var(--perigo-sua); color: var(--perigo-txt); border-color: var(--perigo); }
.alert-warning { background: var(--aviso-sua); color: var(--aviso-txt); border-color: var(--aviso); }
.alert a { color: inherit; }
.info { background: var(--info-sua); color: var(--info-txt); border-radius: var(--raio-sm); padding: 11px 14px; font-size: .93em; margin-top: 14px; }
.info.ok { background: var(--pri-sua); color: var(--pri-txt); }
.info.erro { background: var(--perigo-sua); color: var(--perigo-txt); }
.info details { margin-top: 8px; }
.info summary { cursor: pointer; font-weight: 600; }
.info p { margin: 8px 0 0; }
.cmd { display: block; margin-top: 8px; padding: 11px 12px; background: #0b1224; color: #e2e8f0; border-radius: var(--raio-sm); word-break: break-all; }

/* ---------- layout: menu lateral ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--lateral); z-index: 30;
  display: flex; flex-direction: column; gap: 6px; padding: 20px 14px 14px;
  background: linear-gradient(180deg, var(--escuro), #0b1326 120%); color: #cbd5e1;
  border-right: 1px solid rgba(255, 255, 255, .04); overflow-y: auto; overscroll-behavior: contain;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sidebar .brand { padding: 2px 8px 16px; }
.brand-icon {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 11px; background: var(--btn); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -.02em;
  box-shadow: 0 6px 16px -4px rgba(16, 185, 129, .6);
}
.brand-icon.grande { width: 60px; height: 60px; font-size: 20px; border-radius: 18px; margin: 0 auto 16px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-copy strong { font-size: 16px; color: #fff; letter-spacing: -.01em; }
.brand-copy span { font-size: 12px; color: #7c8aa5; }

.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu-grupo { display: flex; flex-direction: column; gap: 2px; }
.menu-titulo { padding: 16px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #5f6e8a; }
.menu a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: #94a3b8; text-decoration: none; font-weight: 550; transition: background .15s ease, color .15s ease;
}
.menu a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.menu a.ativo { color: #fff; background: rgba(16, 185, 129, .16); }
.menu a.ativo::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: #34d399;
}
.menu a.ativo svg { color: #34d399; }
.menu svg { width: 20px; height: 20px; flex: none; }

.sidebar-user {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 14px 6px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .93em;
}
.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 700;
}
.sidebar-user-nome { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-user-nome strong { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-nome span { color: #7c8aa5; font-size: 12px; }
.sidebar .btn-icone { color: #94a3b8; }
.sidebar .btn-icone:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.mobile-top { display: none; }
.content {
  min-width: 0; margin-left: var(--lateral);
  padding: clamp(18px, 3vw, 40px) clamp(16px, 3.2vw, 44px) 64px;
}
.content > :not(dialog) { max-width: 1320px; margin-left: auto; margin-right: auto; }
.cab { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.cab-acoes { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- cartões e resumo ---------- */
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: clamp(16px, 2vw, 24px); box-shadow: var(--sombra); min-width: 0; }
.card > .btn[type=submit] { margin-top: 18px; }
.resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  position: relative; overflow: hidden; min-width: 0; padding: 18px 18px 16px;
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra);
  transition: transform .18s ease, box-shadow .18s ease;
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--borda-forte); }
.kpi.ok::before { background: linear-gradient(90deg, #10b981, #34d399); }
.kpi.perigo::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.kpi.aviso::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.kpi span { display: block; color: var(--muted); font-size: .88em; font-weight: 550; }
.kpi strong {
  display: block; margin: 6px 0 4px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 1rem + .9vw, 28px); font-weight: 750; letter-spacing: -.02em; line-height: 1.15;
}
.kpi small { display: block; color: var(--muted); font-size: .82em; }
.kpi.perigo strong { color: var(--perigo); }
.kpi.aviso strong { color: var(--aviso); }
.kpi.ok strong { color: var(--pri); }

/* ---------- filtros ---------- */
.filtros { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: flex; gap: 3px; padding: 4px; background: var(--card-2); border: 1px solid var(--borda); border-radius: 13px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a { padding: 7px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; text-decoration: none; transition: background .15s ease, color .15s ease; }
.seg a:hover { color: var(--txt); }
.seg a.ativo { background: var(--card); color: var(--txt); box-shadow: var(--sombra); }
.filtros input[type=search] { flex: 1; min-width: 200px; max-width: 380px; }
.filtros input[type=date] { width: auto; }

/* ---------- tabelas ---------- */
.card.lista { padding: 0; overflow-x: auto; }
.tabela td.titulo { white-space: nowrap; }
.tabela { width: 100%; border-collapse: collapse; font-size: .95em; }
.tabela th {
  text-align: left; font-size: .76em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; padding: 13px 18px; background: var(--card-2); border-bottom: 1px solid var(--borda); white-space: nowrap;
}
.tabela td { padding: 13px 18px; border-bottom: 1px solid var(--borda); vertical-align: middle; overflow-wrap: anywhere; }
.tabela tbody tr { transition: background .12s ease; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabela td.acoes { text-align: right; white-space: nowrap; }
.tabela.compacta th, .tabela.compacta td { padding: 10px 8px; }
.acoes-in { display: inline-flex; gap: 6px; align-items: center; }
.sub { display: block; color: var(--muted); font-size: .88em; font-weight: 400; }
.vazio { padding: 44px 16px; text-align: center; color: var(--muted); margin: 0; }

.tag { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 99px; font-size: .8em; font-weight: 650; white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; opacity: .85; }
.tag.pago { background: var(--pri-sua); color: var(--pri-txt); }
.tag.pendente { background: var(--card-2); color: var(--muted); border: 1px solid var(--borda); }
.tag.hoje { background: var(--aviso-sua); color: var(--aviso-txt); }
.tag.atrasado { background: var(--perigo-sua); color: var(--perigo-txt); }
.tag.pausado { background: var(--card-2); color: var(--muted); border: 1px solid var(--borda); }

/* ---------- dashboard ---------- */
.saudacao { margin: 0 0 4px; }
.saudacao-sub { margin: 0 0 22px; color: var(--muted); }
.avisos { display: grid; gap: 10px; margin-bottom: 20px; }
.avisos .alert { margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.avisos .alert a { font-weight: 700; white-space: nowrap; }
.dash-titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.dash-titulo h2 { margin: 0; }
.dash-titulo small, .dash-titulo a { color: var(--muted); font-size: .9em; }
.dash-titulo a { font-weight: 650; color: var(--pri-h); text-decoration: none; }
.atalhos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr)); gap: 12px; }
.atalho {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; min-width: 0;
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra);
  color: var(--txt); font-weight: 650; text-decoration: none; line-height: 1.25;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.atalho svg { width: 40px; height: 40px; padding: 10px; border-radius: 12px; background: var(--pri-sua); color: var(--pri); flex: none; }
.atalho small { display: block; color: var(--muted); font-weight: 450; font-size: .82em; margin-top: 2px; }
.atalho.destaque { background: var(--btn); color: #fff; border-color: transparent; box-shadow: 0 10px 24px -10px rgba(5, 150, 105, .7); }
.atalho.destaque svg { background: rgba(255, 255, 255, .2); color: #fff; }
.atalho.destaque small { color: rgba(255, 255, 255, .85); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid .card { padding: clamp(16px, 1.6vw, 22px); }
.dash-grid h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.card-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card-cab a { font-size: .88em; font-weight: 650; white-space: nowrap; text-decoration: none; }
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--borda); }
.mini li:last-child { border-bottom: 0; padding-bottom: 2px; }
.mini .quem { min-width: 0; }
.mini .quem strong { display: block; overflow-wrap: anywhere; }
.mini .quanto { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini .quanto strong { display: block; }
.mini-vazio { margin: 0; padding: 22px 0; text-align: center; color: var(--muted); }
.barras { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(6px, 1.4vw, 14px); align-items: end; height: clamp(150px, 18vw, 220px); margin-top: 10px; }
.barra-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; min-width: 0; }
.barra-par { display: flex; align-items: flex-end; gap: 4px; width: 100%; height: 100%; justify-content: center; }
.barra-par i { display: block; width: 42%; max-width: 30px; min-height: 3px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #34d399, #059669); transition: height .4s ease; }
.barra-par i.saida { background: linear-gradient(180deg, #f87171, #dc2626); }
.barra-col span { font-size: .8em; color: var(--muted); text-transform: capitalize; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88em; color: var(--muted); margin-top: 12px; }
.legenda b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: #10b981; }
.legenda b.saida { background: #ef4444; }
.estado { display: grid; gap: 2px; }
.estado div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borda); }
.estado div:last-child { border-bottom: 0; }

/* ---------- relatórios ---------- */
.sec-cab { margin: 28px auto 12px; }
.sec-cab h2 { margin: 0; }
.print-only { display: none; }

/* ---------- ajustes ---------- */
.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cheio-grade { grid-column: 1 / -1; }
.form-linha { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.form-linha input { flex: 1 1 160px; width: auto; }

/* ---------- mensagens ---------- */
.msg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-top: 18px; align-items: start; }
.msg { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.msg header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.msg header strong { display: block; }
.msg footer { display: flex; justify-content: space-between; align-items: center; }
.msg.inativa { opacity: .6; }
.zap {
  background: var(--zap); color: var(--zap-txt); border-radius: 14px 14px 14px 3px; padding: 11px 14px;
  font-size: .93em; line-height: 1.45; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto;
}
.msg .zap { max-height: 190px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip {
  border: 1px solid var(--borda-forte); background: var(--card-2); border-radius: 99px; padding: 4px 11px;
  font-size: .8em; cursor: pointer; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.chip:hover { background: var(--pri-sua); border-color: var(--pri); }
.teste-box { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--borda-forte); }
.teste-box > label { font-size: .93em; font-weight: 600; display: block; margin-bottom: 8px; }
.teste-box .form-linha { margin-bottom: 0; }

/* ---------- contratos anexados ---------- */
input[type=file] { padding: 8px 10px; min-height: 0; cursor: pointer; }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 7px 14px; border: 1px solid var(--borda-forte); border-radius: 9px;
  background: var(--card-2); color: var(--txt); font-weight: 600; cursor: pointer;
}
.contrato-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin-top: 6px; border: 1px solid var(--borda); border-radius: var(--raio-sm); background: var(--card-2);
}
.contrato-item a:not(.btn) { font-weight: 600; overflow-wrap: anywhere; min-width: 0; flex: 1 1 180px; }
.contrato-item.ativo { border-color: var(--pri); background: var(--pri-sua); }
.contrato-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.contrato-info strong { overflow-wrap: anywhere; }

/* visualizador de contratos: lista à esquerda, arquivo à direita */
dialog.visualizador { width: min(1120px, calc(100% - 32px)); }
.dlg-corpo { padding: clamp(18px, 3vw, 28px); }
.visualizador-grade { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.visualizador-lista { display: flex; flex-direction: column; gap: 2px; max-height: 68vh; overflow-y: auto; }
.visualizador-lista .contrato-item { flex-direction: column; align-items: stretch; }
.visualizador-lista .acoes-in { flex-wrap: wrap; }
.visualizador-tela { min-height: 300px; border: 1px solid var(--borda); border-radius: var(--raio-sm); background: var(--card-2); overflow: hidden; }
.visualizador-tela iframe { display: block; width: 100%; height: min(70vh, 760px); border: 0; background: #fff; }
.visualizador-aviso { display: grid; place-content: center; justify-items: center; gap: 12px; min-height: 300px; padding: 24px; text-align: center; color: var(--muted); }
@media (max-width: 900px) {
  .visualizador-grade { grid-template-columns: minmax(0, 1fr); }
  .visualizador-lista { max-height: 32vh; }
  .visualizador-tela iframe { height: 56vh; }
}

/* ---------- janelas ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 0; background: var(--card); color: var(--txt);
  width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  box-shadow: var(--sombra-lg);
}
dialog.grande { width: min(700px, calc(100% - 32px)); }
dialog[open] { animation: dlg-pop .2s ease-out; }
dialog::backdrop { background: rgba(8, 12, 24, .55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
dialog[open]::backdrop { animation: dlg-fade .2s ease-out; }
dialog form { padding: clamp(18px, 3vw, 28px); }
.dlg-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dlg-cab h2 { margin: 0; font-size: 19px; }
.fechar { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); width: 40px; height: 40px; border-radius: 12px; }
.fechar:hover { background: var(--card-2); color: var(--txt); }
.dlg-rodape { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
@keyframes dlg-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes dlg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlg-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes entrar { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content > :not(dialog) { animation: entrar .35s ease-out both; }

/* ---------- login / setup ---------- */
.login-page {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 8%, rgba(16, 185, 129, .22) 0, transparent 42%),
    radial-gradient(circle at 92% 92%, rgba(99, 102, 241, .22) 0, transparent 42%),
    var(--bg);
}
.login-box { width: 100%; max-width: 420px; }
.login-marca { text-align: center; margin-bottom: 22px; }
.login-marca p { color: var(--muted); margin: 6px 0 0; }
.login-form { display: grid; gap: 16px; padding: clamp(20px, 5vw, 30px); box-shadow: var(--sombra-lg); }
.login-form .alert { margin: 0; }
.senha-wrap { position: relative; }
.senha-wrap input { padding-right: 84px; }
.ver-senha {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); font-size: .9em; cursor: pointer; padding: 8px 10px; border-radius: 8px;
}
.ver-senha:hover { background: var(--card-2); color: var(--txt); }
.rodape-login { text-align: center; color: var(--muted); font-size: .88em; margin-top: 18px; }

/* =========================================================
   Interação só onde há mouse (não gruda no toque)
   ========================================================= */
@media (hover: hover) {
  .kpi:hover, .atalho:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -14px rgba(15, 23, 42, .3); }
  .atalho:not(.destaque):hover { border-color: var(--pri); }
  .tabela tbody tr:hover { background: var(--card-2); }
  .mini li:hover .quem strong { color: var(--pri-h); }
}

/* =========================================================
   Responsivo
   ========================================================= */

/* telas grandes: mais respiro e 3 colunas no dashboard */
@media (min-width: 1600px) {
  .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 2000px) {
  body { font-size: 17px; }
  .content > :not(dialog) { max-width: 1560px; }
}

/* desktop pequeno / notebook */
@media (max-width: 1280px) {
  .grade { grid-template-columns: minmax(0, 1fr); }
}

/* tablet: menu vira uma coluna só de ícones */
@media (max-width: 1100px) and (min-width: 761px) {
  :root { --lateral: 78px; }
  .sidebar { padding: 16px 12px; align-items: center; }
  .sidebar .brand { padding: 2px 0 12px; }
  .brand-copy, .menu-titulo, .menu a span, .sidebar-user-nome { display: none; }
  .menu { align-items: center; width: 100%; }
  .menu-grupo { width: 100%; align-items: center; }
  .menu-grupo + .menu-grupo { border-top: 1px solid rgba(255, 255, 255, .07); margin-top: 8px; padding-top: 8px; }
  .menu a { justify-content: center; width: 100%; padding: 12px 0; }
  .menu a.ativo::before { left: -12px; }
  .sidebar-user { flex-direction: column; padding: 14px 0 0; width: 100%; }
}

/* tabelas viram cartões empilhados */
@media (max-width: 900px) {
  .card.lista { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tabela thead { display: none; }
  .tabela, .tabela tbody, .tabela tr, .tabela td { display: block; width: 100%; }
  .tabela tr {
    background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio);
    padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--sombra);
  }
  .card .tabela tr { box-shadow: none; }
  .tabela td, .tabela.compacta td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 6px 0; border: 0; text-align: right; overflow-wrap: anywhere;
  }
  .tabela td::before { content: attr(data-label); color: var(--muted); font-size: .88em; text-align: left; flex: none; }
  .tabela td.titulo, .tabela.compacta td.titulo {
    display: block; text-align: left; font-weight: 700; font-size: 1.05em;
    padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--borda); white-space: normal;
  }
  .tabela td.titulo::before, .tabela td.acoes::before { display: none; }
  .tabela td.acoes { justify-content: flex-end; padding-top: 12px; }
  .acoes-in { flex-wrap: wrap; justify-content: flex-end; }
  .vazio { background: var(--card); border: 1px dashed var(--borda-forte); border-radius: var(--raio); }
}

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

/* celular: menu vira barra inferior, janelas viram folha deslizante */
@media (max-width: 760px) {
  :root { --raio: 14px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; } /* evita zoom automático no iPhone */

  .sidebar {
    inset: auto 0 0 0; width: auto; flex-direction: row; align-items: stretch; gap: 0; overflow: visible;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--card); background: color-mix(in srgb, var(--card) 90%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--borda); border-right: 0; box-shadow: 0 -6px 24px rgba(15, 23, 42, .08);
  }
  .sidebar .brand, .sidebar-user { display: none; }
  .menu { flex-direction: row; gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .menu::-webkit-scrollbar { display: none; }
  .menu-grupo { display: contents; }
  .menu-titulo { display: none; }
  .menu a {
    flex: 1 0 66px; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 2px 6px; min-height: 54px;
    font-size: 10.5px; color: var(--muted); border-radius: 12px; text-align: center; scroll-snap-align: center;
  }
  .menu a:hover { background: none; color: var(--muted); }
  .menu a.ativo { background: var(--pri-sua); color: var(--pri-txt); }
  .menu a.ativo svg { color: var(--pri); }
  .menu a.ativo::before { display: none; }
  .menu svg { width: 22px; height: 22px; }

  .mobile-top {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    background: var(--card); background: color-mix(in srgb, var(--card) 88%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--borda);
  }
  .mobile-top .brand strong { font-size: 17px; letter-spacing: -.01em; }
  .mobile-top .brand-icon { width: 34px; height: 34px; border-radius: 10px; }
  .mobile-top-acoes { display: flex; gap: 2px; }
  .mobile-top .btn-icone { color: var(--muted); width: 42px; height: 42px; }
  .mobile-top .btn-icone:hover { background: var(--card-2); color: var(--txt); }

  .content {
    margin-left: 0;
    padding: 18px max(16px, env(safe-area-inset-right)) calc(92px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .cab { margin-bottom: 18px; }
  .cab-acoes { width: 100%; }
  .cab-acoes > * { flex: 1; }
  .cab-acoes .btn { width: 100%; }
  .cab-acoes form { display: flex; flex: 1; }
  .filtros input[type=search] { max-width: none; min-width: 0; flex-basis: 100%; }
  .filtros input[type=date] { flex: 1; min-width: 0; }
  .seg { width: 100%; }
  .campos { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 14px 14px 12px; }
  .dash-titulo { margin-top: 24px; }

  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; }
  dialog[open] { animation: dlg-sheet .28s cubic-bezier(.2, .8, .2, 1); }
  dialog form, .dlg-corpo { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .dlg-rodape .btn { flex: 1; }
}

/* celulares pequenos */
@media (max-width: 560px) {
  .resumo { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .atalhos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .avisos .alert { flex-direction: column; align-items: flex-start; }
  .barras { gap: 5px; }
}
@media (max-width: 340px) {
  .resumo { grid-template-columns: minmax(0, 1fr) !important; }
}

/* celular deitado: barras mais baixas */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 900px) {
  .menu a { min-height: 44px; flex-direction: row; justify-content: center; font-size: 11px; }
  .menu a span { display: none; }
  .content { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* toque: alvos de 44px+ */
@media (pointer: coarse) {
  .btn { min-height: 46px; }
  .btn-sm { min-height: 40px; padding: 0 14px; }
  .seg a { padding: 9px 15px; }
  .fechar { width: 44px; height: 44px; }
}

/* ---------- movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- impressão: sempre claro e sem menus ---------- */
@media print {
  html, html[data-tema="dark"] {
    color-scheme: light;
    --bg: #fff; --card: #fff; --card-2: #f4f4f4; --txt: #000; --muted: #444; --borda: #ccc; --borda-forte: #bbb;
    --pri: #047857; --pri-sua: #e6f7ef; --pri-txt: #065f46; --perigo: #b91c1c; --aviso: #92400e;
  }
  body { background: #fff; }
  .sidebar, .mobile-top, .no-print, .cab-acoes { display: none !important; }
  .content { margin: 0; padding: 0; }
  .content > :not(dialog) { max-width: none; animation: none; }
  .print-only { display: block; }
  .card, .kpi { box-shadow: none; }
  .kpi::before { display: none; }
  .card.lista { overflow: visible; }
}
