/* ============================================================
   Planejamento Orçamentário ADB — Main CSS
   Visual: identidade Amigos do Bem (baseado em organograma.html)
   ============================================================ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:14px}
body{font-family:'Segoe UI',system-ui,-apple-system,sans-serif;background:#f0f0f0;color:#1a1a1a;height:100vh;overflow:hidden}
:root{
  --blk:#111;--dk:#333;--mid:#666;--bdr:#ddd;--bg:#f5f5f5;--wht:#fff;
  --s1:0 1px 3px rgba(0,0,0,.1);--s2:0 2px 8px rgba(0,0,0,.14);
  --hh:52px;--sb:42px;
  --green:#16a34a;--red:#dc2626;--yellow:#d97706;--blue:#2563eb;
  --green-bg:#dcfce7;--red-bg:#fee2e2;--yellow-bg:#fef3c7;--blue-bg:#dbeafe;
}

/* ── LOGIN ─────────────────────────────────────────────────── */
#loginPage{position:fixed;inset:0;background:#111;display:flex;align-items:center;justify-content:center;z-index:1000}
.lbox{background:#fff;border-radius:8px;padding:40px;width:380px;box-shadow:0 8px 32px rgba(0,0,0,.4)}
.lorg{font-size:10px;letter-spacing:.2em;text-transform:uppercase;color:#bbb;margin-bottom:6px}
.ltit{font-size:22px;font-weight:700;color:#111;margin-bottom:2px}
.lsub{font-size:13px;color:#888;margin-bottom:28px}
.lf label{display:block;font-size:11px;font-weight:700;color:#555;margin-bottom:5px;text-transform:uppercase;letter-spacing:.05em}
.lf input{width:100%;border:1px solid #ddd;border-radius:4px;padding:10px 12px;font-size:14px;outline:none;transition:border .2s}
.lf input:focus{border-color:#111}
.lf .field{margin-bottom:16px}
.btn-login{width:100%;background:#111;color:#fff;border:none;border-radius:4px;padding:11px;font-size:14px;font-weight:600;cursor:pointer;margin-top:8px;transition:background .2s}
.btn-login:hover{background:#333}
.lerr{color:#c00;font-size:12px;margin-top:10px;display:none;padding:8px;background:#fff0f0;border-radius:4px;border:1px solid #fcc}
.llogo{text-align:center;margin-bottom:20px}
.llogo img{height:40px;object-fit:contain}

/* ── APP SHELL ─────────────────────────────────────────────── */
#app{display:none;height:100vh;flex-direction:column}
#app.on{display:flex}
header{height:var(--hh);background:#111;display:flex;align-items:center;padding:0 16px;gap:14px;flex-shrink:0;position:sticky;top:0;z-index:100}
.hlogo img{height:28px;object-fit:contain}
.hbn{font-size:14px;font-weight:700;color:#fff}
.hbs{font-size:10px;color:#777;letter-spacing:.08em;text-transform:uppercase;margin-top:1px}
.hsp{width:1px;height:22px;background:#2a2a2a;flex-shrink:0}
.hfx{flex:1}
.hun{font-size:12px;color:#ccc;text-align:right}
.hur{font-size:10px;color:#666;text-align:right}
.hav{width:30px;height:30px;background:#2a2a2a;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#aaa;flex-shrink:0}
.hbtn{background:none;border:1px solid #2a2a2a;border-radius:4px;padding:4px 10px;font-size:11px;color:#777;cursor:pointer;white-space:nowrap}
.hbtn:hover{border-color:#555;color:#ccc}

/* ── SUBHEADER ─────────────────────────────────────────────── */
#subheader{height:var(--sb);background:#1a1a1a;display:flex;align-items:center;padding:0 16px;gap:20px;flex-shrink:0;border-bottom:1px solid #222}
.sv{font-size:15px;font-weight:700;color:#fff;line-height:1}
.sl{font-size:9px;color:#bbb;text-transform:uppercase;letter-spacing:.1em;margin-top:2px}
.ssep{width:1px;height:22px;background:#333}
.sstatus{font-size:11px;padding:3px 8px;border-radius:10px;font-weight:600}
.sstatus.aberto{background:#16a34a22;color:#16a34a;border:1px solid #16a34a44}
.sstatus.encerrado{background:#dc262622;color:#dc2626;border:1px solid #dc262644}
.sstatus.configuracao{background:#d9770622;color:#d97706;border:1px solid #d9770644}
.sfx{flex:1}
.sdias{font-size:11px;color:#888}

/* ── MAIN CONTENT ──────────────────────────────────────────── */
#main{flex:1;overflow:auto;min-height:0}
.page{display:none;padding:20px}
.page.active{display:block}

/* ── NAV TABS ──────────────────────────────────────────────── */
.nav-tabs{display:flex;gap:4px;padding:12px 20px 0;background:#f5f5f5;border-bottom:1px solid #ddd;overflow:visible;flex-shrink:0;position:relative;z-index:100}
.ntab{background:none;border:none;padding:8px 16px;font-size:13px;font-weight:500;color:#666;cursor:pointer;border-bottom:2px solid transparent;white-space:nowrap;transition:color .15s}
.ntab:hover{color:#111}
.ntab.active{color:#111;border-bottom-color:#111;font-weight:600}
/* ── NAV DROPDOWN ───────────────────────────────────────────── */
.nav-dropdown{position:relative;display:inline-flex;align-items:stretch}
.ntab-dropdown{display:flex;align-items:center;gap:5px}
.ntab-caret{font-size:10px;opacity:.6;transition:transform .15s}
.nav-dropdown.open .ntab-caret{transform:rotate(180deg)}
.nav-dropdown-menu{display:none;position:absolute;top:calc(100% + 1px);left:0;min-width:220px;background:#fff;border:1px solid #ddd;border-radius:0 0 8px 8px;box-shadow:0 6px 20px rgba(0,0,0,.1);z-index:1000;padding:4px 0}
.nav-dropdown.open .nav-dropdown-menu{display:block}
.nav-dropdown-item{display:block;width:100%;text-align:left;background:none;border:none;padding:9px 18px;font-size:13px;font-weight:500;color:#444;cursor:pointer;white-space:nowrap;transition:background .1s}
.nav-dropdown-item:hover{background:#f5f5f5;color:#111}
.nav-dropdown-item.active{color:#111;font-weight:600;background:#f0f0f0}
.nav-dropdown-item--disabled{display:block;padding:9px 18px;font-size:13px;font-weight:500;color:#bbb;cursor:not-allowed;white-space:nowrap}
.nav-dropdown-item--disabled::after{content:' (em breve)';font-size:11px;color:#ccc}
.nav-dropdown-item--locked{display:block;width:100%;text-align:left;padding:9px 18px;font-size:13px;font-weight:500;color:#bbb;cursor:not-allowed;white-space:nowrap;background:none;border:none}
.nav-dropdown-item--locked:hover{background:#fafafa;color:#999}
.nav-dropdown-item--locked::after{content:' 🔒';font-size:11px}
.ntab--locked{opacity:.45;cursor:not-allowed}
.ntab--locked:hover{opacity:.45}

/* ── CARDS ──────────────────────────────────────────────────── */
.cards-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px;padding:20px}
.cc-card{background:#fff;border:1px solid #ddd;border-radius:8px;padding:16px 18px;cursor:pointer;transition:border .15s,box-shadow .15s;position:relative}
.cc-card:hover{border-color:#999;box-shadow:var(--s2)}
.cc-card-code{font-size:10px;color:#888;font-weight:600;letter-spacing:.06em;text-transform:uppercase;margin-bottom:4px}
.cc-card-name{font-size:14px;font-weight:700;color:#111;margin-bottom:8px;line-height:1.3}
.cc-card-meta{font-size:11px;color:#888;margin-bottom:10px}
.cc-card-status{display:inline-block;font-size:10px;font-weight:700;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:.04em}
.cc-card-vals{display:flex;gap:16px;margin-top:10px;padding-top:10px;border-top:1px solid #f0f0f0}
.cc-card-val{flex:1}
.cc-card-val-label{font-size:10px;color:#aaa;margin-bottom:2px}
.cc-card-val-num{font-size:13px;font-weight:600;color:#111}

/* ── STATUS BADGES ─────────────────────────────────────────── */
.badge{display:inline-block;font-size:10px;font-weight:700;padding:2px 7px;border-radius:10px;letter-spacing:.04em;text-transform:uppercase}
.badge-nao-iniciado{background:#f3f4f6;color:#6b7280}
.badge-rascunho{background:#fef3c7;color:#d97706}
.badge-em-preenchimento{background:#dbeafe;color:#2563eb}
.badge-enviado{background:#e0f2fe;color:#0284c7}
.badge-aprovado{background:#dcfce7;color:#16a34a}
.badge-encerrado{background:#f1f5f9;color:#475569}
.badge-reaberto{background:#fce7f3;color:#db2777}
.badge-ajuste{background:#fef9c3;color:#854d0e}

/* ── SECTION HEADER ────────────────────────────────────────── */
.sec-header{display:flex;align-items:center;gap:12px;margin-bottom:16px;flex-wrap:wrap}
.sec-title{font-size:18px;font-weight:700;color:#111}
.sec-sub{font-size:12px;color:#888}
.sec-fx{flex:1}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn{display:inline-flex;align-items:center;gap:6px;border:none;border-radius:4px;padding:7px 14px;font-size:13px;font-weight:600;cursor:pointer;transition:background .15s,opacity .15s}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn-primary{background:#111;color:#fff}
.btn-primary:hover:not(:disabled){background:#333}
.btn-secondary{background:#fff;color:#333;border:1px solid #ddd}
.btn-secondary:hover:not(:disabled){border-color:#999;background:#f9f9f9}
.btn-danger{background:#dc2626;color:#fff}
.btn-danger:hover:not(:disabled){background:#b91c1c}
.btn-success{background:#16a34a;color:#fff}
.btn-success:hover:not(:disabled){background:#15803d}
.btn-warning{background:#d97706;color:#fff}
.btn-warning:hover:not(:disabled){background:#b45309}
.btn-sm{padding:4px 10px;font-size:12px}
.btn-icon{padding:6px;background:none;border:1px solid #ddd;border-radius:4px;cursor:pointer;color:#555}
.btn-icon:hover{border-color:#999;color:#111}

/* ── FORMS ──────────────────────────────────────────────────── */
.form-row{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:12px}
.form-group{flex:1;min-width:180px}
.form-group label{display:block;font-size:11px;font-weight:700;color:#555;margin-bottom:4px;text-transform:uppercase;letter-spacing:.04em}
.form-group input,.form-group select,.form-group textarea{width:100%;border:1px solid #ddd;border-radius:4px;padding:8px 10px;font-size:13px;outline:none;transition:border .2s;font-family:inherit}
.form-group input:focus,.form-group select:focus,.form-group textarea:focus{border-color:#111}
.form-group .hint{font-size:11px;color:#aaa;margin-top:3px}
.form-error{color:#c00;font-size:12px;margin-top:4px}

/* ── PLANILHA / INPUT TABLE ─────────────────────────────────── */
.sheet-wrap{overflow-x:hidden;border:1px solid #ddd;border-radius:6px;background:#fff}
.sheet-table{width:100%;border-collapse:collapse;font-size:12px}
.sheet-table th{background:#1a1a1a;color:#fff;padding:7px 8px;text-align:center;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap}
.sheet-table th.col-nl{text-align:left;position:sticky;left:0;z-index:11;background:#111}
.sheet-table td{border-bottom:1px solid #f0f0f0;border-right:1px solid #f5f5f5;padding:0;vertical-align:middle}
.sheet-table td.nl-cell{padding:6px 10px;font-size:11px;color:#333;font-weight:500;background:#fafafa;position:sticky;left:0;z-index:4;border-right:2px solid #e5e5e5;min-width:220px;max-width:280px;white-space:normal;line-height:1.3;cursor:default}
.sheet-table td.nl-cell .nl-group{font-size:9px;color:#aaa;text-transform:uppercase;letter-spacing:.04em;margin-top:2px}
.sheet-table tr.group-header td{background:#f0f0f0;font-size:10px;font-weight:700;text-transform:uppercase;color:#555;padding:5px 10px;letter-spacing:.06em}
.sheet-table tr.total-row td{background:#e8e8e8;font-weight:700;font-size:12px}
.sheet-table tr:hover td:not(.nl-cell){background:#fafff8}
.sheet-table tr.group-header:hover td{background:#e8e8e8}
/* Barrinhas separadoras entre as colunas de mês (6=Jan ... 17=Dez) */
.sheet-table th:nth-child(n+6):nth-child(-n+17),
.sheet-table td:nth-child(n+6):nth-child(-n+17){border-right:1px solid #d8d8d8}

/* Editable cell */
.cell-edit{display:block;width:100%;border:none;background:transparent;text-align:right;padding:6px 8px;font-size:12px;font-family:inherit;color:#111;outline:none;cursor:text;min-width:80px}
.cell-edit:focus{background:#fffde7;box-shadow:inset 0 0 0 2px #d97706}
.cell-edit.changed{background:#e7f5ff}
td.locked .cell-edit{cursor:default;color:#aaa;background:transparent}
td.locked .cell-edit:focus{background:transparent;box-shadow:none}
td.total-cell{padding:6px 8px;text-align:right;font-weight:600;color:#111;background:#f8f8f8;white-space:nowrap}
td.prev-cell{padding:6px 8px;text-align:right;color:#888;font-size:11px;white-space:nowrap}
td.var-cell{padding:6px 8px;text-align:right;font-size:11px;white-space:nowrap}

/* ── FACILITADOR DE LANÇAMENTOS ──────────────────────────────── */
.fac-block{border:1px solid #eee;border-radius:6px;padding:12px 14px;margin-bottom:12px;background:#fafafa}
.fac-block-title{font-size:11px;font-weight:700;color:#555;text-transform:uppercase;letter-spacing:.06em;margin-bottom:10px}
.fac-opt{margin-bottom:10px}
.fac-opt:last-child{margin-bottom:0}
.fac-radio{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;color:#111;cursor:pointer}
.fac-radio input{cursor:pointer}
.fac-desc{font-size:11px;color:#888;margin:3px 0 0 22px;line-height:1.4}

/* ── MENSAGENS (comunicação ADM ↔ Gestor) ────────────────────── */
.msg-thread{max-height:340px;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:4px 2px}
.msg-bubble{max-width:80%;padding:8px 12px;border-radius:10px;font-size:13px;line-height:1.4}
.msg-bubble.me{align-self:flex-end;background:#111;color:#fff;border-bottom-right-radius:2px}
.msg-bubble.other{align-self:flex-start;background:#f0f0f0;color:#111;border-bottom-left-radius:2px}
.msg-meta{font-size:10px;opacity:.7;margin-bottom:3px;text-transform:uppercase;letter-spacing:.03em}
.msg-badge{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;background:#dc2626;color:#fff;font-size:9px;font-weight:700;border-radius:9px;margin-left:4px}

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:200;display:none;align-items:center;justify-content:center}
.modal-overlay.open{display:flex}
.modal{background:#fff;border-radius:8px;padding:0;max-width:560px;width:90%;box-shadow:0 16px 48px rgba(0,0,0,.3);max-height:90vh;display:flex;flex-direction:column}
.modal-header{padding:18px 20px 14px;border-bottom:1px solid #eee;display:flex;align-items:center;gap:10px}
.modal-header h3{font-size:15px;font-weight:700;color:#111;flex:1}
.modal-close{background:none;border:none;font-size:18px;color:#aaa;cursor:pointer;padding:2px 6px}
.modal-close:hover{color:#111}
.modal-body{padding:20px;overflow-y:auto;flex:1}
.modal-footer{padding:14px 20px;border-top:1px solid #eee;display:flex;gap:8px;justify-content:flex-end}
.modal-info-row{display:flex;gap:8px;margin-bottom:8px;font-size:13px}
.modal-info-row .label{font-weight:600;color:#555;min-width:120px}
.modal-info-row .val{color:#111}

/* ── TABLE GENERIC ─────────────────────────────────────────── */
.data-table{width:100%;border-collapse:collapse;font-size:12px}
.data-table th{background:#f5f5f5;border-bottom:2px solid #ddd;padding:8px 10px;text-align:left;font-size:11px;font-weight:700;color:#555;text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}
.data-table td{padding:7px 10px;border-bottom:1px solid #f0f0f0;color:#333;vertical-align:middle}
.data-table tr:hover td{background:#fafafa}
.data-table td.num{text-align:right;font-variant-numeric:tabular-nums}
.data-table .actions{white-space:nowrap;text-align:right}

/* ── TOOLTIP ────────────────────────────────────────────────── */
.tooltip-wrap{position:relative;display:inline}
.tooltip-box{position:absolute;bottom:calc(100% + 6px);left:0;background:#111;color:#fff;font-size:11px;padding:8px 10px;border-radius:4px;white-space:normal;max-width:320px;z-index:50;line-height:1.5;display:none;box-shadow:var(--s2)}
.tooltip-wrap:hover .tooltip-box{display:block}

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert{padding:10px 14px;border-radius:4px;font-size:12px;font-weight:500;margin-bottom:12px;display:flex;align-items:flex-start;gap:8px}
.alert-info{background:#dbeafe;color:#1e40af;border:1px solid #bfdbfe}
.alert-success{background:#dcfce7;color:#166534;border:1px solid #bbf7d0}
.alert-warn{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
.alert-error{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.alert .alert-close{background:none;border:none;cursor:pointer;font-size:14px;color:inherit;opacity:.6;flex-shrink:0;margin-left:auto}
.alert .alert-close:hover{opacity:1}

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress-wrap{background:#e5e7eb;border-radius:99px;height:6px;overflow:hidden}
.progress-bar{height:100%;background:#111;border-radius:99px;transition:width .4s}
.progress-bar.green{background:#16a34a}
.progress-bar.yellow{background:#d97706}
.progress-bar.red{background:#dc2626}

/* ── COUNTER ────────────────────────────────────────────────── */
.days-counter{text-align:center;padding:12px 16px;background:#fff;border:1px solid #ddd;border-radius:8px}
.days-num{font-size:32px;font-weight:700;color:#111;line-height:1}
.days-label{font-size:11px;color:#888;text-transform:uppercase;letter-spacing:.06em;margin-top:2px}
.days-counter.urgente .days-num{color:#dc2626}
.days-counter.aviso .days-num{color:#d97706}

/* ── SPINNER ────────────────────────────────────────────────── */
.spinner{display:inline-block;width:16px;height:16px;border:2px solid #ddd;border-top-color:#111;border-radius:50%;animation:spin .6s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-overlay{position:fixed;inset:0;background:rgba(255,255,255,.7);z-index:300;display:none;align-items:center;justify-content:center}
.loading-overlay.on{display:flex}
.loading-box{background:#fff;border-radius:8px;padding:24px 32px;box-shadow:var(--s2);display:flex;align-items:center;gap:12px;font-size:13px;font-weight:600;color:#555}

/* ── SIDEBAR LAYOUT ─────────────────────────────────────────── */
.layout-two{display:flex;gap:20px;align-items:flex-start}
.sidebar-panel{width:280px;flex-shrink:0;background:#fff;border:1px solid #ddd;border-radius:8px;padding:16px}
.sidebar-panel h4{font-size:11px;font-weight:700;color:#555;text-transform:uppercase;letter-spacing:.06em;margin-bottom:12px}
.main-panel{flex:1;min-width:0}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media(max-width:900px){
  .cards-grid{grid-template-columns:repeat(auto-fill,minmax(260px,1fr))}
  .layout-two{flex-direction:column}
  .sidebar-panel{width:100%}
  .sheet-table th.col-nl,.sheet-table td.nl-cell{min-width:160px;max-width:200px}
}
@media(max-width:600px){
  .cards-grid{grid-template-columns:1fr}
  .lbox{width:95%;padding:28px 20px}
  .form-row{flex-direction:column}
  .nav-tabs{padding:8px 12px 0}
  .page{padding:12px}
}

/* ── ANOTAÇÕES DE CÉLULAS ───────────────────────────────────── */
.annot-dot{position:absolute;top:0;right:0;width:0;height:0;border-style:solid;border-width:0 8px 8px 0;border-color:transparent #e53e3e transparent transparent;cursor:pointer;z-index:2}
.annot-dot:hover::after{content:attr(title);position:fixed;background:#1a1a2e;color:#fff;padding:6px 10px;border-radius:6px;font-size:11px;max-width:240px;white-space:pre-wrap;z-index:9998;transform:translateY(-110%);pointer-events:none}
td:has(input.cell-edit){position:relative}
