:root {
    --bg: #f8fafc; --card-bg: #ffffff; --text: #0f172a; --text-muted: #64748b;
    --border: #e2e8f0; --primary: #0284c7; --primary-hover: #0369a1;
    --btn-table-bg: #e0f2fe; --btn-table-text: #0369a1; --btn-table-border: #bae6fd;
    --input-bg: #ffffff; --subbox-bg: #f1f5f9;
}
body.dark {
    --bg: #0f172a; --card-bg: #1e293b; --text: #f8fafc; --text-muted: #94a3b8;
    --border: #334155; --primary: #38bdf8; --primary-hover: #0284c7;
    --btn-table-bg: #0369a1; --btn-table-text: #e0f2fe; --btn-table-border: #0284c7;
    --input-bg: #0f172a; --subbox-bg: #0f172a;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-user-drag: none; }
body { background-color: var(--bg); color: var(--text); padding: 20px 10px; display: flex; justify-content: center; transition: background-color 0.3s ease, color 0.3s ease; }
img, svg { pointer-events: none; user-select: none; -webkit-user-select: none; }
input, select, textarea, .kv strong, .result-box, .aviso, .msg, .modal-body { user-select: text; -webkit-user-select: text; }
.app { width: 100%; max-width: 900px; }
.topo { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.topo-logo { display: flex; align-items: center; gap: 16px; }
.logo { max-width: 160px; height: auto; }
.eyebrow { font-size: 11px; font-weight: 700; color: var(--primary); letter-spacing: 1px; margin-bottom: 4px; }
.topo h1 { font-size: 22px; font-weight: 700; }
.topo p  { font-size: 14px; color: var(--text-muted); }
.topo-acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-ajuda, .btn-modo { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-ajuda:hover, .btn-modo:hover { background: var(--subbox-bg); color: var(--text); }
.tema { background: none; border: 1px solid var(--border); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.aviso { background-color: #fef3c7; border: 1px solid #fde047; color: #854d0e; padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 24px; line-height: 1.4; }
.msg { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.msg-erro  { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.msg-aviso { background: #fef9c3; border: 1px solid #fde047; color: #854d0e; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-title span { background-color: var(--primary); color: white; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; flex-shrink: 0; }
.card-title h2 { font-size: 16px; font-weight: 600; }
.card-title p  { font-size: 13px; color: var(--text-muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.grid-eletrico { display: flex; flex-wrap: nowrap; gap: 8px; }
.grid-eletrico label { flex: 1; min-width: 0; font-size: 11px; white-space: nowrap; }
.grid-eletrico input, .grid-eletrico select { padding: 6px; font-size: 12px; }
@media (max-width: 768px) { .grid-eletrico { flex-wrap: wrap; } .grid-eletrico label { min-width: 130px; } }
.modo-relacao { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.radio-inline { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.radio-inline input { width: auto; }
label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--text-muted); gap: 6px; position: relative; }
input, select { background-color: var(--input-bg); color: var(--text); border: 1px solid var(--border); padding: 8px 10px; border-radius: 6px; font-size: 13px; outline: none; width: 100%; transition: border-color 0.2s ease; }
input[readonly] { background: var(--subbox-bg); opacity: 0.85; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input.error, select.error { border-color: #ef4444; background-color: rgba(239, 68, 68, 0.05); }
.dica-campo { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 2px; min-height: 14px; }
.dica-campo.dica-alerta { color: #f97316; font-weight: 600; }
.campo-info { position: absolute; right: 0; top: 0; font-size: 12px; color: var(--primary); cursor: help; font-weight: normal; }
.campo-info .tooltip { display: none; position: absolute; right: 0; top: 20px; background: #1e293b; color: #f8fafc; padding: 8px 12px; border-radius: 6px; font-size: 11px; font-weight: normal; width: 220px; z-index: 50; line-height: 1.4; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.campo-info:hover .tooltip, .campo-info:focus .tooltip { display: block; }
.subbox { background-color: var(--subbox-bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 16px; }
.subbox h3 { font-size: 13px; margin-bottom: 12px; }
.avancado-box { background: rgba(2, 132, 199, 0.05); }
.btn-avancado { background: none; border: 1px dashed var(--border); color: var(--text-muted); padding: 10px 14px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; margin-top: 12px; width: 100%; }
.btn-avancado:hover { background: var(--subbox-bg); color: var(--text); }
.waiting { font-size: 13px; color: var(--text-muted); font-style: italic; padding: 10px 0; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.result-box { background-color: var(--subbox-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.result-box h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.kv { display: flex; justify-content: space-between; align-items: flex-start; font-size: 12px; margin-bottom: 8px; gap: 8px; }
.kv span { color: var(--text-muted); }
.kv strong { text-align: right; }
.sub-info { display: block; font-size: 11px; color: var(--text-muted); font-weight: normal; margin-top: 2px; }
.opcao-fio { background: rgba(249, 115, 22, 0.10); border-left: 3px solid #f97316; padding: 8px 10px; border-radius: 4px; position: relative; }
.opcao-fio-vertical { flex-direction: column; align-items: flex-start; gap: 2px; }
.opcao-fio-vertical .opcao-rotulo { font-size: 12px; color: var(--text-muted); font-weight: 600; display: block; line-height: 1.3; }
.opcao-fio-vertical .rotulo-texto { white-space: nowrap; }
.opcao-fio-vertical .icone-info { color: var(--primary); cursor: help; font-weight: normal; display: inline-block; margin-left: 2px; white-space: nowrap; position: relative; }
.opcao-fio-vertical .opcao-valor { font-size: 13px; text-align: left; display: block; line-height: 1.3; }
.opcao-fio-vertical .opcao-valor .sub-info { display: inline; margin-left: 4px; font-size: 11px; }
.opcao-fio .tooltip-inline { display: none; position: absolute; background: #1e293b; color: #f8fafc; padding: 8px 12px; border-radius: 6px; font-size: 11px; font-weight: normal; z-index: 100; line-height: 1.5; box-shadow: 0 4px 12px rgba(0,0,0,0.25); white-space: normal; width: 220px; top: 100%; left: 0; margin-top: 4px; text-align: left; }
.opcao-fio .icone-info:hover .tooltip-inline, .opcao-fio .icone-info:focus .tooltip-inline, .opcao-fio .icone-info:focus-within .tooltip-inline { display: block; }
.sugestoes-box { margin-top: 16px; background: #fef9c3; border: 1px solid #fde047; color: #854d0e; padding: 12px 16px; border-radius: 8px; font-size: 13px; }
.sugestoes-box h4 { margin-bottom: 8px; font-size: 13px; }
.sugestoes-box ul { margin-left: 18px; line-height: 1.6; }
.selo-status { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; background: var(--card-bg); border: 1px solid var(--border); }
.selo-status.selo-ok { background: #dcfce7; border-color: #86efac; color: #166534; }
.selo-status.selo-atencao { background: #fef3c7; border-color: #fde047; color: #854d0e; }
.selo-status.selo-erro { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.selo-icone { font-size: 32px; line-height: 1; }
.selo-texto strong { display: block; font-size: 15px; }
.selo-texto span { font-size: 12px; opacity: 0.85; }
.btn-detalhes { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; margin-bottom: 16px; width: 100%; }
.btn-detalhes:hover { background: var(--subbox-bg); color: var(--text); }
.detalhes-box { margin-bottom: 0; }
.status-verde    { border-left: 4px solid #16a34a; }
.status-amarelo  { border-left: 4px solid #facc15; }
.status-laranja  { border-left: 4px solid #f97316; }
.status-vermelho { border-left: 4px solid #dc2626; background: rgba(220, 38, 38, 0.08); }
.table-access { margin-top: 16px; }
.btn-table { background-color: var(--btn-table-bg); color: var(--btn-table-text); border: 1px solid var(--btn-table-border); padding: 9px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: filter 0.2s ease; }
.btn-table:hover { filter: brightness(0.95); }
.calculate-wrap { display: flex; gap: 12px; margin-top: 20px; margin-bottom: 40px; align-items: center; flex-wrap: wrap; }
.btn-calc, .btn-reset, .btn-copy, .btn-historico, .btn-pdf, .btn-print { padding: 14px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background-color 0.2s ease; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn-icone { font-size: 16px; }
.btn-calc { flex: 2; min-width: 200px; background-color: #16a34a; color: white; border: none; font-weight: 700; font-size: 15px; }
.btn-calc:hover:not(:disabled) { background-color: #15803d; }
.btn-calc:disabled { opacity: 0.7; cursor: wait; }
.btn-reset { flex: 1; min-width: 100px; background-color: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-reset:hover { background-color: var(--subbox-bg); color: var(--text); }
.btn-copy { flex: 1; min-width: 100px; background-color: #7c3aed; color: white; border: none; font-size: 13px; }
.btn-copy:hover { background-color: #6d28d9; }
.btn-historico { flex: 1; min-width: 100px; background-color: #0f766e; color: white; border: none; font-size: 13px; }
.btn-historico:hover { background-color: #115e59; }
.btn-pdf { flex: 1; min-width: 90px; background-color: #0284c7; color: white; border: none; font-size: 13px; }
.btn-pdf:hover { background-color: #0369a1; }
.btn-print { flex: 1; min-width: 100px; background-color: var(--subbox-bg); border: 1px solid var(--border); color: var(--text); font-size: 13px; }
.btn-voltar { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background-color: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 14px 18px; border-radius: 8px; font-weight: 600; font-size: 13px; transition: all 0.2s ease; }
.btn-voltar:hover { background-color: var(--subbox-bg); color: var(--text); }
footer { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; display: flex; justify-content: center; gap: 12px; }
#rodapeData { font-family: monospace; opacity: 0.7; }
.hidden { display: none !important; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to   { opacity: 1; transform: translateY(0); } }
.fade-in-visible { animation: fadeInUp 0.45s ease-out both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to   { opacity: 1; transform: translateY(0); } }
.toast-protecao { position: fixed; bottom: 20px; right: 20px; background: #1e293b; color: #f8fafc; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: toastIn 0.3s ease-out; }
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box { background: var(--card-bg); border-radius: 12px; padding: 24px; max-width: 600px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; }
.modal-box.wide { max-width: 800px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.modal-body { overflow-y: auto; padding-right: 4px; }
.modal-body h3 { font-size: 14px; margin-top: 14px; margin-bottom: 6px; color: var(--primary); }
.modal-body p  { font-size: 13px; line-height: 1.5; margin-bottom: 8px; color: var(--text); }
.close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.table-scroll { overflow-y: auto; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background-color: var(--subbox-bg); position: sticky; top: 0; }
.historico-lista { display: flex; flex-direction: column; gap: 8px; }
.historico-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--subbox-bg); border: 1px solid var(--border); border-radius: 6px; gap: 12px; }
.historico-item small { color: var(--text-muted); font-size: 11px; }
.btn-carregar { background: var(--primary); color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.btn-carregar:hover { background: var(--primary-hover); }
body.modo-simples .detalhes-box, body.modo-simples .btn-detalhes, body.modo-simples .btn-avancado { display: none !important; }
@media print {
    .topo, .aviso, .calculate-wrap, .table-access, .tema-wrapper, footer, .modal, .campo-info, .toast-protecao, .btn-ajuda, .btn-modo, .modo-relacao, .btn-detalhes, .btn-avancado, .dica-campo { display: none !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
    body { background: #fff; padding: 0; }
    .hidden { display: block !important; }
    .detalhes-box { display: block !important; }
    .selo-status { break-inside: avoid; }
}
/* ============================================================
   FUNDO DE TELA (Apenas no Tema Claro)
   ============================================================ */
body:not(.dark) {
    background-image: url('../../assets/Bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Opcional: Deixa o "cartão" da calculadora levemente transparente para a imagem aparecer um pouco atrás */
/* Se não gostar, basta apagar as 4 linhas abaixo */
body:not(.dark) .app {
    background-color: rgba(248, 250, 252, 0.85); /* Fundo semi-transparente */
    backdrop-filter: blur(4px); /* Efeito de vidro fosco */
    border-radius: 16px;
    padding: 20px;
}