/* ===== Tabela (visão alternativa) ===== */
.tableTop {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
}

.tableTop .btn {
  box-shadow: var(--shadow)
}

.tableWrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  flex: 1;
  /* Allow it to grow */
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  /* Enable inner scrolling for sticky headers */
}

#tableView {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: left;
  font-size: 12px;
  color: rgba(231, 238, 247, .92);
  font-weight: 600;
  padding: 12px 14px;
  white-space: nowrap;
  background: var(--panel2);
  /* Garante visibilidade no rolar */
}

th.tableSortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

th.tableSortable:hover {
  background: var(--panel);
}

th .sortIndicator {
  display: inline-block;
  min-width: 14px;
  text-align: center;
  margin-left: 4px;
  color: var(--accent);
}

tfoot td {
  font-weight: bold;
  background: var(--panel2);
  position: sticky;
  bottom: 0;
  z-index: 5;
  border-top: 2px solid var(--line);
}

tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: rgba(231, 238, 247, .92);
  font-size: 13px;
  vertical-align: top;
}

tbody tr {
  cursor: pointer;
  transition: background .12s ease;
}

tbody tr:hover {
  background: rgba(78, 161, 255, .10);
}

.tdMuted {
  color: rgba(159, 176, 195, .92);
  font-size: 12px;
  white-space: nowrap
}

.tdMono {
  font-variant-numeric: tabular-nums;
  white-space: nowrap
}

.tdNotes {
  color: rgba(231, 238, 247, .88);
  max-width: 520px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tagProject {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}


/* ===== Botões de visão (Calendário / Tabela / Gantt) ===== */
.viewBtns {
  display: flex;
  align-items: center;
  gap: 5px;
  row-gap: 5px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-start
}

.btn.active {
  border-color: rgba(78, 161, 255, .60);
  background: rgba(78, 161, 255, .18);
}

/* ===== Gantt (visão por projeto) ===== */
.ganttControls {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ganttControls .ctrlLabel {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px
}

.ganttControls .ctrlSelect {
  min-width: 240px;
  max-width: 360px;
}

.ganttWrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* Fundo simplificado para o Gantt */
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
}

table.gantt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

table.gantt thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: center;
  font-size: 12px;
  color: rgba(231, 238, 247, .92);
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  white-space: nowrap;
  font-weight: 750;
  letter-spacing: .2px;
}

table.gantt thead th.left {
  text-align: left
}

table.gantt tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: rgba(231, 238, 247, .92);
  font-size: 13px;
  vertical-align: middle;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

table.gantt tbody td.left {
  text-align: left
}

table.gantt tbody tr:hover {
  background: rgba(78, 161, 255, .08)
}

.gCell {
  border-left: 1px solid rgba(255, 255, 255, .06);
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.gCell.on {
  background: rgba(78, 161, 255, .22);
  border-color: rgba(78, 161, 255, .28);
  color: #07121f;
  font-weight: 800;
}

.gCell.on span {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .65);
  color: #06121f;
  border: 1px solid rgba(0, 0, 0, .12);
}

/* ===== Filtros da Tabela (Projeto + Atividade) ===== */
.tableFilters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-right: auto;
}

.tableFilters .ctrlDate {
  width: 180px;
  min-width: 180px;
}

.tableFilters .ctrlSelect {
  min-width: 180px;
  max-width: 250px;
}

#tableProjectFilter,
#tableActivityFilter {
  min-width: 210px;
  max-width: 240px;
}

#tableArtiaLaunchFilter {
  min-width: 110px;
  max-width: 130px;
}

.filterLabelGroup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ctrlLabel--spaced {
  margin-left: 4px;
}

/* ===== Gantt com cabeçalho em 2 linhas (igual Calendário) ===== */
table.gantt thead th {
  vertical-align: bottom;
  white-space: normal;
}

table.gantt thead th.gDayHead {
  text-align: left;
  padding: 10px 10px 8px;
}

.gDayName {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px
}

.gDayDate {
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .2px
}

.gDayWorked {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(231, 238, 247, .88);
  letter-spacing: .2px;
}

.gDayWorked .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(0, 0, 0, .18);
  white-space: nowrap;
}

.gDayWorked .chip .miniDot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(66, 211, 146, .9);
  box-shadow: 0 0 0 4px rgba(66, 211, 146, .12);
}

.artiaLaunchField {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 600;
}

.artiaLaunchHint {
  font-weight: 400;
  font-size: .92em;
  color: var(--muted);
}

.artiaLaunchField input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.artiaLaunchCheck {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
}

.artiaLaunchCheck::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(-45deg) scale(.8);
  margin-top: -1px;
}

.artiaLaunchField input:checked+.artiaLaunchCheck {
  background: rgba(66, 211, 146, .18);
  border-color: rgba(66, 211, 146, .65);
  transform: translateY(-1px);
}

.artiaLaunchField input:checked+.artiaLaunchCheck::after {
  border-left-color: #4ad392;
  border-bottom-color: #4ad392;
}

.tableLaunchCell {
  text-align: center;
  width: 150px;
}

.tableLaunchToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  color: transparent;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, color .15s ease;
}

.tableLaunchToggle[data-checked="true"] {
  border-color: rgba(66, 211, 146, .65);
  background: rgba(66, 211, 146, .18);
  color: #4ad392;
  transform: translateY(-1px);
}

/* Sticky coluna Projeto no Gantt (igual lista da Tabela) */
table.gantt thead th.left {
  position: sticky;
  left: 0;
  z-index: 6;
  background: rgba(14, 23, 34, .98);
}

table.gantt tbody td.left {
  position: sticky;
  left: 0;
  z-index: 4;
  background: linear-gradient(180deg, rgba(18, 26, 36, .82), rgba(18, 26, 36, .55));
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: auto;
  box-sizing: border-box;
}

.modalBackdrop.show {
  display: flex
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100dvh - 20px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid rgba(148, 186, 229, .24);
  background: linear-gradient(180deg, rgba(30, 42, 56, .98), rgba(24, 35, 48, .96));
  box-shadow: 0 20px 64px rgba(0, 0, 0, .62);
  overflow: hidden;
}

.modalHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  gap: 10px
}

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

.modalHeaderMeta {
  display: grid;
  gap: 4px;
}

.modalDateRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none
}

.modalHeader h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .2px
}

.modalHeader .when {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25
}

.ctrlDate--compact {
  height: 26px;
  padding: 4px 8px;
  font-size: 12px;
}

.when--compact {
  margin-top: 0;
}

.modalDuration {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.roundingModal {
  width: min(520px, 100%);
}

.artiaModal {
  width: min(560px, 100%);
}

#artiaKeysForm,
#artiaDbForm,
#artiaOauthPanel,
#artiaConnectedView {
  display: grid;
  gap: 12px;
}

#artiaKeysForm.hidden,
#artiaDbForm.hidden,
#artiaOauthPanel.hidden,
#artiaChooser.hidden,
#artiaConnectedView.hidden {
  display: none;
}

.artiaMethods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.artiaMethod {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .14);
  cursor: pointer;
}

.artiaMethod.hidden {
  display: none;
}

.artiaMethod:has(input:checked) {
  border-color: rgba(78, 161, 255, .60);
  box-shadow: 0 0 0 3px rgba(78, 161, 255, .12);
}

.artiaMethod input {
  margin-top: 2px;
}

.artiaMethod span {
  display: grid;
  gap: 3px;
}

.artiaMethod strong {
  font-size: 13px;
  color: var(--text);
}

.artiaMethod small {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
}

html.light .artiaMethod {
  background: rgba(15, 23, 42, .03);
}

@media (max-width: 560px) {
  .artiaBody .row.grid2 {
    grid-template-columns: 1fr;
  }
}

.artiaBody input[type="password"],
.artiaBody input[type="text"] {
  width: 100%;
  background: rgba(0, 0, 0, .18);
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  font-size: 13px;
}

.artiaBody input:focus {
  border-color: rgba(78, 161, 255, .50);
  box-shadow: 0 0 0 4px rgba(78, 161, 255, .10);
}

html.light .artiaBody input[type="password"],
html.light .artiaBody input[type="text"] {
  background: #ffffff;
}

.artiaStatus {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .14);
  font-size: 13px;
  line-height: 1.35;
}

.artiaInviteRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.artiaError {
  color: #ff8f8f;
  font-size: 12px;
  line-height: 1.3;
}

@media (max-width: 560px) {
  .artiaInviteRow {
    grid-template-columns: 1fr;
  }
}
