/* ══════════════════════════════════════════════════════════════
   ELYON ENGENHARIA - Sistema de Gestão de Atividades
   Estilos principais
   ══════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #0d1b2a;
  --navy-mid: #1a3050;
  --blue-dark: #1e3a5f;
  --blue-mid: #2d5f8e;
  --blue-accent: #3a7bd5;
  --blue-light: #4a9edd;

  --row-mae: #1a3050;
  --row-filho: #3f7fef;
  --row-neta: #bedefb;
  --row-bisneta: #dcecfb;
  --row-etapa: #fafbfc;

  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f0f4f8;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;

  --text-header: #ffffff;
  --text-dark: #1e293b;
  --text-mid: #475569;

  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --purple: #7c3aed;
  --yellow: #e6a817;

  --border: #d1dce8;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', sans-serif;
  background: #edf1f6;
  color: var(--text-dark);
  font-size: 12px;
  min-height: 100vh;
}

/* ══ TOP NAV ══ */
.topbar {
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--blue-accent), var(--blue-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.logo-text {
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
}

.logo-sub {
  color: var(--gray-400);
  font-size: 8px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-left: 8px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  font-style: italic;
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-link:hover {
  color: rgba(255,255,255,0.6);
}

.nav-link.active {
  color: white;
  font-style: normal;
  font-weight: 500;
  background: rgba(255,255,255,0.1);
  border-bottom: 2px solid var(--blue-accent);
}

.nav-title {
  color: #ffd700;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  color: var(--gray-300);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

.btn-signout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--gray-300);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-signout:hover {
  border-color: white;
  color: white;
}

/* ══ OBRA HEADER ══ */
.obra-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 56px;
  z-index: 90;
}

.obra-select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-dark);
  background: white;
  cursor: pointer;
  min-width: 140px;
}

.obra-select:focus {
  outline: none;
  border-color: var(--blue-accent);
}

.date-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.date-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-dark);
  background: white;
  width: 110px;
  cursor: pointer;
}

.date-input:focus {
  outline: none;
  border-color: var(--blue-accent);
}

.obra-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.btn-export {
  background: white;
  border: 1px solid var(--border);
  color: var(--gray-600);
  border-radius: 4px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-export:hover {
  border-color: var(--blue-accent);
  color: var(--blue-accent);
}

/* ══ MAIN CONTENT ══ */
.main {
  padding: 16px 24px 0;
}

/* ══ TABLE CONTAINER ══ */
.table-scroll-container {
  overflow-x: auto;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1400px;
}

/* Column widths */
col.c-acoes   { width: 72px; }
col.c-tipo    { width: 78px; }
col.c-nome    { width: 220px; }
col.c-pred    { width: 160px; }
col.c-dep     { width: 70px; }
col.c-dur     { width: 65px; }
col.c-pct     { width: 50px; }
col.c-gap     { width: 55px; }
col.c-ini     { width: 80px; }
col.c-fim     { width: 80px; }
col.c-ajuste  { width: 60px; }
col.c-inir    { width: 80px; }
col.c-fimr    { width: 80px; }
col.c-resp    { width: 100px; }
col.c-status  { width: 90px; }

/* ══ THEAD ══ */
thead th {
  background: var(--navy);
  color: var(--text-header);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 8px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th.left {
  text-align: left;
  padding-left: 12px;
}

/* ══ ROW TYPES ══ */
tr.row-mae td {
  background: var(--row-mae);
  color: white;
}

tr.row-filho td {
  background: var(--row-filho);
  color: white;
}

tr.row-neta td {
  background: var(--row-neta);
  color: var(--text-dark);
}

tr.row-bisneta td {
  background: var(--row-bisneta);
  color: var(--text-dark);
}

tr.row-etapa td {
  background: var(--row-etapa);
  color: var(--text-mid);
}

/* ══ TD BASE ══ */
td {
  padding: 7px 8px;
  font-size: 11px;
  vertical-align: middle;
  text-align: center;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

td.left {
  text-align: left;
}

/* ══ TIPO BADGE ══ */
.tipo-badge {
  display: inline;
  font-size: 8.5px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.tipo-mae     { color: rgba(255,255,255,0.9); }
.tipo-filho   { color: rgba(255,255,255,0.9); }
.tipo-neta    { color: var(--blue-mid); }
.tipo-bisneta { color: var(--blue-dark); }
.tipo-etapa   { color: var(--gray-600); }

/* ══ EDITABLE CELLS ══ */
.editable {
  cursor: text;
  border-radius: 3px;
  padding: 2px 4px;
  min-height: 18px;
  display: inline-block;
  min-width: 30px;
  transition: background 0.15s;
}

.editable:hover {
  background: rgba(58,123,213,0.1);
}

.editable:focus {
  outline: 2px solid var(--blue-accent);
  background: white;
  color: var(--text-dark);
  border-radius: 3px;
}

tr.row-mae .editable:focus,
tr.row-filho .editable:focus {
  background: rgba(255,255,255,0.95);
  color: var(--navy);
}

.editable-wide {
  min-width: 120px;
}

.editable-name {
  min-width: 180px;
}

.readonly {
  cursor: default !important;
  user-select: none;
}

.readonly:hover {
  background: transparent !important;
}

.readonly:focus {
  outline: none !important;
  background: transparent !important;
  color: inherit !important;
}

/* ══ PERCENT ══ */
.pct-val {
  font-size: 11px;
  font-weight: 600;
}

tr.row-mae .pct-val,
tr.row-filho .pct-val {
  color: white;
}

tr.row-neta .pct-val {
  color: var(--blue-mid);
}

/* ══ DURATION ══ */
.dur-input {
  min-width: 36px;
  font-weight: 600;
}

[data-role="sub-dur"] {
  font-weight: 500;
  color: inherit;
}

/* ══ GAP / AJUSTE BADGES ══ */
.gap-sum {
  display: inline-block;
  background: var(--yellow);
  color: white;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

.ajuste-sum {
  display: inline-block;
  background: #e03030;
  color: white;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

/* ══ DEPENDENCY SELECT ══ */
.dep-select {
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  font-weight: 600;
}

tr.row-mae .dep-select,
tr.row-filho .dep-select {
  color: white;
}

tr.row-neta .dep-select {
  color: var(--blue-mid);
}

tr.row-bisneta .dep-select {
  color: var(--blue-dark);
}

.dep-select-readonly {
  pointer-events: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* ══ RESPONSAVEL SELECT ══ */
.resp-select {
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  color: inherit;
}

.resp-select:focus {
  outline: 1px solid var(--blue-accent);
  border-radius: 2px;
}

/* ══ STATUS ══ */
.status-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 22px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  pointer-events: none;
  position: relative;
  z-index: 1;
  transition: background 0.2s;
}

.status-dot.nd { background: var(--gray-400); }
.status-dot.em { background: var(--purple); }
.status-dot.ok { background: var(--green); }
.status-dot.at { background: var(--red); }
.status-dot.pa { background: var(--orange); }

.status-select {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  top: 0;
  left: 0;
  z-index: 2;
}

.status-select option {
  color: white;
  background: var(--blue-accent);
}

/* ══ ACTIONS ══ */
.actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.act-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
  font-size: 11px;
  color: inherit;
}

tr.row-mae .act-btn,
tr.row-filho .act-btn {
  color: white;
}

.act-btn:hover {
  opacity: 1;
  background: rgba(58,123,213,0.15);
}

.btn-comment.has-comments {
  color: #3f7fef !important;
  opacity: 1;
}

.btn-attach.has-attachments {
  color: #3f7fef !important;
  opacity: 1;
}

/* ══ CRITICAL ROW ══ */
tr.row-critical td,
tr.row-critical td span,
tr.row-critical td select,
tr.row-critical .tipo-badge {
  color: #e03030 !important;
}

tr.row-critical .btn-critical {
  color: #e03030 !important;
  opacity: 1;
}

/* ══ CALENDAR POPUP ══ */
.cal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
}

.cal-popup {
  position: fixed;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  padding: 16px;
  width: 264px;
  z-index: 501;
  font-family: 'Inter', sans-serif;
  border: 1px solid var(--border);
  display: none;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--navy);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  line-height: 1;
}

.cal-nav:hover {
  background: var(--gray-100);
}

.cal-month-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.3px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-day {
  text-align: center;
  font-size: 12px;
  padding: 6px 2px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-dark);
  transition: background 0.1s, color 0.1s;
  border: none;
  background: none;
  width: 100%;
  font-family: 'Inter', sans-serif;
}

.cal-day:hover {
  background: var(--gray-100);
}

.cal-day.today {
  font-weight: 700;
  color: var(--blue-accent);
}

.cal-day.selected {
  background: var(--blue-accent);
  color: white;
  font-weight: 600;
}

.cal-day.other-month {
  color: var(--gray-300);
}

.cal-day.selected:hover {
  background: var(--blue-mid);
}

.cal-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.cal-btn-today {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: white;
  color: var(--gray-600);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.cal-btn-today:hover {
  border-color: var(--blue-accent);
  color: var(--blue-accent);
}

.cal-btn-ok {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: var(--blue-accent);
  color: white;
  padding: 5px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-btn-ok:hover {
  background: var(--blue-mid);
}

/* ══ SIDE PANEL ══ */
.side-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,0.25);
}

.side-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 601;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
  font-family: 'Inter', sans-serif;
}

.side-panel.open {
  right: 0;
}

.panel-header {
  background: var(--navy);
  color: white;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.panel-subtitle {
  font-size: 11px;
  color: var(--gray-300);
  margin-top: 2px;
}

.panel-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.panel-close:hover {
  background: rgba(255,255,255,0.15);
}

/* ══ COMMENT PANEL ══ */
.comment-user-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--gray-50);
}

.comment-user-label {
  font-size: 11px;
  color: var(--gray-600);
  font-weight: 500;
}

.comment-user-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  flex: 1;
}

.comment-user-input:focus {
  outline: none;
  border-color: var(--blue-accent);
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-item {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue-accent);
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
}

.comment-time {
  font-size: 10px;
  color: var(--gray-400);
}

.comment-text {
  font-size: 12px;
  color: var(--text-dark);
  line-height: 1.5;
}

.comment-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  padding: 32px 0;
}

.comment-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.comment-textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  resize: none;
  height: 60px;
  line-height: 1.4;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--blue-accent);
}

.comment-send {
  background: var(--blue-accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.comment-send:hover {
  background: var(--blue-mid);
}

/* ══ ATTACH PANEL ══ */
.attach-drop-zone {
  margin: 16px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.attach-drop-zone:hover,
.attach-drop-zone.dragover {
  border-color: var(--blue-accent);
  background: rgba(58,123,213,0.04);
}

.attach-drop-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.attach-drop-text {
  font-size: 12px;
  color: var(--gray-600);
}

.attach-drop-sub {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 3px;
}

.attach-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-50);
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.attach-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.attach-info {
  flex: 1;
  min-width: 0;
}

.attach-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-size {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 2px;
}

.attach-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 3px;
}

.attach-remove:hover {
  color: var(--red);
  background: rgba(239,68,68,0.08);
}

.attach-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  padding: 20px 0;
}

.attach-error {
  color: var(--red);
  font-size: 11px;
  text-align: center;
  margin: 0 16px 8px;
}

#attachFileInput {
  display: none;
}

/* ══ TOAST ══ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--navy);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
