/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body.cro-body { font-family: 'Segoe UI', -apple-system, sans-serif; background: #eef2f7; padding: 0; }
.cro-app { max-width: 1400px; margin: 0 auto; padding: 8px; }

/* ── BARRA DE OBRAS ────────────────────────────────────────────────────────── */
.obras-bar {
    background: #0f172a; padding: 6px 14px;
    display: flex; justify-content: space-between; align-items: center;
    border-radius: 8px; margin-bottom: 6px; gap: 8px; flex-wrap: wrap;
}
.obras-bar-left   { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.obras-bar-title  { color: rgba(255,255,255,0.5); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.obras-bar-user   { color: rgba(255,255,255,0.7); font-size: 10px; }
#obraSelector {
    font-size: 11px; font-weight: 600; padding: 3px 8px;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px; color: white; cursor: pointer; max-width: 260px;
}
#obraSelector option { background: #1e293b; color: white; }
.btn-new-obra { background: #22c55e; font-size: 10px; padding: 3px 10px; border-radius: 5px; border: none; color: white; cursor: pointer; font-weight: 700; }
.btn-new-obra:hover { background: #16a34a; }
.btn-del-obra { background: rgba(239,68,68,0.25); border: 1px solid rgba(239,68,68,0.4); font-size: 11px; padding: 3px 8px; border-radius: 5px; color: #fca5a5; cursor: pointer; }
.btn-del-obra:hover { background: rgba(239,68,68,0.5); }
.btn-login { color: #93c5fd; font-size: 10px; text-decoration: none; border: 1px solid rgba(147,197,253,0.3); padding: 3px 10px; border-radius: 5px; }

/* ── HEADER ───────────────────────────────────────────────────────────────── */
.header { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); padding: 8px 16px; border-radius: 8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.obra-nome { font-size: 16px; font-weight: 600; background: rgba(255,255,255,0.1); border: none; color: white; padding: 4px 10px; border-radius: 6px; width: auto; min-width: 200px; }
.obra-nome:focus { outline: none; background: rgba(255,255,255,0.2); }
.dates-container { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-group { background: rgba(0,0,0,0.3); padding: 4px 10px; border-radius: 6px; text-align: center; }
.date-group label { display: block; font-size: 8px; color: rgba(255,255,255,0.6); text-transform: uppercase; font-weight: 600; margin-bottom: 2px; }
.date-group input[type="date"] { font-size: 12px; font-weight: 700; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); border-radius: 5px; color: white; padding: 2px 5px; text-align: center; }
.date-group input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.7; }
.countdown-box { background: rgba(0,0,0,0.4); padding: 5px 14px; border-radius: 8px; text-align: center; border: 1px solid rgba(255,255,255,0.1); }
.countdown-num { font-size: 22px; font-weight: 800; color: white; line-height: 1; }
.countdown-label { font-size: 8px; color: rgba(255,255,255,0.6); text-transform: uppercase; margin-top: 1px; }
.countdown-box.warning .countdown-num { color: #f9a825; }
.countdown-box.critical .countdown-num { color: #e74c3c; }
.countdown-box.done .countdown-num { color: #e74c3c; }
.progress-info { background: rgba(255,255,255,0.07); padding: 4px 10px; border-radius: 6px; font-size: 10px; color: rgba(255,255,255,0.75); text-align: center; }
.progress-bar-mini { height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.progress-bar-mini-fill { height: 100%; background: linear-gradient(90deg, #27ae60, #f9a825); border-radius: 2px; transition: width 0.5s; }

/* ── KPIs ─────────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.kpi-card { background: white; border-radius: 8px; padding: 6px 8px; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.kpi-value { font-size: 20px; font-weight: 700; }
.kpi-label { font-size: 8px; color: #777; margin-top: 2px; text-transform: uppercase; }
.kpi-critical { color: #e74c3c; }
.kpi-warning { color: #f39c12; }

/* ── ALERTAS ──────────────────────────────────────────────────────────────── */
.alert-card { padding: 10px 14px; margin-bottom: 8px; border-radius: 8px; border-left: 4px solid; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.alert-card.critical { background: #fff5f5; border-left-color: #e74c3c; }
.alert-card.warning  { background: #fffbf0; border-left-color: #f39c12; }
.alert-title   { font-size: 13px; font-weight: 800; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.alert-metric  { font-size: 18px; font-weight: 800; margin: 5px 0; }
.alert-submetric { font-size: 12px; font-weight: 700; margin: 4px 0; color: #555; }
.impact-list { margin: 6px 0; padding-left: 16px; font-size: 10px; line-height: 1.4; }
.impact-list li { margin: 2px 0; }
.action-plan { background: #e8f5e9; padding: 6px 10px; border-radius: 6px; margin-top: 6px; }
.action-plan ul { margin-left: 16px; font-size: 9px; line-height: 1.4; }
.critical-badge { background: #e74c3c; color: white; padding: 1px 6px; border-radius: 10px; font-size: 9px; display: inline-block; margin-left: 5px; }

/* ── GRÁFICO ──────────────────────────────────────────────────────────────── */
.chart-card { background: white; border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.chart-card h3 { font-size: 11px; margin-bottom: 5px; padding-bottom: 3px; border-bottom: 1px solid #eee; }
.gantt-wrapper { position: relative; width: 100%; cursor: crosshair; }
.gantt-container { width: 100%; position: relative; }
.gantt-list { min-height: 80px; width: 100%; position: relative; }
.gantt-row {
    display: flex; margin-bottom: 3px; align-items: center;
    width: 100%; min-height: 28px;
}
.gantt-row.dragging { opacity: 0.4; }
.gantt-row.drag-over-top    { border-top: 2px solid #3498db !important; }
.gantt-row.drag-over-bottom { border-bottom: 2px solid #3498db !important; }
.gantt-label {
    width: 150px; min-width: 150px;
    font-size: 9px; font-weight: 500; padding-right: 6px;
    flex-shrink: 0; overflow: hidden;
}
.gantt-bar-container {
    flex: 1; position: relative; height: 26px;
    background: #ecf0f1; border-radius: 4px; overflow: visible; min-width: 0;
}
.gantt-bar {
    position: absolute; height: 100%; border-radius: 4px;
    display: flex; align-items: center; padding-left: 4px;
    color: white; font-size: 8px; font-weight: 600;
}
.gantt-bar.critical { background: #e74c3c; }
.gantt-bar.warning  { background: #f9a825; }
.gantt-bar.normal   { background: #1e88e5; }
.gantt-bar.overflow { background: linear-gradient(90deg, #e74c3c 70%, #8b0000) !important; }
.gantt-marker { position: absolute; width: 2px; height: 100%; background: #2c3e50; top: 0; z-index: 10; }
.gantt-marker.prazo { background: #e74c3c; width: 3px; z-index: 11; }
.gantt-scale { display: flex; margin-top: 4px; padding-left: 150px; width: 100%; position: relative; }
.gantt-scale .scale-mark { flex: 1; text-align: center; font-size: 7px; border-left: 1px solid #ddd; padding: 2px 0; }
.gantt-scale .scale-mark.prazo-mark { color: #e74c3c; font-weight: bold; background: #fff0f0; }
.gantt-legend { margin-top: 5px; font-size: 8px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.legend-critical { display: inline-block; width: 14px; height: 14px; background: #e74c3c; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend-warning  { display: inline-block; width: 14px; height: 14px; background: #f9a825; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend-normal   { display: inline-block; width: 14px; height: 14px; background: #1e88e5; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Mouse line */
.mouse-line    { position: absolute; top: 0; width: 1px; background: #333; pointer-events: none; z-index: 20; opacity: 0.6; }
.mouse-tooltip { position: absolute; background: #2c3e50; color: white; padding: 2px 6px; border-radius: 4px; font-size: 9px; white-space: nowrap; pointer-events: none; z-index: 21; font-weight: bold; }

/* Marcadores dinâmicos */
.gantt-marker-dyn { pointer-events: none; }

/* ── DRAG & DROP ──────────────────────────────────────────────────────────── */
.drag-handle { cursor: grab; padding: 0 5px 0 2px; color: #aaa; font-size: 13px; user-select: none; flex-shrink: 0; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
tr.dragging td { opacity: 0.4; background: #f0f4ff; }
tr.drag-over-top td    { border-top: 2px solid #3498db !important; }
tr.drag-over-bottom td { border-bottom: 2px solid #3498db !important; }

/* ── PROGRESS HANDLE ─────────────────────────────────────────────────────── */
.prog-popup {
    position: absolute; bottom: 115%; left: 50%; transform: translateX(-50%);
    background: #1a1a2e; color: white; font-size: 10px; font-weight: 700;
    padding: 3px 7px; border-radius: 5px; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4); pointer-events: none;
    opacity: 0; transition: opacity 0.15s;
}
.progress-handle:hover .prog-popup { opacity: 1; }

/* ── FORMULÁRIO ───────────────────────────────────────────────────────────── */
.form-section { background: white; border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.form-section h3 { font-size: 11px; margin-bottom: 6px; padding-bottom: 3px; border-bottom: 1px solid #eee; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; margin-bottom: 6px; }
.input-group label { display: block; font-size: 8px; font-weight: 600; margin-bottom: 2px; color: #666; text-transform: uppercase; }
.input-group input, .input-group select { width: 100%; padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px; font-size: 10px; }
button { background: #3498db; color: white; border: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 10px; margin-right: 4px; }
button:hover { background: #2980b9; }

/* ── TABELA ───────────────────────────────────────────────────────────────── */
.table-section { background: white; border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin-bottom: 8px; }
.table-section h3 { font-size: 11px; margin-bottom: 6px; padding-bottom: 3px; border-bottom: 1px solid #eee; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 4px 6px; text-align: left; border-bottom: 1px solid #eee; font-size: 10px; }
th { background: #f8f9fa; font-weight: 600; font-size: 9px; }
.status-badge    { padding: 1px 5px; border-radius: 3px; font-size: 8px; font-weight: 600; display: inline-block; }
.status-critical { background: #e74c3c; color: white; }
.status-warning  { background: #f9a825; color: white; }
.status-feasible { background: #27ae60; color: white; }
.btn-editar  { background: #f39c12; padding: 1px 6px; font-size: 9px; margin: 0 1px; border: none; border-radius: 3px; cursor: pointer; color: white; }
.delete-btn  { background: #e74c3c; padding: 1px 6px; font-size: 9px; margin: 0 1px; border: none; border-radius: 3px; cursor: pointer; color: white; }
.dep-icon    { cursor: help; margin-left: 3px; font-size: 8px; opacity: 0.7; }

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-content { background: white; border-radius: 8px; width: 400px; max-width: 90%; padding: 12px; }
.modal-actions { display: flex; gap: 6px; margin-top: 10px; }
.modal-input { width: 100%; padding: 5px; margin: 3px 0; border: 1px solid #ddd; border-radius: 4px; font-size: 11px; }

/* ── RESPONSIVO ───────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .header { flex-direction: column; align-items: stretch; }
    .form-grid { grid-template-columns: 1fr; }
    .gantt-label { width: 100px; min-width: 100px; font-size: 8px; }
}
