/* v9 — inclui: tema claro/escuro, KPIs, Kanban, feriados/fins-de-semana, edição inline */
:root{
  --bg:#0b1220; --panel:#0f172a; --muted:#94a3b8; --text:#e5e7eb; --border:#334155;
  --accent:#16a34a; --card:#111827; --card2:#0b1220;
  --badge-red:#ef444422; --badge-yellow:#f59e0b22; --badge-green:#22c55e22;
  --badge-red-text:#fecaca; --badge-yellow-text:#fde68a; --badge-green-text:#bbf7d0;
  --status-producao-bg:#36531433; --status-producao-fg:#d9f99d; --status-producao-bd:#36531466;
  --status-aguarda-bg:#1f293733; --status-aguarda-fg:#93c5fd; --status-aguarda-bd:#1f293766;
  --status-transito-bg:#164e6333; --status-transito-fg:#67e8f9; --status-transito-bd:#164e6366;
  --status-concluido-bg:#064e3b33; --status-concluido-fg:#6ee7b7; --status-concluido-bd:#064e3b66;
  --status-faturado-bg:#0f172a33; --status-faturado-fg:#cbd5e1; --status-faturado-bd:#0f172a66;
  --status-porfaturar-bg:#7c2d1233; --status-porfaturar-fg:#fdba74; --status-porfaturar-bd:#7c2d1266;

  --weekend-bg:#0f172a; --holiday-bd:#eab308; --holiday-bg:#eab30822; --holiday-text:#fde68a;
}
:root[data-theme="light"]{
  --bg:#f6f8fb; --panel:#ffffff; --muted:#475569; --text:#0b1220; --border:#e2e8f0;
  --card:#ffffff; --card2:#f8fafc;
  --badge-red:#fee2e2; --badge-yellow:#fef3c7; --badge-green:#dcfce7;
  --badge-red-text:#7f1d1d; --badge-yellow-text:#7c2d12; --badge-green-text:#14532d;

  --status-producao-bg:#ecfccb; --status-producao-fg:#365314; --status-producao-bd:#d9f99d;
  --status-aguarda-bg:#dbeafe; --status-aguarda-fg:#1e3a8a; --status-aguarda-bd:#bfdbfe;
  --status-transito-bg:#cffafe; --status-transito-fg:#164e63; --status-transito-bd:#a5f3fc;
  --status-concluido-bg:#d1fae5; --status-concluido-fg:#065f46; --status-concluido-bd:#a7f3d0;
  --status-faturado-bg:#e2e8f0; --status-faturado-fg:#0f172a; --status-faturado-bd:#cbd5e1;
  --status-porfaturar-bg:#ffedd5; --status-porfaturar-fg:#7c2d12; --status-porfaturar-bd:#fed7aa;

  --weekend-bg:#f1f5f9; --holiday-bd:#ca8a04; --holiday-bg:#fef3c7; --holiday-text:#7c2d12;
}

*{box-sizing:border-box}
html,body{height:100%}
body{margin:0; font-family:Inter,system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  background:linear-gradient(180deg,var(--bg) 0%, var(--bg) 100%); color:var(--text)}

/* Header */
.app-header{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); background:linear-gradient(180deg,var(--panel) 0%, var(--panel) 100%); position:sticky; top:0; z-index:5}
.brand{display:flex; align-items:center; gap:10px}
.logo{width:36px; height:36px; border-radius:10px; background:var(--card2); display:grid; place-items:center; font-weight:800; color:#3b82f6}
.brand-text{display:flex; flex-direction:column; line-height:1.1}
.brand-text strong{font-size:14px}
.brand-text span{font-size:12px; color:var(--muted)}
.toolbar .btn{min-width:42px}
.actions{display:flex; align-items:center; gap:8px}

/* Buttons */
.btn{
  appearance:none; border:1px solid var(--border); background:var(--panel); color:var(--text);
  padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:600;
}
.btn.ghost{background:transparent}
.btn.primary{background:linear-gradient(180deg,#22c55e,#16a34a); border-color:#16a34a; color:#fff}
.btn.danger{background:linear-gradient(180deg,#ef4444,#dc2626); border-color:#b91c1c; color:#fff}
.btn:disabled{opacity:.6; cursor:not-allowed}

/* Filters */
.filters{display:flex; flex-direction:column; gap:8px; padding:10px 16px; border-bottom:1px solid var(--border); background:var(--panel)}
.legend{display:flex; gap:12px; align-items:center; font-size:12px; color:var(--muted)}
.dot{display:inline-block; width:10px; height:10px; border-radius:50%}
.dot.urgent{background:#dc2626}
.dot.priority{background:#d97706}
.dot.normal{background:#16a34a}
.filter-controls{display:flex; flex-wrap:wrap; gap:10px; align-items:center}
.filter-controls input[type="search"]{background:var(--panel); color:var(--text); border:1px solid var(--border); padding:8px 10px; border-radius:10px; min-width:220px}

/* KPI */
.kpi{display:grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap:10px; padding:10px 16px; border-bottom:1px solid var(--border); background:var(--panel)}
.kpi-item{border:1px solid var(--border); border-radius:12px; padding:10px; background:var(--card)}
.kpi-label{font-size:12px; color:var(--muted)}
.kpi-value{font-size:18px; font-weight:800; margin-top:2px}

/* Calendar */
.calendar{display:grid; gap:10px; padding:12px 16px; grid-template-columns: repeat(7, minmax(200px, 1fr));}
.calendar.week{grid-template-columns: repeat(7, minmax(240px,1fr));}
.grid-title{grid-column:1 / -1; text-transform:capitalize; font-weight:800; letter-spacing:.4px; padding:8px 2px}

/* Day */
.day{border:1px solid var(--border); border-radius:16px; background:linear-gradient(180deg,var(--card),var(--panel)); overflow:hidden; min-height:180px}
.day.muted-cell{opacity:.65}
.day.weekend{background:linear-gradient(180deg,var(--weekend-bg), var(--panel))}
.day.holiday{border:2px solid var(--holiday-bd); box-shadow:inset 0 0 0 9999px var(--holiday-bg)}
.day-header{display:flex; justify-content:space-between; align-items:center; gap:8px; padding:10px 12px; border-bottom:1px dashed var(--border); font-size:12px; color:var(--muted)}
.day-header .daynum[aria-current="date"]{color:#16a34a; font-weight:800}
.day-header .badge-day{font-size:11px; font-weight:800; padding:2px 8px; border-radius:999px; border:1px solid var(--holiday-bd); color:var(--holiday-text); background:var(--holiday-bg)}
.day-body{padding:10px 12px; display:flex; flex-direction:column; gap:8px}
.muted{color:var(--muted); font-size:12px}

/* Capacity bar */
.cap-bar{position:relative; height:24px; border:1px solid var(--border); border-radius:8px; overflow:hidden; display:flex; align-items:center; background:var(--card2)}
.cap-bar>div{position:absolute; left:0; top:0; height:100%; background:#22c55e22}
.cap-bar>span{position:relative; z-index:1; font-size:12px; padding-left:8px}
.cap-over>div{background:#ef444422}
.cap-high>div{background:#f59e0b22}

/* Cards */
.job-card{border:1px solid var(--border); border-radius:14px; padding:10px 10px; background:var(--panel); display:flex; flex-direction:column; gap:6px}
.job-title{display:flex; align-items:center; justify-content:space-between; font-weight:700}
.job-meta{font-size:12px; color:var(--muted); display:flex; gap:6px; align-items:center; flex-wrap:wrap}
.badge{padding:2px 8px; font-size:11px; border-radius:999px; border:1px solid var(--border)}
.badge.urgent{background:var(--badge-red); color:var(--badge-red-text)}
.badge.priority{background:var(--badge-yellow); color:var(--badge-yellow-text)}
.badge.normal{background:var(--badge-green); color:var(--badge-green-text)}
.job-status{margin-top:2px;font-size:12px;font-weight:700;display:inline-block;padding:4px 8px;border-radius:999px;border:1px solid var(--border);cursor:pointer; user-select:none}
.status-producao{background:var(--status-producao-bg); color:var(--status-producao-fg); border-color:var(--status-producao-bd)}
.status-aguarda{background:var(--status-aguarda-bg); color:var(--status-aguarda-fg); border-color:var(--status-aguarda-bd)}
.status-transito{background:var(--status-transito-bg); color:var(--status-transito-fg); border-color:var(--status-transito-bd)}
.status-concluido{background:var(--status-concluido-bg); color:var(--status-concluido-fg); border-color:var(--status-concluido-bd)}
.status-faturado{background:var(--status-faturado-bg); color:var(--status-faturado-fg); border-color:var(--status-faturado-bd)}
.status-porfaturar{background:var(--status-porfaturar-bg); color:var(--status-porfaturar-fg); border-color:var(--status-porfaturar-bd)}
.assignee-pill{padding:2px 6px; border:1px dashed var(--border); border-radius:8px; font-size:11px; cursor:pointer}
.assignee-edit{font-size:12px; padding:2px 6px; border:1px solid var(--border); border-radius:6px; background:var(--card); color:var(--text)}

/* Dialog */
dialog{border:none; border-radius:16px; padding:0; overflow:hidden; background:var(--panel); color:var(--text); box-shadow:0 20px 60px rgba(0,0,0,.25)}
dialog::backdrop{background:rgba(0,0,0,.35)}
#jobForm{padding:14px}
#jobForm h2{margin:0 0 12px 0; font-size:18px}
.grid-form{display:grid; grid-template-columns:repeat(2,minmax(220px,1fr)); gap:10px}
.grid-form label{display:flex; flex-direction:column; gap:6px; font-size:12px}
.grid-form input, .grid-form select, .grid-form textarea{background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:10px; padding:8px 10px}
.dialog-actions{display:flex; justify-content:flex-end; gap:8px; padding:12px 0 0 0}

/* Kanban */
.kanban{display:flex; gap:12px; padding:12px 16px; overflow-x:auto}
.kanban-col{min-width:260px; max-width:360px; flex: 0 0 auto; border:1px solid var(--border); border-radius:14px; background:var(--panel); display:flex; flex-direction:column}
.kanban-col-header{padding:10px 12px; border-bottom:1px dashed var(--border); display:flex; justify-content:space-between; align-items:center}
.kanban-col-body{padding:10px 12px; display:flex; flex-direction:column; gap:8px; min-height:200px}
.kanban-col-body.empty::after{content:'Sem trabalhos'; color:var(--muted); font-size:12px}

/* Login */
.login{max-width:360px; margin:48px auto; border:1px dashed var(--border); border-radius:16px; padding:16px; background:var(--panel)}
.login h2{margin-top:0}
.login input{width:100%; background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:10px; padding:10px; margin-bottom:8px}

/* Drag */
.drag-over{outline:2px dashed #22c55e66; outline-offset:-6px}

/* Toast */
#toast{position:fixed; bottom:16px; right:16px; display:flex; flex-direction:column; gap:8px; z-index:1000}
.toast{background:var(--panel); color:var(--text); border:1px solid var(--border); border-radius:10px; padding:10px 12px; min-width:220px; box-shadow:0 5px 20px rgba(0,0,0,.15)}
.toast.ok{border-color:#16a34a}
.toast.err{border-color:#ef4444}

/* Responsive */
@media (max-width:1120px){
  .calendar{grid-template-columns: repeat(2, 1fr);}
  .grid-form{grid-template-columns:1fr}
}
